Skip to content Skip to sidebar Skip to footer

Hacking Php Code With Sql Injection

I have some code like this which is open to SQL injection. We got hacked and now we fixed it. I just want to know what the inputs (username and password) must be in order to hack t

Solution 1:

Use variable binding in PDO library.

Solution 2:

If hacker pass value:

$username = "' OR * OR '"

then query will be:

SELECT password FROM tbl_users WHERE username='' OR * OR ''; - this will be select any user.

But hacker can:

$username = "'; DELETE * FROM tbl_users WHERE username = * OR '";

SELECT password FROM tbl_users WHERE username = ''; DELETE * FROM tbl_users WHERE username = * OR '';

Or can made UPDATE to change any password.

Safety? mysql_real_escape_string or preg_match("/^[a-zA-Z0-9]{3,15}$/", $username), for example.

Solution 3:

Using boolean blind or time blind injection hacker can retrieve all the database structure.

Example:

username = 'admin' and if(1=1, sleep(10), 5222) #

This query gonna take 10 second to return and confirm that your condition is true or false. Using the information_schema and SQL condition test you can retrieve all databases information.

Post a Comment for "Hacking Php Code With Sql Injection"