sensepost / objection

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

[bug] Cannot patch xapk, is this supported? #631

Closed Scylla2020 closed 10 months ago

Scylla2020 commented 10 months ago

Describe the bug Im trying to patch an xapk file using and getting an error tht it cant find AndroidManifest.xml. Is xapk supported and what are the steps to get it working?

To Reproduce Steps to reproduce the behavior:

  1. objection patchapk -2 -s "C:\Users\userx\Desktop\Tests\Pro Punter Alert_1.9.4_Apkpure.xapk"

Similar issues https://github.com/sensepost/objection/issues/431

Expected behavior I expected to patch as normal like the apk's

Evidence / Logs / Screenshots I get this error:

An error may have occurred while running aapt.
ERROR: dump failed because no AndroidManifest.xml found

App does not have android.permission.INTERNET, attempting to patch the AndroidManifest.xml...
Traceback (most recent call last):
  File "C:\Users\userx\AppData\Local\Programs\Python\Python38\Scripts\objection-script.py", line 11, in <module>
    load_entry_point('objection==1.11.0', 'console_scripts', 'objection')()
  File "c:\users\userx\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\userx\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "c:\users\userx\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\userx\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\userx\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "c:\users\userx\appdata\local\programs\python\python38\lib\site-packages\objection\console\cli.py", line 373, in patchapk
    patch_android_apk(**locals())
  File "c:\users\userx\appdata\local\programs\python\python38\lib\site-packages\objection\commands\mobile_packages.py", line 192, in patch_android_apk
    patcher.inject_internet_permission()
  File "c:\users\userx\appdata\local\programs\python\python38\lib\site-packages\objection\utils\patchers\android.py", line 435, in inject_internet_permission
    xml = self._get_android_manifest()
  File "c:\users\userx\appdata\local\programs\python\python38\lib\site-packages\objection\utils\patchers\android.py", line 296, in _get_android_manifest
    return ElementTree.parse(os.path.join(self.apk_temp_directory, 'AndroidManifest.xml'))
  File "c:\users\userx\appdata\local\programs\python\python38\lib\xml\etree\ElementTree.py", line 1202, in parse
    tree.parse(source, parser)
  File "c:\users\userx\appdata\local\programs\python\python38\lib\xml\etree\ElementTree.py", line 584, in parse
    source = open(source, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\userx\\AppData\\Local\\Temp\\tmplzy_1agp.apktemp\\AndroidManifest.xml'
Cleaning up temp files...

Environment (please complete the following information):

leonjza commented 10 months ago

objection does not support xapk files. I think you might have to unzip the xapk to get an apk that might work. This is not something I have tested. Pull requests welcome!

Scylla2020 commented 10 months ago

Ok thanks. Followed the discussion at https://github.com/sensepost/objection/issues/347 and got it working.