This commit is contained in:
Jean-Marie 'Histausse' Mineau 2024-02-15 23:13:26 +01:00
parent 3a7208f1b5
commit cd6c638080
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
3 changed files with 48 additions and 115 deletions

59
test.py
View file

@ -59,42 +59,43 @@ print(f"[+] New code of {method_id} ")
for i in code.insns:
print(f" {i}")
# # Strip class for debugging
# classes = list(
# filter(
# lambda x: x
# not in [
# IdType("Lcom/example/testapplication/ui/home/HomeViewModel;"),
# IdType("Landroidx/navigation/NavDeepLink$Builder;"),
# IdType("Landroidx/constraintlayout/core/widgets/ConstraintWidget$1;"),
# IdType("Landroidx/appcompat/app/ActionBar;"),
# IdType("Landroidx/constraintlayout/core/state/WidgetFrame;"),
# ],
# apk.classes.keys(),
# )
# )
# # for cls in classes:
# # apk.remove_class(cls)
# Strip class for debugging
classes = list(
filter(
lambda x: x
not in [
# IdType("Lcom/example/testapplication/ui/home/HomeViewModel;"),
# IdType("Landroidx/navigation/NavDeepLink$Builder;"),
# IdType("Landroidx/constraintlayout/core/widgets/ConstraintWidget$1;"),
# IdType("Landroidx/appcompat/app/ActionBar;"),
# IdType("Landroidx/constraintlayout/core/state/WidgetFrame;"),
IdType("Landroidx/appcompat/app/AppCompatViewInflater;"),
],
apk.classes.keys(),
)
)
for cls in classes:
apk.remove_class(cls)
print("[+] Recompile")
dex_raw = apk.gen_raw_dex()
# new_apk = Apk()
# for dex in dex_raw:
# new_apk.add_dex_file(dex)
new_apk = Apk()
for dex in dex_raw:
new_apk.add_dex_file(dex)
print("[+] Repackage")
utils.replace_dex(
APK_NAME,
APK_NAME.parent / (APK_NAME.name.removesuffix(".apk") + "-instrumented.apk"),
dex_raw,
Path().parent / "my-release-key.jks",
zipalign=Path.home() / "Android" / "Sdk" / "build-tools" / "34.0.0" / "zipalign",
apksigner=Path.home() / "Android" / "Sdk" / "build-tools" / "34.0.0" / "apksigner",
)
# print("[+] Repackage")
#
# utils.replace_dex(
# APK_NAME,
# APK_NAME.parent / (APK_NAME.name.removesuffix(".apk") + "-instrumented.apk"),
# dex_raw,
# Path().parent / "my-release-key.jks",
# zipalign=Path.home() / "Android" / "Sdk" / "build-tools" / "34.0.0" / "zipalign",
# apksigner=Path.home() / "Android" / "Sdk" / "build-tools" / "34.0.0" / "apksigner",
# )
last_id = None