HTTPSトラフィック検査のためにAndroid APK(またはAAB、XAPK)を準備するPythonスクリプト(以前のbash )。
このスクリプトでは、APKファイルを再構築し、ユーザーの資格認定ストレージを信頼できるようにすることにより、SSL> = 7をバイパスすることができます。処理後、出力APKファイルはHTTPSトラフィック検査の準備ができています。
AABファイルが提供された場合、スクリプトがユニバーサルAPKを作成して処理します。 XAPKファイルが提供された場合、スクリプトがそれを解凍し、すべてのAPKファイルを処理します。
MacOS、Linux、Windowsで動作します。
[テストが必要] Windowsのパフォーマンスは、おそらくMacos / Linuxよりも数回(〜3.5)低くなります( apktool APKをデコードするのに時間がかかります)。
それ:
javaを除く)場合はダウンロードします。bundletool (AABファイルが提供されている場合)を介してAABファイルをAPKファイルにデコードするか、XAPKファイル(XAPKの場合)を解凍します。apktoolを使用してAPKファイルをデコードします。network_security_config.xml信頼できるようにするために、パッチ(またはファイルが欠落している場合に作成されます)。apktoolを介して新しいAPKファイルをエンコードします。uber-apk-signerを介してパッチされたAPKファイルに署名します。オプションで、スクリプトは次のことを許可します。
adbを介して直接デバイスにインストールします。ルートアクセスは必要ありません。
以下のリストからツールをインストールします。
adbへのパスをパス環境変数に追加することを忘れないでください)以下のツールは、スクリプトが欠落している場合に備えてダウンロードされます。
前提条件:
pip3 install -r requirements.txtを実行して、必要なPythonモジュールをインストールするスクリプトは次のように起動できます
python3 /path/to/the/script/apk-rebuild.py
python3 apk-rebuild.py -h (またはpython3 apk-rebuild.py --help )を実行して、使用マニュアルを印刷します。
usage: apk-rebuild.py [-h] [-v] [-i] [--pause] [-p] [-r] [-o OUTPUT] [--no-src] [--only-main-classes] [--ks KS]
[--ks-pass KS_PASS] [--ks-alias KS_ALIAS] [--ks-alias-pass KS_ALIAS_PASS]
file
The script allows to bypass SSL pinning on Android >= 7 via rebuilding the APK file
and making the user credential storage trusted. After processing the output APK file
is ready for HTTPS traffic inspection.
positional arguments:
file path to .apk, .aab or .xapk file for rebuilding
options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-i, --install install the rebuilded .apk file(s) via adb
--pause pause the script execution before the building the output .apk
-p, --preserve preserve the unpacked content of the .apk file(s)
-r, --remove remove the source file (.apk, .aab or .xapk) after the rebuilding
-o OUTPUT, --output OUTPUT
output .apk file name or output directory path (for .xapk source file)
--no-src use --no-src option when decompiling via apktool
--only-main-classes use --only-main-classes option when decompiling via apktool
--ks KS use custom .keystore file for .aab decoding and .apk signing
--ks-pass KS_PASS password of the custom keystore
--ks-alias KS_ALIAS key (alias) in the custom keystore
--ks-alias-pass KS_ALIAS_PASS
password for key (alias) in the custom keystore
APKファイルを再構築するには、スクリプトを引数で使用します。例は以下にあります:
AABファイルにパッチを当て、未払いのAPKファイルコンテンツを削除しないでください
python3 apk-rebuild.py input.aab --preserve
APKファイルにパッチを当て、パッチをかけた後にソースAPKファイルを削除し、Android-DeviceにパッチされたAPKファイルをインストールします
python3 apk-rebuild.py input.apk -r -i
ソースファイルへのパスは、最初の引数として指定する必要があります。
<debug-overrides>要素をthe network_security_config.xmlに追加するように依頼できます(そして、 android:networkSecurityConfigプロパティをAndroidManifest.xmlのapplication要素に追加します): https://developer.android.com/training/articles/security-config#debug-overrides。バグレポート、機能のリクエスト、またはアイデアの議論については、ここで問題を開きます。
多くの感謝: