GithubHelp home page GithubHelp logo

nemesida-waf / waf-bypass Goto Github PK

View Code? Open in Web Editor NEW
1.2K 23.0 155.0 700 KB

Check your WAF before an attacker does

Home Page: https://nemesida-waf.com

License: MIT License

Python 98.88% Dockerfile 1.12%
waf python3 bypass python rce xss waf-bypass-tool api-security-testing lfi nosql-injection

waf-bypass's Introduction

WAF Bypass Tool

WAF bypass Tool is an open source tool to analyze the security of any WAF for False Positives and False Negatives using predefined and customizable payloads. Check your WAF before an attacker does. WAF Bypass Tool is developed by Nemesida WAF team with the participation of community.

WAF Bypass Tool

How to run

It is forbidden to use for illegal and illegal purposes. Don't break the law. We are not responsible for possible risks associated with the use of this software.

Run using Docker

The latest waf-bypass always available via the Docker Hub. It can be easily pulled via the following command:

# docker pull nemesida/waf-bypass
# docker run nemesida/waf-bypass --host='example.com'

Run using pipx

# pipx install git+https://github.com/nemesida-waf/waf-bypass.git
# <pipx bin dir>/waf-bypass

Run directly from source code using CLI

# git clone https://github.com/nemesida-waf/waf_bypass.git /opt/waf-bypass/
# python3 -m pip install -r /opt/waf-bypass/requirements.txt
# python3 /opt/waf-bypass/main.py --host='example.com'

Options

  • '--proxy' (--proxy='http://proxy.example.com:3128') - option allows to specify where to connect to instead of the host.

  • '--header' (--header 'Authorization: Basic YWRtaW46YWRtaW4=' --header 'X-TOKEN: ABCDEF') - option allows to specify the HTTP header to send with all requests (e.g. for authentication). Multiple use is allowed.

  • '--user-agent' (--user-agent 'MyUserAgent 1/1') - option allows to specify the HTTP User-Agent to send with all requests, except when the User-Agent is set by the payload ("USER-AGENT").

  • '--block-code' (--block-code='403' --block-code='222') - option allows you to specify the HTTP status code to expect when the WAF is blocked. (default is 403). Multiple use is allowed.

  • '--threads' (--threads=15) - option allows to specify the number of parallel scan threads (default is 10).

  • '--timeout' (--timeout=10) - option allows to specify a request processing timeout in sec. (default is 30).

  • '--exclude-dir' - exclude the payload's directory (--exclude-dir='SQLi,XSS').

  • '--json-format' - an option that allows you to display the result of the work in JSON format (useful for integrating the tool with security platforms). If the option is not specified, the output will be in table format (the default format).

  • '--details' - display the False Positive and False Negative payloads. Not compatible with option --json-format option.

  • '--curl-replay' - display the cURL command to reproduce False Positive, False Negative or Failed requests. Not compatible with option --json-format option.

JSON format

JSON output specification example:

{
  "TARGET": "https://example.com", // defined by --host option
  "PROXY": {},                     // defined by --proxy option
  "HEADERS": {                     // defined by --header option
    "User-Agent": ""
  },
  "BLOCK-CODE": [                  // defined by --block-code option
    ...
  ],
  "THREADS": 50,                   // defined by --threads option
  "TIMEOUT": 30,                   // defined by --timeout option
  "EXCLUDE-DIR": [                 // defined by --exclude-dir option
    ...
  ],
  "FAILED": {                      // requests with failed processing status
    "MFD/7.json": {
      "BODY": "WBHTTPSConnectionPool(host='example.com', port=443): Read timed out. (read timeout=1)"
    },
    ...
  },
  "PASSED": {                      // passed requests
    "UWA/3.json": {
      "URL": "403 RESPONSE CODE"
    },
    ...
  },
  "FALSED": {                      // requests with false positive processing status
    ...
  },
  "BYPASSED": {                    // requests with false negative processing status
    "UWA/26.json": {
      "URL": "200 RESPONSE CODE"
    },
    ...
  },
  "TestRequest": {                // test requests with processing status, exclude passed
    "FAILED": {},
    "FALSED": {
        "UWA/3.json": {
        "URL": "403 RESPONSE CODE"
        },
        ...
    }
    
  },
  "CURL": {                       // cURL command to reproduce false positive and false negative requests
    "FALSED": {},
    "BYPASSED": {
      "UWA/26.json": {
        "URL": "curl -X GET -H 'Accept: */*' -H 'Accept-Encoding: gzip, deflate' -H 'Connection: keep-alive' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' 'https://example.com/do.php#.png'"
      },
      ...
    }
  }
}

Payloads

Depending on the purpose, payloads are located in the appropriate folders:

  • FP - False Positive payloads
  • API - API testing payloads
  • CM - Custom HTTP Method payloads
  • GraphQL - GraphQL testing payloads
  • LDAP - LDAP Injection payloads
  • LFI - Local File Include payloads
  • MFD - multipart/form-data payloads
  • NoSQLi - NoSQL Injection payloads
  • OR - Open Redirect payloads
  • RCE - Remote Code Execution payloads
  • RFI - Remote File Inclusion payloads
  • SQLi - SQL Injection payloads
  • SSI - Server-Side Includes payloads
  • SSRF - Server-Side Request Forgery payloads
  • SSTI - Server-Side Template Injection payloads
  • UWA - Unwanted Access payloads
  • XSS - Cross-Site Scripting payloads

Write your own payloads

When compiling a payload, the following zones, method and options are used:

  • URL - request's path
  • ARGS - request's query
  • BODY - request's body
  • COOKIE - request's cookie
  • USER-AGENT - request's user-agent
  • REFERER - request's referer
  • HEADER - request's header
  • METHOD - request's method
  • BOUNDARY - specifies the contents of the request's boundary. Applicable only to payloads in the MFD directory.
  • ENCODE - specifies the type of payload encoding (Base64, HTML-ENTITY, UTF-16) in addition to the encoding for the payload. Multiple values are indicated with a space (e.g. Base64 UTF-16). Applicable only to for ARGS, BODY, COOKIE and HEADER zone. Not applicable to payloads in API and MFD directories. Not compatible with option JSON.
  • JSON - specifies that the request's body should be in JSON format
  • BLOCKED - specifies that the request should be blocked (FN testing) or not (FP)

Except for some cases described below, the zones are independent of each other and are tested separately (those if 2 zones are specified - the script will send 2 requests - alternately checking one and the second zone).

For the zones you can use %RND% suffix, which allows you to generate an arbitrary string of 6 letters and numbers. (e.g.: param%RND=my_payload or param=%RND% OR A%RND%B)

You can create your own payloads, to do this, create your own folder on the '/payload/' folder, or place the payload in an existing one (e.g.: '/payload/XSS'). Allowed data format is JSON.

API directory

API testing payloads located in this directory are automatically appended with a header 'Content-Type: application/json'.

MFD directory

For MFD (multipart/form-data) payloads located in this directory, you must specify the BODY (required) and BOUNDARY (optional). If BOUNDARY is not set, it will be generated automatically (in this case, only the payload must be specified for the BODY, without additional data ('... Content-Disposition: form-data; ...').

If a BOUNDARY is specified, then the content of the BODY must be formatted in accordance with the RFC, but this allows for multiple payloads in BODY a separated by BOUNDARY.

Other zones are allowed in this directory (e.g.: URL, ARGS etc.). Regardless of the zone, header 'Content-Type: multipart/form-data; boundary=...' will be added to all requests.

waf-bypass's People

Contributors

0x566164696d avatar dankegel avatar dkegel-fastly avatar jamesconlan96 avatar nort007 avatar romanov-r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

waf-bypass's Issues

Suggestion: Adding some sort of progress output

At the moment the product doesn't provide any progress, there is no way to know if you are 10% through, 50% through or 99% through

The output given to the user is either nothing (if there are no unexpected outcome) or very noisy (if there is a lot of unexpected outcome)

Since the code knows how many file (json) payloads there are, the product can know where it is ... at one progress it is ... Also it can provide some sort of ETA based on previous progress

If you wish I can develop this and offer a PR for it

UWA/26.json is not a valid HTTP payload

The portion of URLs after # is for client-side processing and does not get sent to the server in HTTP requests. Therefore, there is no way for a WAF to block this request, as it would only receive /do.php instead of the full /do.php#.png

/do.php is not malicious in and of itself and therefore the UWA/26.json payload should not be expected to be blocked by a WAF.

Code exception

Hi,it was used normally a few days ago, but now it reports an error when it is used。
Error message :
error occurred while processing payload from file path\xxx.json: list index out of range�

Hard to identify and replay individual failures?

After using waf-bypass, often one wants to zero in on individual failures and replay them, but it seems hard to do.

waf-bypass could make this easier in many ways.

For instance, it could output curl commands (a la https://github.com/ofw/curlify) or a json equivalent (a la https://curlconverter.com/json) for each failure case to a log file.
Alternately, it could provide a --replay option that accepts an identifier from log file and replays just that one request.

I want to get detail about the payload test

I run the script and get result but have no idea how to find the payload detail. I need look into each payloads resulting to false negative to verify the test result.
Thanks

docker and python3 error

root@ubuntu20:/opt/waf-bypass# docker run nemesida/waf-bypass --host='www.dingjunkj.com'

^C

Target: http://www.dingjunkj.com

Proxy:

Timeout: 30s

Threads: 5

Block code: 403

Exclude dirs:

User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36

An incorrect response was received while processing request from file /opt/waf-bypass/payload/SSI/1.json in URL: 0
An incorrect response was received while processing request from file /opt/waf-bypass/payload/API/3.json in URL: 0
An incorrect response was received while processing request from file /opt/waf-bypass/payload/RCE/5.json in URL: 0
An incorrect response was received while processing request from file /opt/waf-bypass/payload/API/1.json in URL: 0
An incorrect response was received while processing request from file /opt/waf-bypass/payload/SSI/2.json in URL: 0
An error occurred while processing file /opt/waf-bypass/payload/RCE/5.json in BODY: WBHTTPConnectionPool(host='www.dingjunkj.com', port=80): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f5ffce55070>, 'Connection to www.dingjunkj.com timed out. (connect timeout=30)'))
An incorrect response was received while processing request from file /opt/waf-bypass/payload/API/2.json in URL: 0
An incorrect response was received while processing request from file /opt/waf-bypass/payload/SSI/5.json in URL: 0
An incorrect response was received while processing request from file /opt/waf-bypass/payload/RCE/22.json in URL: 0
An incorrect response was received while processing request from file /opt/waf-bypass/payload/NoSQLi/6.json in URL: 0
An error occurred while processing file /opt/waf-bypass/payload/RCE/22.json in COOKIE: WBHTTPConnectionPool(host='www.dingjunkj.com', port=80): Read timed out.
An incorrect response was received while processing request from file /opt/waf-bypass/payload/RCE/15.json in URL: 0
An incorrect response was received while processing request from file /opt/waf-bypass/payload/NoSQLi/2.json in URL: 0
An error occurred while processing file /opt/waf-bypass/payload/RCE/15.json in ARGS: WBHTTPConnectionPool(host='www.dingjunkj.com', port=80): Read timed out.
An incorrect response was received while processing request from file /opt/waf-bypass/payload/RFI/4.json in ARGS: 0
An incorrect response was received while processing request from file /opt/waf-bypass/payload/RFI/4.json in ARGS: 0
An incorrect response was received while processing request from file /opt/waf-bypass/payload/RFI/4.json in ARGS: 0

Keyboard Interrupt

Test run failed

image
Run the script according to the tutorial, and report this error directly. Has any brother Jimei encountered this error? How did you solve it?

Results meaning

Hi guys, I'm curious what is BYPASSED, PASSED etc. means in the results of the program? Can you provide a little description, please? I'm a little confused about how to interpret the results...

For the False Negative test:

  1. Does the PASSED means "Not vulnerable"? Does it mean that payloads in this column didn't triggered WAF Bypass and WAF successfully blocked the malicious request?
  2. Does the BYPASSED means "Vulnerable"? Does it mean that payloads in this column triggered WAF Bypass and WAF failed to block the malicious requests?
  3. FAILED is about Failed requests? (e.g.,cannot connect to server, incorrect response code etc.) I found it in your code, but can you confirm that?

For the False Positive test:

  1. Does the PASSED means "Not vulnerable"? Does it mean that payloads in this column didn't triggered WAF Bypass and WAF successfully blocked the malicious request?
  2. Does the FALSED means that WAF blocks the Legitimate requests and that's why it's "Vulnerable"?

By the way, your program is awesome, thanks <3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.