I find myself in need of a way to show how some things can go wrong with php, databases, and the web. I decided there are few better ways than to demonstrate an SQL injection.
My problem is, however, that the injections don't appear to be working.
I've made sure that the variables passed through are pure input (employed stripslashes(), didn't use mysql_real_escape_string(), and so on). I've made various different attempts at injection, but so far the best result I get is an error about the following line:
if (mysql_num_rows($execute) == NULL){mysql_num_rows(): supplied argument is not a valid MySQL result resourceWhich is the error appearing on attempted injections.
Here is some of the code I have been using:
if (!$db){
die("<font color='#F62817'><b>Error: Could not connect to database - ".mysql_error()."</b></font><p>\n");
include("admin_loginform.php");
mysql_close($db);
} //end of if
else {
//Leaving $admin and $password open to SQL injection for demonstration purposes
$query="SELECT *
FROM admins
WHERE username='$admin' AND password='$password'";
$execute=mysql_query($query,$db);
if (mysql_num_rows($execute) == NULL){
echo "<font color='#F62817'><b>Error: Invalid username or password.</b></font><p>\n";
include("admin_loginform.php");
mysql_close($db);
} //end of if
else {
echo "<font color='#5EFB6E'><b>Welcome to administration, $admin.</font></b><br>\n";
echo "What do you want to do?<br>\n";
Can anyone tell me what I could do to make my script vulnerable? For once I want my script to be exploited and I find it doesn't work anyway! I've Googled a bit but I've either not looked in the right places or (oddly enough) there's not much material on how to MAKE a website more vulnerable.Summary: I need my script to be exploitable via SQL injection. Any ideas please?


Sign In
Create Account



Back to top









