sql limit 子句注入

sql injection on limit clause

是否有可能在以下查询中利用 sql 注入?

mysql_query("SELECT `one`, `two`, `three` FROM test LIMIT ".$vulnerablepost.",2;") or die(mysql_error());

可能的查询类型有哪些?是否可以执行 SELECT OUTFILE? 谢谢

是的。由于可以操纵或调整输入以注入错误SQL。如果您的输入值看起来像

怎么办
$vulnerablepost = "20;delete from student_table;select 1";

您最终会遇到如下所示的 SQL 查询,它在语法上是正确的,但会给您带来麻烦

SELECT `one`, `two`, `three` FROM test LIMIT 20;delete from student_table;select 1,2;

是的,您不应该使用它。使用 PDO 或 Mysqli。 http://php.net/manual/en/ref.pdo-mysql.php

因此,除非您使用的是非常旧的 PHP 版本,否则您不应使用该功能。您甚至还可以查看该页面的文档。 http://php.net/manual/en/function.mysql-query.php

Warning
This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include:
mysqli_query()
PDO::query()