BY: Hans
Magic_quotes_gpc = on
Everyone knows the php configuration file php. in. If the magic_quotes_gpc configuration in it is opened, magic_quotes_gpc = on anyone who knows something about php knows it.
Then we need to inject numeric fields.
<?
If (isset ($ _ POST ["f_login"])
{
// Connect to the database
$ T_strUid = $ _ POST ["f_uid"];
$ T_strPwd = $ _ POST ["f_pwd"];
$ T_strSQL = "SELECT * FROM tbl_users WHERE uid = $ t_strUid AND password = '$ t_strPwd' LIMIT 0, 1 ";
If ($ t_hRes = mysql_query ($ t_strSQL ))
{
// Query successful
}
}
?>
<Html>
<Body>
<Form method = post action = "">
User ID: <input type = "text" name = "username" size = 30> <br>
Password: <input type = text name = "userpwd" size = 30> <br>
<Input type = "submit" name = "user_login" value = "Logon">
</Form>
</Body>
The above Code requires us to enter username and password to log on. Some codes are omitted.
If entered correctly:
Select * from tbltable_users WHERE userid = admin AND password = 'admin' LIMIT 0, 1
If the attacker enters admin OR 1 = 1 # At username, the SQL statement injected is as follows:
SELECT * FROM table_users WHERE userid = admin OR 1 = 1 # AND password = 'admin' LIMIT 0, 1
The following code can be injected.
In php. ini, set the display_errors option to display_errors = off.