- Joined
- Feb 7, 2008
- Messages
- 186
- Reaction score
- 19
WooAF you can say this is "insecure" "insecure" all you want but try to SQL inject you aren't going to be able to.
Let me clear up what are you confused about WooAF, you are thinking I am just tossing $_POST['password'] into the DB before checking it at all. But I am, if you look at the long if statement you will see
What this is doing is replacing everything that isn't a-z,A-Z,0-9 with nothing and if that isn't the exact same thing as $_POST['password'] it will error.
Hope this helps you understand PHP a bit more, friend.
Let me clear up what are you confused about WooAF, you are thinking I am just tossing $_POST['password'] into the DB before checking it at all. But I am, if you look at the long if statement you will see
PHP:
preg_replace("/[^a-zA-Z\d ]/", "", $_POST['password']) != $_POST['password']
Hope this helps you understand PHP a bit more, friend.
PHP:
<?php
$link = mssql_connect('COMPUTER\\iPlayWarZ', 'sa', 'password');
$selectdb = mssql_select_db("WarZ");
if (!$link || !$selectdb){
die('DB Issue');
}
if(isset($_POST['Submit'])){
/* ugly but it works */
if(empty($_POST['email']) || empty($_POST['password']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) || preg_replace("/[^a-zA-Z\d ]/", "", $_POST['password']) != $_POST['password'] || strlen($_POST['password']) > 50){ //Since I don't know what the max password size is you should change this.
die("Something went wrong.");
}
$query = mssql_query("SELECT `email` FROM Accounts WHERE email = '".$_POST['email']."'"); //No need to select EVERYTHING from that row.
$query = mssql_num_rows($query);
if($query > 0){
die("Email is already in-use. Please use a different one.");
}
else{
mssql_query("EXEC WZ_ACCOUNT_CREATE '".$_SERVER['REMOTE_ADDR']."', '".$_POST['email']."', '".$_POST['password']."', 0, 0, 0");
die("Account created");
}
}
?>
<!--
This is only a sample script, you can remove, edit, what you want.
-->
<form method="post">
<center>
<fieldset>
<legend>Register</legend>
<!-- Email -->
<label for='email' >Email Address*:</label>
<input type='text' name='email' maxlength="50" /><br>
<!-- Password -->
<label for='password' >Password*:</label>
<input type='password' name='password' maxlength="50" /><br>
<!-- Submit -->
<input type='submit' name='Submit' value='Register' />
</fieldset>
</center>
</form>
Last edited:

