this is part of an assignment for my computer security class, so I'm not looking for specific answers, just some help.
We were given a faulty program (in php) that controls a sql database (a bank account) and we have to find a way to create a SQL injection attack that will let us log into an account without knowing it's ID ahead of time.
I'm pretty sure I know where the vulnerability is, but I can't quite seem to get my attacks to work.
The code in question (it's kinda long, but the only part that matters is in the first part):
FrobozzCo Community Credit Union
FrobozzCo Community Credit Union
We're working for GUE
$debugmode = 1;
function debug($msg) {
global $debugmode;
if ($debugmode) {
echo "$msg
\n";
}
}
$thispage = 'FCCU.php';
echo "
Done.
The line:
$query = "SELECT * FROM accounts WHERE id = $id AND password = '$password'";
I've tried a couple of strings in the ID input (I'm working from my browser) such as
100 OR id=id;
0 OR 1=1;
To try and comment out the password part of the command. I'm pretty new to SQL so I think I'm just formatting this wrong.
That or I'm completely overlooking a more obvious exploit.
Answer
You need to make sure to comment out the rest of the query, so the quotes don't trip you up and so any extra clauses are ignored.
Try setting the ID to:
0 OR id=id --
The --
(that's hyphen, hyphen, space: the space is important) is a comment in MySQL.
No comments:
Post a Comment