objection icon indicating copy to clipboard operation
objection copied to clipboard

[bug] Can you help me with this error?

Open hoper21 opened this issue 2 years ago • 2 comments

(root💀kali)-[/home/kali/Downloads]
└─# objection patchapk -s Hoper.apk

No architecture specified. Determining it using `adb`...
Detected target device architecture as: arm64-v8a
Using latest Github gadget version: 16.1.3
Patcher will be using Gadget version: 16.1.3
Detected apktool version as: 2.7.0-dirty
Running apktool empty-framework-dir...
I: Removing 1.apk framework file...
Unpacking GreatDay.apk
App already has android.permission.INTERNET
Setting extractNativeLibs to true...
Target class not specified, searching for launchable activity instead...
Reading smali from: /tmp/tmpda0dkegw.apktemp/smali/com/dataon/hoper/MainActivity.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/tmpda0dkegw.apktemp/smali/com/dataon/hoper/MainActivity.smali
Creating library path: /tmp/tmpda0dkegw.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" org.jf.util.ExceptionWithContext: Exception occurred while writing code_item for method Lcom/google/android/gms/internal/gtm/zzut;->zzrz()Lcom/google/android/gms/internal/gtm/zzut;
        at org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:1058)                                 
        at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:354)                                                 
        at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:309)                                                 
        at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:58)                                                  
        at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:37)                                                  
        at brut.androlib.Androlib.buildSourcesSmali(Androlib.java:437)                                                 
        at brut.androlib.Androlib.buildSources(Androlib.java:368)                                                      
        at brut.androlib.Androlib.build(Androlib.java:320)                                                             
        at brut.androlib.Androlib.build(Androlib.java:287)                                                             
        at brut.apktool.Main.cmdBuild(Main.java:263)                                                                   
        at brut.apktool.Main.main(Main.java:82)                                                                        
Caused by: org.jf.util.ExceptionWithContext: Error while writing instruction at code offset 0x6c                       
        at org.jf.dexlib2.writer.DexWriter.writeCodeItem(DexWriter.java:1331)                                          
        at org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:1054)                                 
        ... 10 more                                                                                                    
Caused by: org.jf.util.ExceptionWithContext: Unsigned short value out of range: 65536                                  
        at org.jf.dexlib2.writer.DexDataWriter.writeUshort(DexDataWriter.java:116)                                     
        at org.jf.dexlib2.writer.InstructionWriter.write(InstructionWriter.java:356)                                   
        at org.jf.dexlib2.writer.DexWriter.writeCodeItem(DexWriter.java:1291)                                          
        ... 11 more                                                                                                    
                                                                                                                       
                                                                                                                       
Built new APK with injected loadLibrary and frida-gadget
Performing zipalign
Zipaligning the APK may have failed. Read the following output to determine if zipalign actually had an error: 
                                                                                                                       
/usr/bin/zipalign: symbol lookup error: /usr/bin/zipalign: undefined symbol: _ZN11zip_archive7InflateERKNS_6ReaderEjjPNS_6WriterEPm                                                                                                           
                                                                                                                       
Zipalign completed
Signing new APK.
Signing the new APK may have failed.

Exception in thread "main" java.io.FileNotFoundException: /tmp/tmpda0dkegw.apktemp.aligned.objection.apk (No such file or directory)                                                                                                          
        at java.base/java.io.RandomAccessFile.open0(Native Method)                                                     
        at java.base/java.io.RandomAccessFile.open(RandomAccessFile.java:344)                                          
        at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:259)                                        
        at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:213)                                        
        at com.android.apksig.ApkSigner.sign(ApkSigner.java:190)                                                       
        at com.android.apksigner.ApkSignerTool.sign(ApkSignerTool.java:356)                                            
        at com.android.apksigner.ApkSignerTool.main(ApkSignerTool.java:85)                                             
                                                                                                                       
Signed the new APK
Copying final apk from /tmp/tmpda0dkegw.apktemp.aligned.objection.apk to Hoper.objection.apk in current directory...
Traceback (most recent call last):
  File "/usr/local/bin/objection", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/lib/python3/dist-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/objection/console/cli.py", line 373, in patchapk
    patch_android_apk(**locals())
  File "/usr/local/lib/python3.11/dist-packages/objection/commands/mobile_packages.py", line 230, in patch_android_apk
    shutil.copyfile(patcher.get_patched_apk_path(), os.path.join(os.path.abspath('.'), destination))
  File "/usr/lib/python3.11/shutil.py", line 256, in copyfile
    with open(src, 'rb') as fsrc:
         ^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpda0dkegw.apktemp.aligned.objection.apk'
Cleaning up temp files...

hoper21 avatar Aug 23 '23 04:08 hoper21

This is an issue with apktool, and has nothing to do with objection: https://github.com/iBotPeaches/Apktool/issues/3005

Doesn't seem to have a solution though.

TheDauntless avatar Aug 29 '23 10:08 TheDauntless

This is an issue with apktool, and has nothing to do with objection: iBotPeaches/Apktool#3005

Doesn't seem to have a solution though.

Thankyou for answering me. i will go to link with related issue.

hoper21 avatar Aug 30 '23 05:08 hoper21

As mention this is caused by apktool, it has been fixed in newer versions and can thus be resolved by manually installing an updated version of apktool as per https://apktool.org/docs/install/

IPMegladon avatar Jul 10 '24 16:07 IPMegladon