SQL injection questions

Suppose the web server uses the following PHP code to process login requests:

$username = $_POST[user]; $password = $_POST[pass]; $sql = "SELECT * FROM users WHERE name = '$username' AND password = '$password'"; if(mysql_num_rows($rs) > 0){ //do something } 
  • What is the meaning of a username that a successful login will always have?

I think that the value ' OR 1=1 will always lead to a successful login, because then the request will look like this:

 "SELECT * FROM users WHERE name = '' OR 1=1 AND password = '$password'" 

Is it correct?

  1. Suppose the data is configured to use the Chinese Unicode GBIC character set. In GBK, byte 0x5c encodes \ and 0x27 encodes ' . Bytes 0xbf27 represent two ΒΏ' characters, and bytes 0xbf5c represent one Chinese character. If the username and password fields add slashes to ' , " , \ and null , which username will always result in a successful login, assuming the database interprets this string as GBK, but adds slash processes how is ascii?

I'm not sure what the last part of the sentence means (interpreting as GBK, but processing as ASCII). Can someone shed some light on how to solve this problem?

+7
sql php sql-injection
source share

No one has answered this question yet.

See similar questions:

36
How to create a SQL injection attack using Shift-JIS and CP932?

or similar:

3491
How can I UPDATE from SELECT in SQL Server?
2776
How can I prevent SQL injection in PHP?
2603
Add a default column to an existing table in SQL Server
1762
How to import SQL file using command line in MySQL?
1658
How to return only date from SQL Server DateTime data type
1657
Find duplicate values ​​in SQL table
1587
Insert multiple rows into a single SQL query?
1064
How does SQL injection work from the XBCD Bobby Tables comic?
562
SQL injection that spreads around mysql_real_escape_string ()
558
Are PDO prepared statements sufficient to prevent SQL injection?

All Articles