sensepost / objection

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

[bug] Unable to rebuild the app #389

Closed rajeshnadiminti closed 4 years ago

rajeshnadiminti commented 4 years ago

When I running "objection patchapk -s internal_release.apk -a x86 -2" I am getting the following error.

Using latest Github gadget version: 12.10.4
Patcher will be using Gadget version: 12.10.4
Detected apktool version as: 2.4.1
Running apktool empty-framework-dir...
Unpacking 07_08_Full.apk
App already has android.permission.INTERNET
Target class not specified, searching for launchable activity instead...
Reading smali from: /tmp/tmpntltpp5e.apktemp/smali/com/voatz/vma/feature/launch/LaunchActivity.smali
Injecting into an existing constructor
Injecting loadLibrary call at line: 44
Attempting to fix the constructors .locals count
Current locals value is 0, updating to 1:
Writing patched smali back to: /tmp/tmpntltpp5e.apktemp/smali/com/voatz/vma/feature/launch/LaunchActivity.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/tmpntltpp5e.apktemp/res/values-hdpi/mipmaps.xml:3: error: invalid value for type 'mipmap'. Expected a reference.
W: /tmp/tmpntltpp5e.apktemp/res/values-hdpi/mipmaps.xml:4: error: invalid value for type 'mipmap'. Expected a reference.
W: /tmp/tmpntltpp5e.apktemp/res/values-hdpi/mipmaps.xml: error: file failed to compile.
W: /tmp/tmpntltpp5e.apktemp/res/values-ldrtl/layouts.xml:3: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpntltpp5e.apktemp/res/values-ldrtl/layouts.xml:4: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpntltpp5e.apktemp/res/values-ldrtl/layouts.xml: error: file failed to compile.
W: /tmp/tmpntltpp5e.apktemp/res/values-mdpi/mipmaps.xml:3: error: invalid value for type 'mipmap'. Expected a reference.
W: /tmp/tmpntltpp5e.apktemp/res/values-mdpi/mipmaps.xml:4: error: invalid value for type 'mipmap'. Expected a reference.
W: /tmp/tmpntltpp5e.apktemp/res/values-mdpi/mipmaps.xml: error: file failed to compile.
W: /tmp/tmpntltpp5e.apktemp/res/values-sw600dp/layouts.xml:3: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpntltpp5e.apktemp/res/values-sw600dp/layouts.xml:4: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpntltpp5e.apktemp/res/values-sw600dp/layouts.xml: error: file failed to compile.
W: /tmp/tmpntltpp5e.apktemp/res/values-v28/layouts.xml:3: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpntltpp5e.apktemp/res/values-v28/layouts.xml: error: file failed to compile.
W: /tmp/tmpntltpp5e.apktemp/res/values-watch/layouts.xml:3: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpntltpp5e.apktemp/res/values-watch/layouts.xml:4: error: invalid value for type 'layout'. Expected a reference.
W: /tmp/tmpntltpp5e.apktemp/res/values-watch/layouts.xml: error: file failed to compile.
W: /tmp/tmpntltpp5e.apktemp/res/values-xhdpi/mipmaps.xml:3: error: invalid value for type 'mipmap'. Expected a reference.
W: /tmp/tmpntltpp5e.apktemp/res/values-xhdpi/mipmaps.xml:4: error: invalid value for type 'mipmap'. Expected a reference.
W: /tmp/tmpntltpp5e.apktemp/res/values-xhdpi/mipmaps.xml: error: file failed to compile.
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/brut_util_Jar_3870503532437956374.tmp, compile, --dir, /tmp/tmpntltpp5e.apktemp/res, --legacy, -o, /tmp/tmpntltpp5e.apktemp/build/resources.zip]

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/tmpntltpp5e.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/tmpntltpp5e.apktemp.objection.apk' as zip archive

Zipalign completed
Copying final apk from /tmp/tmpntltpp5e.apktemp.aligned.objection.apk to 07_08_Full.objection.apk in current directory...
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/bin/objection", line 8, in <module>
    sys.exit(cli())
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/objection/console/cli.py", line 371, in patchapk
    patch_android_apk(**locals())
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/objection/commands/mobile_packages.py", line 227, in patch_android_apk
    shutil.copyfile(patcher.get_patched_apk_path(), os.path.join(os.path.abspath('.'), destination))
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/shutil.py", line 120, in copyfile
    with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpntltpp5e.apktemp.aligned.objection.apk'
Cleaning up temp files...
Failed to cleanup with error: [Errno 2] No such file or directory: '/tmp/tmpntltpp5e.apktemp.objection.apk'
leonjza commented 4 years ago

For this one you will need to get apktool to unpack & pack the APK outside of objection. Once you know what fixes you need to make manually you can add the --pause flag which will let you edit the APK before objection tries to pack it again.

rajeshnadiminti commented 4 years ago

Thanks. Will try to do that

leonjza commented 4 years ago

I added a wiki page with more tips here https://github.com/sensepost/objection/wiki/Android-APK-Patching.