Even if you use mysql_real_escape_string (), the sql injection may still occur
Although it is generally believed that mysql_real_escape_string () can prevent SQL injection, in specific cases, SQL injection may still happen. The following explains how this attack happened:
Set the server character set to allow the ASCII back slope (0x5C) and the invalid multi -line character character set (for example, GBK). This can be implemented through the Set Names statement.
Create an effective load starting with 0xbf27. In the specified character set (for example, GBK), this means an invalid multi -line character that will be converted to 0x27 (skimp) in Latin1.
mysql_real_escape_string () based on connected character sets (GBK) operations, rather than the client faked character set (Latin1). It will be effective to be valid to 0x5c27. However, because the client still believes that it uses Latin1, the backslash (0x5C) is still unprofitable.
MySQLI is not affected because it uses a real pre -processing statement.
Relieve measures:Disable simulation pre -processing statements in PDO.
You can reduce this potential loophole.
The above is the detailed content of Can SQL Injection Still Occur Even with `mysql_real_escape_string()`?. For more information, please follow other related articles on the PHP Chinese website!