-
Notifications
You must be signed in to change notification settings - Fork 939
Description
Describe the bug
A patched application starts up normally instead of pausing, indicating that frida-gadget wasn't injected correctly.
To Reproduce
See below for example application.
Steps to reproduce the behavior:
- objection patchapk -s base.apk
- objection signapk split_*.apk
- adb install-multiple *.objection.apk
- Launch the app, it launches normally rather than pausing at startup
Similar issues
didn't see any
Expected behavior
According to https://github.com/sensepost/objection/wiki/Running-Patched-Android-Applications, a patched application should pause at startup.
Evidence / Logs / Screenshots
Any output from objection, such as stack traces or errors that occurred. Be sure to run objection with the --debug flag so that errors from the agent are verbose enough to debug. For example:
% /tmp/venv/bin/objection -d patchapk -s base.apk
No architecture specified. Determining it using `adb`...
Detected target device architecture as: arm64-v8a
Using latest Github gadget version: 17.4.1
Patcher will be using Gadget version: 17.4.1
Detected apktool version as: 2.12.1
Running apktool empty-framework-dir...
Unpacking base.apk
An error may have occurred while extracting the APK.
Invocation: /usr/bin/apktool decode -f -o /tmp/tmpaifwfkfx.apktemp base.apk
W: Unknown data detected at end of type chunk. Skipping: 80 byte(s)
App already has android.permission.INTERNET
Target class not specified, searching for launchable activity instead...
Unable to determine the launchable activity using aapt, trying to manually parse the AndroidManifest for activity aliases...
Smali not found in smali directory. This might be a multidex APK. Searching...
Found smali at: /tmp/tmpaifwfkfx.apktemp/smali_classes2/com/instagram/mainactivity/InstagramMainActivity.smali
Reading smali from: /tmp/tmpaifwfkfx.apktemp/smali_classes2/com/instagram/mainactivity/InstagramMainActivity.smali
Injecting into an existing constructor
Injecting loadLibrary call at line: 165
Attempting to fix the constructors .locals count
Current locals value is 2, updating to 3:
Writing patched smali back to: /tmp/tmpaifwfkfx.apktemp/smali_classes2/com/instagram/mainactivity/InstagramMainActivity.smali
Copying Frida gadget to libs path...
Rebuilding the APK with the frida-gadget loaded...
Rebuilding the APK may have failed. Read the following output to determine if apktool actually had an error:
W: /tmp/tmpaifwfkfx.apktemp/res/values-h640dp/layouts.xml:3: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpaifwfkfx.apktemp/res/values-h640dp/layouts.xml: error: file failed to compile.
W: /tmp/tmpaifwfkfx.apktemp/res/values-land/layouts.xml:3: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpaifwfkfx.apktemp/res/values-land/layouts.xml:4: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpaifwfkfx.apktemp/res/values-land/layouts.xml: error: file failed to compile.
W: /tmp/tmpaifwfkfx.apktemp/res/values-sw600dp/layouts.xml:3: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpaifwfkfx.apktemp/res/values-sw600dp/layouts.xml:4: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpaifwfkfx.apktemp/res/values-sw600dp/layouts.xml: error: file failed to compile.
W: /tmp/tmpaifwfkfx.apktemp/res/values/layouts.xml:3: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpaifwfkfx.apktemp/res/values/layouts.xml:4: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpaifwfkfx.apktemp/res/values/layouts.xml:5: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpaifwfkfx.apktemp/res/values/layouts.xml:6: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpaifwfkfx.apktemp/res/values/layouts.xml:7: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpaifwfkfx.apktemp/res/values/layouts.xml:8: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpaifwfkfx.apktemp/res/values/layouts.xml:9: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpaifwfkfx.apktemp/res/values/layouts.xml:10: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpaifwfkfx.apktemp/res/values/layouts.xml:11: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpaifwfkfx.apktemp/res/values/layouts.xml:12: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpaifwfkfx.apktemp/res/values/layouts.xml:13: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpaifwfkfx.apktemp/res/values/layouts.xml:14: error: invalid value for type 'layout'. Expected a reference.
Exception in thread "main" brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_148049056042784291774775889863617329001.tmp, compile, --dir, /tmp/tmpaifwfkfx.apktemp/res, --legacy, -o, /tmp/tmpaifwfkfx.apktemp/build/resources.zip]
at brut.androlib.AaptInvoker.invoke(SourceFile:105)
at brut.androlib.ApkBuilder.buildResources(SourceFile:328)
at brut.apktool.Main.main(SourceFile:96)
Caused by: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_148049056042784291774775889863617329001.tmp, compile, --dir, /tmp/tmpaifwfkfx.apktemp/res, --legacy, -o, /tmp/tmpaifwfkfx.apktemp/build/resources.zip]
at brut.util.OS.exec(SourceFile:148)
at brut.androlib.AaptInvoker.invoke(SourceFile:101)
... 2 more
Built new APK with injected loadLibrary and frida-gadget
Performing zipalign
Zipalign completed
Signing new APK.
Signed the new APK
Copying final apk from /tmp/tmpaifwfkfx.apktemp.aligned.objection.apk to base.objection.apk in current directory...
Cleaning up temp files...
% objection signapk split_*.apk
Performing zipalign
Zipalign completed
Signing new APK.
Signed the new APK
Copying final apk from /tmp/tmpeffi9su6.apktemp.aligned.objection.apk to split_config.xxhdpi.objection.apk in current directory...
Cleaning up temp files...
Performing zipalign
Zipalign completed
Signing new APK.
Signed the new APK
Copying final apk from /tmp/tmpnz1nww8t.apktemp.aligned.objection.apk to split_executorch.objection.apk in current directory...
Cleaning up temp files...
Performing zipalign
Zipalign completed
Signing new APK.
Signed the new APK
Copying final apk from /tmp/tmpp67ga6qi.apktemp.aligned.objection.apk to split_heliumcore.objection.apk in current directory...
Cleaning up temp files...
Performing zipalign
Zipalign completed
Signing new APK.
Signed the new APK
Copying final apk from /tmp/tmp4bj9io1r.apktemp.aligned.objection.apk to split_heliumiab.objection.apk in current directory...
Cleaning up temp files...
Performing zipalign
Zipalign completed
Signing new APK.
Signed the new APK
Copying final apk from /tmp/tmp3mlrnnyd.apktemp.aligned.objection.apk to split_pytorch.objection.apk in current directory...
Cleaning up temp files...
Performing zipalign
Zipalign completed
Signing new APK.
Signed the new APK
Copying final apk from /tmp/tmpc8e30h__.apktemp.aligned.objection.apk to split_spm.objection.apk in current directory...
Cleaning up temp files...
Environment (please complete the following information):
- Device: Google Pixel 7
- OS: Android 15, LineageOS 22.2-20250919-NIGHTLY-panther
- Frida Version: 17.4.1
- Objection Version: 1.11.0 at e282ea0 with (fix) Construct apktool command lines correctly #768
Application
Recent Instagram split APK: https://drive.google.com/file/d/1nuh8lf19biR5yamCy8s_fEAMnp9jBVU-/view?usp=drive_link
Additional context
If there are troubleshooting steps or other command-line options that should be tried, or ways of validating whether patching is happening successfully, it would be extremely helpful if those were documented on the wiki.