我正在尝试一种 SQL 注入(inject):
http://localhost/test/mysql.php?uid=1;%20DROP%20TABLE%20test
此 URL 应等于语句:
SELECT username FROM test WHERE userid=1; DROP TABLE test
但是,当我打开这个 URL 时弹出一个错误:
Error:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'drop table test' at line 1
'drop table test' 好像是放在一对引号里,但不被当做语句。对应的php代码是这样的:
$SQL="select username from login where userid=".$userid;
$result=mysql_query($SQL);
我想知道为什么。感谢您提供任何有用的答案。
最佳答案
mysql_query
不支持一次执行多条语句:
mysql_query()
sends a unique query (multiple queries are not supported) to the currently active database on the server that's associated with the specifiedlink_identifier
.
MySQL 错误消息也反射(reflect)了这一点,该消息将 ;
之后的所有内容都引用为意外。
关于mysql - 这个SQL注入(inject)不行,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24902663/