PiratProxies

Automation and testing

Sending mitmproxy traffic through a proxy

mitmproxy lets you watch and change the traffic of an app you are testing. In upstream mode it passes that traffic on through another proxy, so you can inspect it and change its country at once.

The right proxy type for mitmproxy

Any plan with the country you need to test from.

The values to enter in mitmproxy

Every PiratProxies plan comes down to four values: host, port, username and password. Here they are for Residential; your own username and password are on your plan page.

Hostresi.piratproxies.com
HTTP port8080
SOCKS5 port1080
UsernameUSERNAME
Passwordshown on your plan page

There is no separate country or session field: both are part of the username. Your plan page has a generator that writes it, and Targeting and sessions describes each piece.

Setting it up in mitmproxy

  1. Start mitmproxy in upstream mode with the proxy's address.
  2. Give the login with --upstream-auth.
  3. Point your app or device at mitmproxy as usual.

Code: mitmproxy through a proxy

Shell

mitmproxy --mode upstream:http://resi.piratproxies.com:8080 --upstream-auth USERNAME:PASSWORD

Put your own login from the plan page in place of USERNAME and PASSWORD. The example calls an IP-check service, so what it prints is the address your request came from.

Should mitmproxy rotate IPs or keep one?

When mitmproxy plays one visitor across several steps, a sticky session keeps the IP address unchanged from start to finish. When every run stands alone, drop the session and each run begins from a new address.

Here is what a sticky username looks like:

USERNAME-country-us-time-600-session-a1b2c3d4

When mitmproxy will not connect

  • Your app talks to mitmproxy without a login. Only mitmproxy needs the username and password, which also makes it a handy forwarder for apps that cannot send one.
  • Error 407 means the login was refused. Copy the username and password from your plan page once more, and make sure no space crept in and the username was not cut short.
  • An IP in the wrong country nearly always comes from the username, since the country code lives there. Other fixes.

mitmproxy and proxies: questions

Which PiratProxies plan suits mitmproxy best?

Any plan with the country you need to test from.

Words used in this guide: headless browser, rotating proxy, sticky session, proxy authentication.

mitmproxy belongs to its own developers, and PiratProxies has no connection with them; we name it only to say what this guide covers. Follow the rules of the sites you visit and our acceptable use policy.