Git Product home page Git Product logo

http-request-translator's Introduction

Offensive Web Testing Framework

Build staus License (3-Clause BSD) python_3.6 python_3.7 python_3.8

OWASP OWTF is a project focused on penetration testing efficiency and alignment of security tests to security standards like the OWASP Testing Guide (v3 and v4), the OWASP Top 10, PTES and NIST so that pentesters will have more time to

  • See the big picture and think out of the box
  • More efficiently find, verify and combine vulnerabilities
  • Have time to investigate complex vulnerabilities like business logic/architectural flaws or virtual hosting sessions
  • Perform more tactical/targeted fuzzing on seemingly risky areas
  • Demonstrate true impact despite the short timeframes we are typically given to test.

The tool is highly configurable and anybody can trivially create simple plugins or add new tests in the configuration files without having any development experience.

Note: This tool is however not a silverbullet and will only be as good as the person using it: Understanding and experience will be required to correctly interpret tool output and decide what to investigate further in order to demonstrate impact.

Requirements

OWTF is developed on KaliLinux and macOS but it is made for Kali Linux (or other Debian derivatives)

OWTF supports Python3.

OSX pre-requisites

Dependencies: Install Homebrew (https://brew.sh/) and follow the steps given below:

$ python3 -m venv ~/.virtualenvs/owtf
$ source ~/.virtualenvs/owtf/bin/activate
$ brew install coreutils gnu-sed openssl
# We need to install 'cryptography' first to avoid issues
$ pip install cryptography --global-option=build_ext --global-option="-L/usr/local/opt/openssl/lib" --global-option="-I/usr/local/opt/openssl/include"

Installation

Running as a Docker container:

The recommended way to use OWTF is by building the Docker Image so you will not have to worry about dependencies issues and installing the various pentesting tools.

git clone https://github.com/owtf/owtf
cd owtf
make compose

Installing directly

Create and start the PostgreSQL database server

Using preconfigured Postgresql Docker container (Recommended)

Please make sure you have Docker installed!

Run make startdb to create and start the PostgreSQL server in a Docker container. In the default configuration, it listens on port 5342 exposed from Docker container.

Manual setup (painful and error-prone)

You can also use a script to this for you - find it in scripts/db_setup.sh. You'll need to modify any hardcoded variables if you change the corresponding ones in owtf/settings.py.

Start the postgreSQL server,

  • macOS: brew install postgresql and pg_ctl -D /usr/local/var/postgres start
  • Kali: sudo systemctl enable postgresql; sudo systemctl start postgresql or sudo service postgresql start

Create the owtf_db_user user,

  • macOS: psql postgres -c "CREATE USER $db_user WITH PASSWORD '$db_pass';"
  • Kali: sudo su postgres -c "psql -c \"CREATE USER $db_user WITH PASSWORD '$db_pass'\""

Create the database,

  • macOS: psql postgres -c "CREATE DATABASE $db_name WITH OWNER $db_user ENCODING 'utf-8' TEMPLATE template0;"
  • Kali: sudo su postgres -c "psql -c \"CREATE DATABASE $db_name WITH OWNER $db_user ENCODING 'utf-8' TEMPLATE template0;\""

Installing OWTF

git clone https://github.com/owtf/owtf
cd owtf
python3 setup.py develop
owtf
open `localhost:8009` in the web browser for the OWTF web interface or `owtf --help` for all available commands.

Features

  • Resilience: If one tool crashes OWTF, will move on to the next tool/test, saving the partial output of the tool until it crashed.
  • Flexible: Pause and resume your work.
  • Tests Separation: OWTF separates its traffic to the target into mainly 3 types of plugins:
    • Passive : No traffic goes to the target
    • Semi Passive : Normal traffic to target
    • Active: Direct vulnerability probing
  • Extensive REST API.
  • Has almost complete OWASP Testing Guide(v3, v4), Top 10, NIST, CWE coverage.
  • Web interface: Easily manage large penetration engagements easily.
  • Interactive report:
  • Automated plugin rankings from the tool output, fully configurable by the user.
  • Configurable risk rankings
  • In-line notes editor for each plugin.

License

Checkout LICENSE

Code of Conduct

Checkout Code of Conduct

Links

http-request-translator's People

Contributors

arunk-s avatar cjdupreez avatar depierre avatar dhruvagarwal avatar dufferzafar avatar nlfox avatar rnehra01 avatar sentient07 avatar

Stargazers

 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

http-request-translator's Issues

Interactive mode efficiency improvements

I am not sure where the current approach came from, it would be much more useful to simply paste the whole HTTP request once and have the translator translate directly (i.e. in a single step: one paste x translation).

Instead, at present, the translator requires the user to enter the request in 2 steps:
Step 1) Enter request headers (Ctrl+D to finish/Ctrl+C to quit).
Step 2) Enter request body/parameters (Ctrl+D to finish/Ctrl+C to quit).

Given that HTTP requests have a known structure (2 newlines or \r\n\r\n between headers and body), it should be simple enough for the translator to let users paste the whole request once + figure out the rest from there, saving some time to the user ;)

Templates should be moved away from the source code

The templates that are used to generate the different scripts are in the same files as the python code to generate the scripts.

It makes it hard for one to read the source code and it is also a poor design to keep it that way.

A better design would be to separate the templates from the source code.

Incomplete documentation

The current documentation of the project (that one can find in '/doc/') is far from being complete. It is currently poorly written and does not contain much.

That would be nice to update the documentation to show every person who's interested in the project, what http request translator does for them.

Feature request: JavaScript translation

An extremely cool feature to have here would be conversion to send the request via JavaScript only, so that the tester has a fully working initial draft to play with from the browser development tools:
Something that can easily be copy-pasted and executed via F12 / Console tab on most modern browsers, without installing any tools, this is super-handy for PoCs :)

Incomplete unit testing

The unit tests for the project do not cover all of the code base, nor properly test everything.

It would be nice to continue updating the tests to increase the coverage while still being meaningful.

PEP8 Formatting Errors

The code still has some parts that does not follow PEP8. Mixed spaces and tabs and too long lines of code are some of the primary issues.

re_domain matching bug

ValueError: Invalid URL 'http://www.cmd5.com/'.
is shown.
The regexp in utils.py is wrong.It can't deal the domain with numbers.

Do students need to work on this repo for GSoC?

The OWASP GSoC Idea related to HTTP Request Translator does not link to this repo.

So, I was under the impression that we might have to create a new tool from scratch, and not update this code. Is that the case?

I think that the existing codebase isn't as clean as it can be and have some plans in mind regarding how we can structure our code so that it has an extensible architecture (something that is mentioned in the idea.)

I've recently added a similar feature (exporting requests as Python Code etc.) to mitmproxy. Here are the relevant pulls: mitmproxy/mitmproxy#884 & mitmproxy/mitmproxy#916

If you're interested in a quick prototype of my design, I can get it done this weekend.

Fails with multipart request.

Raw request

b'POST /tslwebapp/example/HelloWorld.action HTTP/1.1\r\nHost: 10.28.194.39:8080\r\nContent-Type: multipart/form-data; boundary=--------429242435\r\nContent-Length: 224\r\n\r\n----------429242435\r\nContent-Disposition: form-data; name="${#_memberAccess["allowStaticMethodAccess"]=true,@java.lang.Runtime@getRuntime().exec(\'touch /foo\')}=1"\r\n\r\n----------429242435--'

Request CURL translated by HRT

#!/usr/bin/env bash
curl --data "----------429242435Content-Disposition: form-data; name=\"${#_memberAccess[\"allowStaticMethodAccess\"]=true,@java.lang.Runtime@getRuntime().exec('touch /foo')}=1\"----------429242435--"  -v --request POST http://172.16.244.210:8000/tslwebapp/example/HelloWorld.action  --header "Host: 172.16.244.210:8000"  --header "Content-Type: multipart/form-data; boundary=--------429242435"  --header "Content-Length: 224"  --include

intercepted at proxy

POST /tslwebapp/example/HelloWorld.action HTTP/1.1
Host: 172.16.244.210:8000
User-Agent: curl/7.54.0
Accept: */*
Content-Type: multipart/form-data; boundary=--------429242435
Content-Length: 82
Connection: close

----------429242435Content-Disposition: form-data; name="0=1"----------429242435--

How it should look like

POST /tslwebapp/example/HelloWorld.action HTTP/1.1
Host: 172.16.244.210:8000
User-Agent: curl/7.54.0
Accept: */*
Content-Type :multipart/form-data; boundary=--------429242435
Content-Length: 224
Content-Type: application/x-www-form-urlencoded
Connection: close

----------429242435
Content-Disposition: form-data; name="${#_memberAccess["allowStaticMethodAccess"]=true,@java.lang.Runtime@getRuntime().exec('touch /foor')}=1"

----------429242435--

Interactive mode exception handling issues / bugs

It looks like when using interactive mode like this:
http_request_translator --interactive

When unexpected Control + D sequences are used, the following happens, would be more professional to handle this in a more graceful way :)

Steps:

  1. Paste a request + convert it
  2. Paste another request, play with Control + D at the wrong time
  3. The following happens:
>>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> 
>>> Traceback (most recent call last):
  File "/usr/local/bin/http_request_translator", line 4, in <module>
    __import__('pkg_resources').run_script('http-request-translator==0.1', 'http_request_translator')
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 735, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1659, in run_script
    exec(script_code, namespace, namespace)
  File "/usr/local/lib/python2.7/dist-packages/http_request_translator-0.1-py2.7.egg/EGG-INFO/scripts/http_request_translator", line 54, in <module>

  File "/usr/local/lib/python2.7/dist-packages/http_request_translator-0.1-py2.7.egg/EGG-INFO/scripts/http_request_translator", line 49, in take_arguments

  File "build/bdist.linux-i686/egg/http_request_translator/translator.py", line 34, in process_arguments
  File "build/bdist.linux-i686/egg/http_request_translator/translator.py", line 100, in take_headers
  File "build/bdist.linux-i686/egg/http_request_translator/translator.py", line 131, in take_body
  File "build/bdist.linux-i686/egg/http_request_translator/translator.py", line 100, in take_headers
  File "build/bdist.linux-i686/egg/http_request_translator/translator.py", line 122, in take_body
  File "build/bdist.linux-i686/egg/http_request_translator/translator.py", line 170, in parse_raw_request
UnboundLocalError: local variable 'host' referenced before assignment

Ruby script fails with IP addresses

It seems that ruby_script fails when dealing with ip addresses. For instance:

$python2 translator.py --output ruby --Request "GET http://127.0.0.1/robots.txt HTTP/1.1
Host: 127.0.0.1"
@@@ DEBUG input check_valid_url 'http://127.0.0.1http://127.0.0.1/robots.txt'
# . . .

This does not happen with python_script for instance:

$python2 translator.py --output python --Request "GET http://127.0.0.1/robots.txt HTTP/1.1   
Host: 127.0.0.1"
@@@ DEBUG input check_valid_url 'http://127.0.0.1'
# . . .

a small error in README.rst

  --interactive, -i     Interactive mode: read raw HTTP request from keyboard,
                        hit enter when ready.Type ':q!' to exit from the
                        interactive mode.

is wrong,actually it should be

  --interactive, -i     Interactive mode: read raw HTTP request from keyboard,
                        hit enter when ready.Press 'Ctrl+D' to finish or 'Ctrl+C'
                        to exit from the interactive mode.

Function get_url fails with ipv6 addresses

The following URL [::1]:80 (IPv6 localhost on port 80, see https://www.ietf.org/rfc/rfc2732.txt) triggers the following exception:

Traceback (most recent call last):
  File "translator.py", line 138, in <module>
    main()
  File "translator.py", line 135, in main
    args = take_arguments()
  File "translator.py", line 44, in take_arguments
    process_arguments(parser.parse_args())
  File "translator.py", line 76, in process_arguments
    plugin_manager(script_list, parsed_tuple)
  File "/http-request-translator/http_request_translator/plugin_manager.py", line 14, in plugin_manager
    searchString)
  File "/http-request-translator/http_request_translator/ruby_script.py", line 22, in generate_script
    url = get_url(header_dict['Host'])
  File "/http-request-translator/http_request_translator/util.py", line 50, in get_url
    if int(port.strip()) in port_protocol.keys():
ValueError: invalid literal for int() with base 10: ''

http method bug

It looks like the request translator will fail when an "unusual" http method like PUT is used, the http method might need to be something like "OMG" or anything else, especially given the target user base of this tool who will all be trying to mess with a web server :)
NOTE: Other translation modes are probably also affected I guess?

Step 1) run in interactive mode

http_request_translator --interactive

Step 2) Paste the request
NOTE: The same request with a "GET" method worked
NOTE 2: When fixing, please try other methods like MEC, TEST or OMG, be creative, all strange methods should be translatable (hint for test case!) :)

PUT https://target.com/path/to/target HTTP/1.1
[some headers here...]

Step 3) Control + D and Control + D results in this error:
btw, please fix the horrible typo too :D

Please Enter a Vaild Request!

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.