Code Monkey home page Code Monkey logo

ssrf_proxy's Introduction

SSRF Proxy

Version 0.0.4 MIT License

SSRF Proxy is a multi-threaded HTTP proxy server designed to tunnel client HTTP traffic through HTTP servers vulnerable to Server-Side Request Forgery (SSRF).

Once configured, SSRF Proxy attempts to format client HTTP requests appropriately for the vulnerable server. Likewise, the server's response is parsed and formatted for the client.

By correctly formatting the client request and stripping unwanted junk from the response it is possible to use SSRF Proxy as a HTTP proxy for web browsers, proxychains, and scanning tools such as sqlmap, nmap, dirb and nikto.

SSRF Proxy also assists with leveraging blind SSRF vulnerabilities to perform time-based attacks, such as blind time-based SQL injection with sqlmap.

Version Version 0.0.4
Github https://github.com/bcoles/ssrf_proxy
Wiki https://github.com/bcoles/ssrf_proxy/wiki
Documentation http://www.rubydoc.info/github/bcoles/ssrf_proxy
Author Brendan Coles
Copyright 2015-2017 Brendan Coles
License MIT License

Requirements

Ruby 2.2.2 or newer.

Ruby Gems:

  • celluloid-io
  • webrick
  • logger
  • colorize
  • ipaddress
  • base32
  • htmlentities
  • socksify
  • mimemagic

Installation

$ gem install ssrf_proxy

Usage (command line)

Usage:   ssrf-proxy [options] -u <SSRF URL>
Example: ssrf-proxy -u http://target/?url=xxURLxx
Options:

   -h, --help             Help
       --version          Display version

  Output options:
   -v, --verbose          Verbose output
   -d, --debug            Debugging output
       --no-color         Disable colored output

  Server options:
   -p, --port=PORT        Listen port (Default: 8081)
       --interface=IP     Listen interface (Default: 127.0.0.1)

  SSRF request options:
   -u, --url=URL          Target URL vulnerable to SSRF.
   -f, --file=FILE        Load HTTP request from a file.
       --placeholder=STR  Placeholder indicating SSRF insertion point.
                          (Default: xxURLxx)
       --method=METHOD    HTTP method (GET/HEAD/DELETE/POST/PUT/OPTIONS)
                          (Default: GET)
       --post-data=DATA   HTTP post data
       --cookie=COOKIE    HTTP cookies (separated by ';')
       --user=USER[:PASS] HTTP basic authentication credentials.
       --user-agent=AGENT HTTP user-agent (Default: none)
       --rules=RULES      Rules for parsing client request
                          (separated by ',') (Default: none)
       --no-urlencode     Do not URL encode client request

  SSRF connection options:
       --ssl              Connect using SSL/TLS.
       --proxy=PROXY      Use a proxy to connect to the server.
                          (Supported proxies: http, https, socks)
       --insecure         Skip server SSL certificate validation.
       --timeout=SECONDS  Connection timeout in seconds (Default: 10)

  HTTP response modification:
       --match=REGEX      Regex to match response body content.
                          (Default: \A(.*)\z)
       --strip=HEADERS    Headers to remove from the response.
                          (separated by ',') (Default: none)
       --decode-html      Decode HTML entities in response body.
       --unescape         Unescape special characters in response body.
       --guess-status     Replaces response status code and message
                          headers (determined by common strings in the
                          response body, such as 404 Not Found.)
       --guess-mime       Replaces response content-type header with the
                          appropriate mime type (determined by the file
                          extension of the requested resource.)
       --sniff-mime       Replaces response content-type header with the
                          appropriate mime type (determined by magic bytes
                          in the response body.)
       --timeout-ok       Replaces timeout HTTP status code 504 with 200.
       --detect-headers   Replaces response headers if response headers
                          are identified in the response body.
       --fail-no-content  Return HTTP status 502 if the response body
                          is empty.
       --cors             Adds a 'Access-Control-Allow-Origin: *' header.

  Client request modification:
       --forward-method   Forward client request method.
       --forward-headers  Forward all client request headers.
       --forward-body     Forward client request body.
       --forward-cookies  Forward client request cookies.
       --cookies-to-uri   Add client request cookies to URI query string.
       --body-to-uri      Add client request body to URI query string.
       --auth-to-uri      Use client request basic authentication
                          credentials in request URI.
       --ip-encoding=MODE Encode client request host IP address.
                          (Modes: int, ipv6, oct, hex, dotted_hex)
       --cache-buster     Append a random value to the client request
                          query string.

Usage (ruby)

Load the ssrf_proxy library:

  require 'ssrf_proxy'

Initialize the SSRFProxy::HTTP object:

  # Initialize with a URL containing 'xxURLxx' placeholder
  ssrf = SSRFProxy::HTTP.new(url: 'http://example.local/?url=xxURLxx')

  # Or, provide the placeholder elsewhere in the request
  ssrf = SSRFProxy::HTTP.new(url: 'http://example.local/', method: 'POST', post_data: 'xxURLxx')

  # Alternatively, the object can be initialized
  # with a file containing a raw HTTP request:
  ssrf = SSRFProxy::HTTP.new(file: 'ssrf.txt')

  # Or, initialized with a StringIO object containing a raw HTTP request:
  http = StringIO.new("GET http://example.local/?url=xxURLxx HTTP/1.1\n\n")
  ssrf = SSRFProxy::HTTP.new(file: http)

Refer to the documentation for additional configuration options.

Once initialized, the SSRFProxy::HTTP object can be used to send HTTP requests via the SSRF using the send_uri and send_request methods.

  # GET via SSRF
  ssrf.send_uri('http://127.0.0.1/')

  # POST via SSRF
  ssrf.send_uri('http://127.0.0.1/', method: 'POST', headers: {}, body: '')

  # GET via SSRF (using a raw HTTP request)
  ssrf.send_request("GET http://127.0.0.1/ HTTP/1.1\n\n")

Refer to the documentation for additional request options.

Documentation

Refer to the wiki for more information and example usage: https://github.com/bcoles/ssrf_proxy/wiki

Refer to RubyDoc for code documentation: http://www.rubydoc.info/github/bcoles/ssrf_proxy

ssrf_proxy's People

Contributors

bcoles 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

ssrf_proxy's Issues

RFC: Implement Functionality in Metasploit

So there's a basic http proxy in the PR queue with all the trappings of Rex, and it would be cool to have the SSRF proxy pivoted into a client network natively via Rex Sockets (and also as a type of http tunneling session handler). I havent read over the codebase yet, but figure you might be able to ballpark the effort to porting the SSRF parts over while leaving that proxy code to work as it does.

Feature: Raw request

Make it read from a raw request file similar to sqlmap -r req.txt. This option can substitute the options:

   -u, --url=URL          SSRF URL with 'xxURLxx' placeholder
       --method=METHOD    HTTP method (GET/HEAD/DELETE/POST/PUT)
                          (Default: GET)
       --post-data=DATA   HTTP post data
       --cookie=COOKIE    HTTP cookies (separated by ';')
       --user-agent=AGENT HTTP user-agent (Default: Mozilla/5.0)

giving error

wrong number of arguments (given 1, expected 0)

Inventory notification

Your tool/software has been inventoried on Rawsec's CyberSecurity Inventory.

https://inventory.rawsec.ml/tools.html#SSRF%20Proxy

What is Rawsec's CyberSecurity Inventory?

An inventory of tools and resources about CyberSecurity. This inventory aims to help people to find everything related to CyberSecurity.

  • Open source: Every information is available and up to date. If an information is missing or deprecated, you are invited to (help us).
  • Practical: Content is categorized and table formatted, allowing to search, browse, sort and filter.
  • Fast: Using static and client side technologies resulting in fast browsing.
  • Rich tables: search, sort, browse, filter, clear
  • Fancy informational popups
  • Badges / Shields
  • Static API
  • Twitter bot

More details about features here.

Note: the inventory is a FLOSS (Free, Libre and Open-Source Software) project.

Why?

  • Specialized websites: Some websites are referencing tools but additional information is not available or browsable. Make additional searches take time.
  • Curated lists: Curated lists are not very exhaustive, up to date or browsable and are very topic related.
  • Search engines: Search engines sometimes does find nothing, some tools or resources are too unknown or non-referenced. These is where crowdsourcing is better than robots.

Why should you care about being inventoried?

Mainly because this is giving visibility to your tool, more and more people are using the Rawsec's CyberSecurity Inventory, this helps them find what they need.

Badges

The badge shows to your community that your are inventoried. This also shows you care about your project and want it growing, that your tool is not an abandonware.

Feel free to claim your badge here: http://inventory.rawsec.ml/features.html#badges, it looks like that Rawsec's CyberSecurity Inventory, but there are several styles available.

Want to thank us?

If you want to thank us, you can help make the project better known by tweeting about it! For example: Twitter URL

So what?

That's all, this message is just to notify you if you care.

Add support for HTTPS

The SSRF Proxy library for Ruby supports HTTPS requests, however the server is not a HTTPS proxy and does not support SSL/TLS tunneling.

I have a somewhat-working implementation, however it's lacking a few niceties and is not yet suitable for release. There's also some additional refactoring to be done as part of the changes.

SSL/TLS tunneling will be implemented in the next release: SSRF Proxy version 0.0.5.

In the interim, a temporary workaround exists.

When the --rules ssl option is specified, SSRF Proxy will change the URL scheme to https for all client requests. This effectively allows communications with third-party servers via SSRF using HTTPS. Note that changing the rules requires restarting the proxy.

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.