Hello everybody, today I want to talk about Mitm Proxy Recorder for your performance engineering projects. Mobile performance engineering projects require record and playing while dealing with Mobile or Web Apps compared to API testing. JMeter has a very handy Proxy Recorder but there are other tools to help you overcome the challenges. One of these tools is; mitmproxy. You can take a look at its web site for more details. It is https://mitmproxy.org/

Mitmproxy is a lightweight and very capable proxy recorder. It comes with an interactive console filled with many features. In this tutorial, I’ll show you some basic stuff that you might need in a performance testing project.

How to Install Mitmproxy

You can use the below command to install Mitm Proxy Recorder on Linux or Mac.

How to Start Mitmproxy

Open a terminal screen. Enter “mitmproxy” and you’ll be welcomed this empty screen.

Mitm Proxy Recorder started listening to your request by a default port. The default port is 8080. You can change the port with the below command.

Configure your Mobile Device for Proxy

In order to record your mobile device’s http/https traffic, the mobile device must be on the same wireless network. Then, IP address of the machine where you started mitmproxy must be given as a proxy to your mobile device.

Step1: You need to setup your mobile device’s proxy settings

In an iOS device, follow these steps;

  • Settings —> Wi-Fi —> Your connected network
  • Choose Manual from HTTP Proxy section
  • Add server value, Server = Computer’s IP address
  • Add Port value , Port = JMeter’s Port value

In an Android device, follow these steps;

  • Settings —> Wi-Fi —> Your connected network
  • Show advanced options
  • Choose Manual from HTTP Proxy section
  • Add Proxy hostname value, Proxy hostname = Computer’s IP address
  • Add Proxy Port value, Proxy Port = JMeter’s Port value

2- Install Mitmproxy Certificate into Mobile Device

Then you need to install Mitmproxy’s certificate into your mobile device. To do so, open “~/.mitmproxy” folder in terminal. Install *.cer file to your mobile device.

3- Start Recording

Finally, you are ready to go. Do anything you want with your device. Logs of your activities will appear on the screen with a little delay.

How to Use MitmProxy’s Interface

  • Up and down arrow’s on your keyboard let you navigate the requests.
  • You can discover request details by selecting it.

Some Useful Commands

Writing the output to a file

In the recording screen, press “e“, then select “raw“. It will ask you the location. Enter the location and anything related to that request (headers, body data, path, etc..)  will be saved into a file.

Return to the Main Console

Press “:” and write “console.view.pop“. You’ll be directed back to the main console.

Clear Recording

Just click “z” to clear mitmproxy console.

Replay the Request

Just click “r” to replay the request from the proxy.

There are many more commands that you can explore. Just type mitmproxy –commands before starting and browse all the commands.

Happy recording and load testing!
Canberk Akduygu