Here is a task. There is Android application which uses some REST API over HTTP. This API is in refactoring phase and sometimes fails on random calls. Through application its not possible to understand the real reason. I need to intercept calls and see the details. How to do it with less blood? I am using Mac

Here is the solution. Both devices (Android and Mac) should be connected to the same Wi-Fi spot.

# Configure Android

First go to your Android Wifi connection settings and configure proxy server

proxy

Put IP address of you Mac and port for its default value 8080.

# Run HTTP proxy

Download a man-in-middle http proxy called mitmproxy (https://mitmproxy.org/). There are precompiled binaries for MacOS. Its console application with nice UI for capturing all HTTP requests, looking into details of request/response headers and body. It even can tamper the data.

By default port is 8080, so just run it on console.

mitmproxy-small

Here is a full features list

  • Intercept HTTP requests and responses and modify them on the fly.
  • Save complete HTTP conversations for later replay and analysis.
  • Replay the client-side of an HTTP conversations.
  • Replay HTTP responses of a previously recorded server.
  • Reverse proxy mode to forward traffic to a specified server.
  • Transparent proxy mode on OSX and Linux.
  • Make scripted changes to HTTP traffic using Python.
  • SSL certificates for interception are generated on the fly.
  • And much, much more.
Happy debugging!