Skip to content
πŸ€– A CLI application that prepares Android APK files for HTTPS inspection
TypeScript JavaScript
Branch: master
Clone or download
Latest commit 51ef1a0 Nov 19, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Initial commit Oct 5, 2019
jar Update Apktool Oct 11, 2019
src Add `--wait` option Nov 19, 2019
.editorconfig Initial commit Oct 5, 2019
.gitignore Initial commit Oct 5, 2019
LICENSE Initial commit Oct 5, 2019
README.md Add `--wait` option Nov 19, 2019
package.json v0.6.0 Nov 19, 2019
tsconfig.json Initial commit Oct 5, 2019
yarn.lock Use `@tybys/cross-zip` fork instead of `cross-zip` Nov 17, 2019

README.md

apk-mitm

A CLI application that automatically prepares Android APK files for HTTPS inspection

Inspecting a mobile app's HTTPS traffic using a proxy is probably the easiest way to figure out how it works. However, with the Network Security Configuration introduced in Android 7 and app developers trying to prevent MITM attacks using certificate pinning, getting an app to work with an HTTPS proxy has become quite tedious.

apk-mitm automates the entire process. All you have to do is give it an APK file and apk-mitm will:

You can also use apk-mitm to patch apps using Android App Bundle and rooting your phone is not required.

Usage

If you have an up-to-date version of Node.js (8.2+) and Java (8+), you can run this command to patch an app:

$ npx apk-mitm <path-to-apk>

So, if your APK file is called example.apk, you'd run:

$ npx apk-mitm example.apk

  βœ” Decoding APK file
  βœ” Modifying app manifest
  βœ” Modifying 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 or mitmproxy to look at the app's traffic.

Patching App Bundles

You can also patch apps using Android App Bundle with apk-mitm by providing it with a *.xapk file (for example from APKPure) or a *.apks file (which you can export yourself using SAI).

Making manual changes

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-econding the app, allowing you to make changes to the files in the temporary directory.

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. You'll have to create your own API key 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. Check their issues on GitHub 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:

$ npm install -g apk-mitm

Thanks

License

MIT Β© Niklas Higi

You can’t perform that action at this time.