sensepost / objection

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

Cannot patch apk on windows #399

Closed taulantb94 closed 3 years ago

taulantb94 commented 4 years ago

I am unable to patch the APK file :


C:\Users\ttaul>objection patchapk -s base.apk
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\python\python38\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "c:\python\python38\lib\multiprocessing\spawn.py", line 126, in _main
    self = reduction.pickle.load(from_parent)
  File "c:\python\python38\lib\site-packages\objection\utils\__init__.py", line 57, in <module>
    Process(target=check_version).start()
  File "c:\python\python38\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "c:\python\python38\lib\multiprocessing\context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "c:\python\python38\lib\multiprocessing\context.py", line 326, in _Popen
    return Popen(process_obj)
  File "c:\python\python38\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "c:\python\python38\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
No architecture specified. Determining it using `adb`...    _check_not_importing_main()
  File "c:\python\python38\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main

    raise RuntimeError('''
RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.
Detected target device architecture as: x86
Using latest Github gadget version: 12.11.7
Patcher will be using Gadget version: 12.11.7
Detected apktool version as: 2.4.1
Running apktool empty-framework-dir...
Press any key to continue . . .
Traceback (most recent call last):
  File "c:\python\python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python\python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Python\Python38\Scripts\objection.exe\__main__.py", line 9, in <module>
  File "c:\python\python38\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "c:\python\python38\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "c:\python\python38\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\python\python38\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\python\python38\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "c:\python\python38\lib\site-packages\objection\console\cli.py", line 371, in patchapk
    patch_android_apk(**locals())
  File "c:\python\python38\lib\site-packages\objection\commands\mobile_packages.py", line 187, in patch_android_apk
    patcher.set_apk_source(source=source)
  File "c:\python\python38\lib\site-packages\objection\utils\patchers\android.py", line 270, in set_apk_source
    raise Exception('Source {0} not found.'.format(source))
Exception: Source base.apk not found.
Cleaning up temp files...
Failed to cleanup with error: [WinError 2] The system cannot find the file specified: 'C:\\Users\\ttaul\\AppData\\Local\\Temp\\tmp7ezw6gei.apktemp.objection.apk'

Any thoughts help?

leonjza commented 4 years ago

What's the version of objection here? Please fill in all of the fields in the ticket template.

taulantb94 commented 4 years ago

Hi Sorry for not doing that on the first place, I have updated everything also added the aapt, however, it could not patch the apk file:

SharedScreenshot

Version: objection: 1.9.5.

Sorry if I am missing something else to provide here, let me know if you need anything else. I am using an android emulator. The apktool is to updated also to the newest.

taulantb94 commented 4 years ago

Sorry to torment, could you look at it? @leonjza

CRYBOII commented 4 years ago

image

Same here i can't use it on window10

leonjza commented 4 years ago

Version: objection: 1.9.5.

Alright. Unfortunately Windows support is not really a supported platform, even though it mostly works. To debug and fix this one, I'll need some help. The exception is thrown here when being called from here.

My best guess is the problem is related to how Windows handles paths? Does the source APK have spaces in it?

leonjza commented 4 years ago

@ZIGCER see #386