A CLI application that automatically prepares Android APK files for HTTPS inspection , modified from shroudedcode
npm install apk-mitm-modifiedapk-mitm automates the entire process. All you have to do is give it an APK file and apk-mitm will:
apk-mitm to patch apps using Android App Bundle and rooting your phone is not required.
shell
$ npx apk-mitm
`
So, if your APK file is called example.apk, you'd run:
`shell
$ npx apk-mitm example.apk
✔ Decoding APK file
✔ Modifying app manifest
✔ Replacing network security config
✔ Disabling certificate pinning
✔ Encoding patched APK file
✔ Signing patched APK file
Done! Patched APK: ./example-patched.apk
`
You can now install the example-patched.apk file on your Android device and use a proxy like [Charles][charles] or [mitmproxy][mitmproxy] to look at the app's traffic.
$3
You can also patch apps using Android App Bundle with apk-mitm by providing it with a .xapk file (for example from [APKPure][apkpure]) or a .apks file (which you can export yourself using [SAI][sai]).
$3
Sometimes you'll need to make manual changes to an app in order to get it to work. In these cases the --wait option is what you need. Enabling it will make apk-mitm wait before re-enconding the app, allowing you to make changes to the files in the temporary directory.
If you want to experiment with different changes to an APK, then using --wait is probably not the most convenient option as it forces you to start from scratch every time you use it. In this case you might want to take a look at [APKLab][apklab]. It's an Android reverse engineering workbench built on top of VS Code that comes with [apk-mitm support][apklab-mitm] and should allow you to iterate much more quickly.
Caveats
- If the app uses Google Maps and the map is broken after patching, then the app's API key is probably [restricted to the developer's certificate][google-api-key-restrictions]. You'll have to [create your own API key][google-maps-android] without restrictions and run apk-mitm with the --wait option to be able to replace the com.google.android.geo.API_KEY value in the app's AndroidManifest.xml file.
- If apk-mitm crashes while decoding or encoding the issue is probably related to [Apktool][apktool]. Check [their issues on GitHub][apktool-issues] to find possible workarounds. If you happen to find an Apktool version that's not affected by the issue, you can instruct apk-mitm to use it by specifying the path of its JAR file through the --apktool option.
Installation
The above example used npx to download and execute apk-mitm without local installation. If you do want to fully install it, you can do that by running:
`shell
$ npm install -g apk-mitm
``