• Home
  • Become a Hacker
    • Get Started
    • Hacker Mindset
    • Roadmap
    • Simple Setup – Hacker 101
    • Types of Hackers
    • Recommended Courses
  • Boot People Offline
  • Courses
    • All Hacking Courses
    • Cyber Security School
  • CTF
    • Beginners to Advanced Guide
    • Create your own CTF box
    • Field and Resources Guide
    • Platforms & Wargames
    • Tools Used for Solving CTF
    • Writeups
  • Dark Web
    • Beginners Guide
    • Darknet Markets
    • Darkweb 101 (Anonymity Guide)
    • Dark Web OSINT Tools
    • Hacking Forums
    • Latest News
    • Onion Links
  • Hacker Gadgets
  • Hacking Books
  • Tools Directory
Menu
  • Home
  • Become a Hacker
    • Get Started
    • Hacker Mindset
    • Roadmap
    • Simple Setup – Hacker 101
    • Types of Hackers
    • Recommended Courses
  • Boot People Offline
  • Courses
    • All Hacking Courses
    • Cyber Security School
  • CTF
    • Beginners to Advanced Guide
    • Create your own CTF box
    • Field and Resources Guide
    • Platforms & Wargames
    • Tools Used for Solving CTF
    • Writeups
  • Dark Web
    • Beginners Guide
    • Darknet Markets
    • Darkweb 101 (Anonymity Guide)
    • Dark Web OSINT Tools
    • Hacking Forums
    • Latest News
    • Onion Links
  • Hacker Gadgets
  • Hacking Books
  • Tools Directory
Search
Close
  • Home
  • 2022
  • May
  • 30
  • Mitmproxy2Swagger – Automagically Reverse-Engineer REST APIs Via Capturing Traffic

Mitmproxy2Swagger – Automagically Reverse-Engineer REST APIs Via Capturing Traffic

May 30, 2022 Comments Off on Mitmproxy2Swagger – Automagically Reverse-Engineer REST APIs Via Capturing Traffic
Mitmproxy2Swagger - Automagically Reverse-Engineer REST APIs Via Capturing Traffic cybersecurity ethical hacking hack android hack app hack wordpress hacker news hacking hacking tools for windows keylogger kit kitploit password brute force penetration testing pentest pentest android pentest linux pentest toolkit pentest tools spy tool kit spyware tools

A tool for automatically converting mitmproxy captures to OpenAPI 3.0 specifications. This means that you can automatically reverse-engineer REST APIs by just running the apps and capturing the traffic.

Installation

First you will need python3 and pip3.

$ pip install mitmproxy2swagger 
# ... or ...
$ pip3 install mitmproxy2swagger

Then clone the repo and run mitmproxy2swagger as per examples below.

Usage

Mitmproxy

To create a specification by inspecting HTTP traffic you will need to:

  1. Capture the traffic by using the mitmproxy tool. I personally recommend using mitmweb, which is a web interface built-in to mitmproxy.

    $ mitmweb
    Web server listening at http://127.0.0.1:8081/
    Proxy server listening at http://*:9999
    ...

    IMPORTANT

    To configure your client to use the proxy exposed by mitm proxy, please consult the mitmproxy documentation for more information.

  2. Save the traffic to a flow file.

    In mitmweb you can do this by using the “File” menu and selecting “Save”:

  3. Run the first pass of mitmproxy2swagger:

    $ mitmproxy2swagger -i <path_to_mitmptoxy_flow> -o <path_to_output_schema> -p <api_prefix>

    Please note that you can use an existing schema, in which case the existing schema will be extended with the new data. You can also run it a few times with different flow captures, the captured data will be safely merged.

    <api_prefix> is the base url of the API you wish to reverse-engineer. You will need to obtain it by observing the requests being made in mitmproxy.

    For example if an app has made requests like these:

    https://api.example.com/v1/login
    https://api.example.com/v1/users/2
    https://api.example.com/v1/users/2/profile

    The likely prefix is https://api.example.com/v1.

  4. Running the first pass should have created a section in the schema file like this:

    x-path-templates:
    # Remove the ignore: prefix to generate an endpoint with its URL
    # Lines that are closer to the top take precedence, the matching is greedy
    - ignore:/addresses
    - ignore:/basket
    - ignore:/basket/add
    - ignore:/basket/checkouts
    - ignore:/basket/coupons/attach/{id}
    - ignore:/basket/coupons/attach/104754

    You should edit the schema file with a text editor and remove the ignore: prefix from the paths you wish to be generated. You can also adjust the parameters appearing in the paths.

  5. Run the second pass of mitmproxy2swagger:

    $ mitmproxy2swagger -i <path_to_mitmptoxy_flow> -o <path_to_output_schema> -p <api_prefix> [--examples]

    Run the command a second time (with the same schema file). It will pick up the edited lines and generate endpoint descriptions.

    Please note that mitmproxy2swagger will not overwrite existing endpoint descriptions, if you want to overwrite them, you can delete them before running the second pass.

    Passing --examples will add example data to requests and responses. Take caution when using this option, as it may add sensitive data (tokens, passwords, personal information etc.) to the schema.

HAR

  1. Capture and export the traffic from the browser DevTools.

    In the browser DevTools, go to the Network tab and click the “Export HAR” button.

  2. Continue the same way you would do with the mitmproxy dump. mitmproxy2swagger will automatically detect the HAR file and process it.

Example output

See the examples. You will find a generated schema there and an html file with the generated documentation (via redoc-cli).

See the generated html file here.

Download Mitmproxy2Swagger

Post navigation

Hakoriginfinder – Tool For Discovering The Origin Host Behind A Reverse Proxy. Useful For Bypassing Cloud WAFs!
iMonitor v1.0.5.2 releases: Endpoint Behavior Analysis System

Related Articles

NVIDIA Addresses High Security Flaws in GPU Display Drivers and vGPU Software

NVIDIA Addresses High Security Flaws in GPU Display Drivers and vGPU Software

- Hack Tools
April 1, 2023
Noseyparker - A Command-Line Program That Finds Secrets And Sensitive Information In Textual Data And Git History

Noseyparker – A Command-Line Program That Finds Secrets And Sensitive Information In Textual Data And Git History

- Hack Tools
April 1, 2023
SOOS DAST: vulnerability scanner against your web apps or APIs

SOOS DAST: vulnerability scanner against your web apps or APIs

- Hack Tools
April 1, 2023
hacker gadgets
hacker phone covers

Recent Posts

NVIDIA Addresses High Security Flaws in GPU Display Drivers and vGPU Software

NVIDIA Addresses High Security Flaws in GPU Display Drivers and vGPU Software

April 1, 2023
Noseyparker - A Command-Line Program That Finds Secrets And Sensitive Information In Textual Data And Git History

Noseyparker – A Command-Line Program That Finds Secrets And Sensitive Information In Textual Data And Git History

April 1, 2023
SOOS DAST: vulnerability scanner against your web apps or APIs

SOOS DAST: vulnerability scanner against your web apps or APIs

April 1, 2023
CVE-2023-29059: Unraveling the Trojanized 3CX Desktop App Supply Chain Attack

CVE-2023-29059: Unraveling the Trojanized 3CX Desktop App Supply Chain Attack

April 1, 2023
CVE-2023-25076: Critical Buffer Overflow Vulnerability in SNIProxy

CVE-2023-25076: Critical Buffer Overflow Vulnerability in SNIProxy

March 31, 2023
Fingerprintx - Standalone Utility For Service Discovery On Open Ports!

Fingerprintx – Standalone Utility For Service Discovery On Open Ports!

March 31, 2023

Social Media Hacking

SocialPath – Track users across Social Media Platforms

SocialPath – Track users across Social Media Platforms

- Social Media Hacking
October 16, 2019October 16, 2019

SocialPath is a django application for gathering social media intelligence on specific username. It checks for Twitter, Instagram, Facebook, Reddit...

SocialScan – Check Email Address and Username Availability on Online Platforms

SocialScan – Check Email Address and Username Availability on Online Platforms

June 17, 2019
Shellphish – Phishing Tool For 18 Social Media Apps

Shellphish – Phishing Tool For 18 Social Media Apps

June 10, 2019July 27, 2019
WhatsApp Hacking using QRLJacking

WhatsApp Hacking using QRLJacking

May 2, 2019May 19, 2019
How to Hack any Facebook Account with Z-Shadow

How to Hack any Facebook Account with Z-Shadow

April 26, 2019June 29, 2020
hacker buffs

About Us

Haxf4rall is a collective, a good starting point and provides a variety of quality material for cyber security professionals.

Join Our Community!

Please wait...
Get the latest News and Hacking Tools delivered to your inbox.
Don't Worry ! You will not be spammed

Active Members

Submit a Tool

Hackers Handbook 2018


Grab your copy here

ABOUT US

Haxf4rall is a collective, a good starting point and provides a variety of quality material for cyber security professionals.

Our primary focus revolves around the latest tools released in the Infosec community and provide a platform for developers to showcase their skillset and current projects.

COMPANY
  • Contact Us
  • Disclaimer
  • Hacker Gadgets
  • LANC Remastered
  • PCPS IP Puller
  • Privacy Policy
  • Sitemap
  • Submit your Tool
Menu
  • Contact Us
  • Disclaimer
  • Hacker Gadgets
  • LANC Remastered
  • PCPS IP Puller
  • Privacy Policy
  • Sitemap
  • Submit your Tool
Live Chat
RESOURCES
  • Attack Process
  • Become a Hacker
  • Career Pathways
  • Dark Web
  • Hacking Books
  • Practice Your Skills
  • Recommended Courses
  • Simple Setup – Hacker 101
Menu
  • Attack Process
  • Become a Hacker
  • Career Pathways
  • Dark Web
  • Hacking Books
  • Practice Your Skills
  • Recommended Courses
  • Simple Setup – Hacker 101
Get Started
TOOLBOX
  • Anonymity
  • Bruteforce
  • DoS – Denial of Service
  • Information Gathering
  • Phishing
  • SQL Injection
  • Vulnerability Scanners
  • Wifi Hacking
Menu
  • Anonymity
  • Bruteforce
  • DoS – Denial of Service
  • Information Gathering
  • Phishing
  • SQL Injection
  • Vulnerability Scanners
  • Wifi Hacking
Tools Directory

2014 – 2020 | Haxf4rall.com               Stay Connected:

Facebook Twitter Google-plus Wordpress
Please wait...

Join Our Community

Subscribe now and get your free HACKERS HANDBOOK

Don't Worry ! You will not be spammed
SIGN UP FOR NEWSLETTER NOW