<center><h1><u>Register:</u></h1>
<?php
require_once('API/recaptchalib.php');
$pubkey='6LdU6sUSAAAAAKDtN5TkL_LlOD5Al_SCyoPFOD0V' ; //your reCaptcha public key
$privkey='6LdU6sUSAAAAAMs-kqVdGJUSuz5wuNNpmbEL0dBw'; //your reCaptcha private key.
$design='red'; //reCaptcha style, found
?>
<script type="text/javascript">
var RecaptchaOptions = {
theme : '<?php echo $design; ?>'
};
</script>
<center>
<?php
require('./configs/reg_conf.php');
function doesUsernameExist($name){
$exit = FALSE;
$result = @mssql_query("SELECT * FROM ACCOUNT_TBL WHERE account='$name'");
if (mssql_num_rows($result) != 0){
$exit = TRUE;
}
return $exit;
}
if(isset($_POST['submit'])){
$user = preg_replace ("
/[^A-Za-z0-9]/", "", $_POST['username']);
$pass = preg_replace ("
/[^A-Za-z0-9]/", "", $_POST['password']);
$resp = recaptcha_check_answer ($privkey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if($_POST['username'] == ""){
echo '<font color="red">Enter a user.</font><br /><br />';
}
else if($_POST['password'] == ""){
echo '<font color="red">Enter a password.</font><br /><br />';
}
else if ((strlen($_POST['username']) > 16) || (strlen($_POST['username']) < 3)){
echo '<font color="red">The user should be 3 to 16 characters.</font><br /><br />';
}
else if ((strlen($_POST['password']) > 16) || (strlen($_POST['password']) < 3)){
echo '<font color="red">The password should be 3 to 16 characters.</font><br /><br />';
}
else if($_POST['username'] != $user){
echo '<font color="red">User with invalid characters.</font><br /><br />';
}
else if($_POST['password'] != $pass){
echo '<font color="red">Password with invalid characters.</font><br /><br />';
}
else if(strlen($_POST["recaptcha_response_field"]) == 0){
echo '<font color="red">Did you forget to enter reCaptcha?</font><br />';
}
else if(!$resp->is_valid){
echo 'You have entered the reCaptcha wrong, reCaptcha said:'.$resp->error;
}
else {
$pass = md5('kikugalanet' . $pass);
if(!doesUsernameExist($user)){
$stmt = mssql_init('webCreateAcc', $link);
mssql_bind($stmt, '@account', $user, SQLVARCHAR, false, false, 15);
mssql_bind($stmt, '@password', $pass, SQLVARCHAR, false, false, 36);
mssql_bind($stmt, '@email', $mail, SQLVARCHAR, false, false, 120);
mssql_execute($stmt) or die ("Something is wrong on the execution");
mssql_free_statement($stmt);
echo '<font color="Green">Register Successfull.</font><br /><br />';
}
else {
echo '<font color="red">User already Exist.</font><br /><br />';
}
}
mssql_close();
}
echo '<form action="#" method="post">';
echo 'Username: <input type="text" name="username" /><br />';
echo 'Password: <input type="password" name="password" /><br />';
echo '<input type="submit" name="submit" value="Register" />';
echo recaptcha_get_html($pubkey);
?>
</center>
</div>
<div class="cbox-ui cbox-end"></div>
</div>
<div class="cui cbottom"></div>
</div>
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$time = date("l dS of F Y h:i:s A");
$fp = fopen ("[WEB]SQL_Injection.txt", "a+");
$sql_inject_1 = array(";","'","%",'"'); #Whoth need replace
$sql_inject_2 = array("", "","","""); #To wont replace
$GET_KEY = array_keys($_GET); #array keys from $_GET
$POST_KEY = array_keys($_POST); #array keys from $_POST
$COOKIE_KEY = array_keys($_COOKIE); #array keys from $_COOKIE
/*begin clear $_GET */
for($i=0;$i<count($GET_KEY);$i++)
{
$real_get[$i] = $_GET[$GET_KEY[$i]];
$_GET[$GET_KEY[$i]] = str_replace($sql_inject_1, $sql_inject_2, HtmlSpecialChars($_GET[$GET_KEY[$i]]));
if($real_get[$i] != $_GET[$GET_KEY[$i]])
{
fwrite ($fp, "IP: $ip\r\n");
fwrite ($fp, "Method: GET\r\n");
fwrite ($fp, "Value: $real_get[$i]\r\n");
fwrite ($fp, "Script: $script\r\n");
fwrite ($fp, "Time: $time\r\n");
fwrite ($fp, "==================================\r\n");
}
}
/*end clear $_GET */
/*begin clear $_POST */
for($i=0;$i<count($POST_KEY);$i++)
{
$real_post[$i] = $_POST[$POST_KEY[$i]];
$_POST[$POST_KEY[$i]] = str_replace($sql_inject_1, $sql_inject_2, HtmlSpecialChars($_POST[$POST_KEY[$i]]));
if($real_post[$i] != $_POST[$POST_KEY[$i]])
{
fwrite ($fp, "IP: $ip\r\n");
fwrite ($fp, "Method: POST\r\n");
fwrite ($fp, "Value: $real_post[$i]\r\n");
fwrite ($fp, "Script: $script\r\n");
fwrite ($fp, "Time: $time\r\n");
fwrite ($fp, "==================================\r\n");
}
}
/*end clear $_POST */
/*begin clear $_COOKIE */
for($i=0;$i<count($COOKIE_KEY);$i++)
{
$real_cookie[$i] = $_COOKIE[$COOKIE_KEY[$i]];
$_COOKIE[$COOKIE_KEY[$i]] = str_replace($sql_inject_1, $sql_inject_2, HtmlSpecialChars($_COOKIE[$COOKIE_KEY[$i]]));
if($real_cookie[$i] != $_COOKIE[$COOKIE_KEY[$i]])
{
fwrite ($fp, "IP: $ip\r\n");
fwrite ($fp, "Method: COOKIE\r\n");
fwrite ($fp, "Value: $real_cookie[$i]\r\n");
fwrite ($fp, "Script: $script\r\n");
fwrite ($fp, "Time: $time\r\n");
fwrite ($fp, "==================================\r\n");
}
}
/*end clear $_COOKIE */
fclose ($fp);
?>
Jetzt sollten keine SQL Injektion's mehr klappen
MfG
hanns.g