Bypassing web application firewils with sqlmap tamper scripts

Source: Internet
Author: User

Http://websec.ca/blog/view/Bypassing_WAFs_with_SQLMap

Web application firewils have become the new security solution for several businesses. compile companies often ignore the actual vulnerabilities and merely rely on the firewall for protection. regrettably, most, if not all firewils can be bypassed. in saying
This, my post will demonstrate how to use some of sqlmap's new features to bypass WAFS/IDSS.

I have recently had the pleasure of working on a few tamper scripts for sqlmap, which can be found in the latest development version from the Subversion repository.

SVN checkout https://svn.sqlmap.org/sqlmap/trunk/sqlmap sqlmap-Dev

The focus of the tamper scripts is to modify the request in a way that will evade the detection of the WAF (Web application firewall) Rules. in some cases, you might need to combine a few tamper scripts together in order to fool the WAF. for a complete list
Of the tamper scripts, you can refer tohttps: // svn.sqlmap.org/sqlmap/trunk/sqlmap/tamper/

The first scripts I'll demonstrate are space2hash. py and space2morehash. py which
Work with MySQL (still haven't gotten around to the MSSQL one ). these scripts will convert all spaces to block comments with random text. the extended version of the script (space2morehash. PY) will also add the comments in between certain function names and
The parenthesis.

To get started using the tamper scripts, you use the -- tamper switch followed by the script name.
In my example I'm using the following command:

./Sqlmap. py-u http: // 192.168.0.107/test. php? Id = 1-V 3 -- DBMS "MySQL" -- technique u-p id -- batch -- tamper
"Space2morehash. py"


Figure 1: space2morehash. py tamper script in action


As shown in figure 1, the tamper script replaces the spaces in the injection with % 23 randomtext % 0a,
Which is of course URL encoded. The function's Char (), user (), Concat () Get
Changed to function % 23 randomtext % 0a () since they aren't blacklisted inignore_space_affected_keywords.
This is because of MySQL's Function
Name Parsing and resolution and how it treats function calland identifiers.

Another two scripts that transform spaces are space2mssqlblank. py and space2mysqlblank. py.
MySQL allows characters 09, 0a-0d, a0
Be used as whitespaces while MSSQL allows a much wider range, from 01-1f.


Figure 2: space2mssqlblank. py using different characters as whitespaces


Next up we have a few scripts that mess around with the encoding: charencode. py andchardoubleencode. py.
These are useful to bypass different keyword filters, for example when table_name is being detected and there is no way around it.


Figure 3: charencode. py can be used to evade Keyword Detection


If the application URL decodes the request for some reason (some do), The chardoubleencode. py script can come in handy.


Figure 4: chardoubleencode. py can be used when the application decodes the request


Additionally, if the application is programmed in ASP/ASP. NET, The charunicodeencode. py andpercentage. py scripts
Can be used to hide the true payload.


Figure 5: charunicodeencode. py obfuscating the injection with Unicode encoding


An interesting characteristic of ASP is the ability to add as your percentage signs as you want in between characters. For example, and
1 = % 1 is completely valid!


Figure 6: percent signs in between each character is valid in ASP


In conclusion, I 've shown just a few of your tamper scripts. I highly recommend testing them out as each one can be used in different situations. I will be working on a few more this month, so be sure to stay tuned.

References:
Sqlmap
SQL
Injection pocket reference

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.