sensepost / objection

📱 objection - runtime mobile exploration
GNU General Public License v3.0
7.6k stars 859 forks source link

objection patchapk fails #278

Closed w4cky closed 5 years ago

w4cky commented 5 years ago
objection patchapk -s com.twitter.android_394330161_apps.evozi.com.apk                                                                                                                                                                   1.77 L  11:18:35
No architecture specified. Determining it using `adb`...
Detected target device architecture as: arm64-v8a
Using latest Github gadget version: 12.7.5
Patcher will be using Gadget version: 12.7.5
Unpacking com.twitter.android_394330161_apps.evozi.com.apk
App already has android.permission.INTERNET
Target class not specified, searching for launchable activity instead...
Smali not found in smali directory. This might be a multidex APK. Searching...
Found smali at: /tmp/tmp_qoojlvd.apktemp/smali_classes2/com/twitter/android/StartActivity.smali
Reading smali from: /tmp/tmp_qoojlvd.apktemp/smali_classes2/com/twitter/android/StartActivity.smali
Injecting loadLibrary call at line: 6
Attempting to fix the constructors .locals count
Current locals value is 0, updating to 1:
Writing patched smali back to: /tmp/tmp_qoojlvd.apktemp/smali_classes2/com/twitter/android/StartActivity.smali
Creating library path: /tmp/tmp_qoojlvd.apktemp/lib/arm64-v8a
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: 

Exception in thread "main" java.lang.NoSuchMethodError: java.nio.ByteBuffer.clear()Ljava/nio/ByteBuffer;
    at org.jf.dexlib2.writer.DexWriter.writeAnnotationDirectories(DexWriter.java:790)
    at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:340)
    at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:297)
    at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:61)
    at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:36)
    at brut.androlib.Androlib.buildSourcesSmali(Androlib.java:419)
    at brut.androlib.Androlib.buildSources(Androlib.java:350)
    at brut.androlib.Androlib.build(Androlib.java:302)
    at brut.androlib.Androlib.build(Androlib.java:269)
    at brut.apktool.Main.cmdBuild(Main.java:247)
    at brut.apktool.Main.main(Main.java:79)

Built new APK with injected loadLibrary and frida-gadget
Signing new APK.
Signing the new APK may have failed.
jarsigner: unable to open jar file: /tmp/tmp_qoojlvd.apktemp.objection.apk

Signed the new APK
Performing zipalign
Zipaligning the APK may have failed. Read the following output to determine if zipalign actually had an error: 

Unable to open '/tmp/tmp_qoojlvd.apktemp.objection.apk' as zip archive

Zipalign completed
Copying final apk from /tmp/tmp_qoojlvd.apktemp.aligned.objection.apk to com.twitter.android_394330161_apps.evozi.com.objection.apk in current directory...
Traceback (most recent call last):
  File "/usr/local/bin/objection", line 10, in <module>
    sys.exit(cli())
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/objection/console/cli.py", line 344, in patchapk
    patch_android_apk(**locals())
  File "/usr/local/lib/python3.7/dist-packages/objection/commands/mobile_packages.py", line 194, in patch_android_apk
    shutil.copyfile(patcher.get_patched_apk_path(), os.path.join(os.path.abspath('.'), destination))
  File "/usr/lib/python3.7/shutil.py", line 120, in copyfile
    with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp_qoojlvd.apktemp.aligned.objection.apk'
Cleaning up temp files...
Failed to cleanup with error: [Errno 2] No such file or directory: '/tmp/tmp_qoojlvd.apktemp.objection.apk'
leonjza commented 5 years ago

Duplicate of #212