DEV Community

r_tanaka
r_tanaka

Posted on • Updated on

Debug android 9 with mitmproxy instead of Charles

I used Charles.
I decided to stop to use it because

  • linux version's UI is not good
  • Not open source
  • Not command line

Installation

you can download tar file from https://mitmproxy.org/
unpack it you can see

  • mitmdump
  • mitmproxy
  • mitmweb

You should move it to any location you want.

Boot

mitmproxy

default 8080 port is used.

Set up your android

Connect your android and the mitmproxy

  1. Open wifi setting screen for your android
  2. Select your wifi connection setting
  3. Tap pencil icon(edit button)
  4. Change proxy setting to Manual
  5. input your computer's local IP address as Proxy hostname
  6. input 8080 as Proxy port

Now you can open a browser and access any web site then you can see log on the mitmproxy.

Certification for andorid applications

see also : https://docs.mitmproxy.org/stable/concepts-certificates/

Let you access http://mitm.it via any browser via mitmproxy.
you can install certification for each device.

If you device's android version is less than 9(Pie).
You are lucky you can see all of logs for each apps.

Set up your android application for Pie

see also : https://stackoverflow.com/questions/55154263/do-not-use-proxy-on-android-9-pie

add xml resource file into res/xml/network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- SECURITY RISK -  This app's network data can now be intercepted!!! -->
<network-security-config>
    <base-config>
        <trust-anchors>
            <!-- Trust preinstalled CAs -->
            <certificates src="system" />
            <!-- Additionally trust user added CAs -->
            <certificates src="user" />
        </trust-anchors>
    </base-config>
</network-security-config>

Add an attributes into <applicaiton> tag in AnroidManifest.xml

    <application
...
        android:networkSecurityConfig="@xml/network_security_config"

Done!

addional

  • some android devices has a bug about wifi proxy.
  • not only android 9 sometimes it is needed to add network_security_config.xml

Top comments (0)