sensepost / objection

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

[bug] exception when loading script #553

Closed g2asell2019 closed 2 months ago

g2asell2019 commented 2 years ago

Describe the bug when I run objection with --startup-script, objection just exit the REPL due to resume command

To Reproduce Steps to reproduce the behavior:

  1. objection --gadget "" explore --startup-script "main_v3.1.4_clean.js"
  2. REPL crash

Expected behavior Expect REPL not crash

Evidence / Logs / Screenshots Any output from objection, such as stack traces or errors that occurred. Be sure to run objection with the --debug flag so that errors from the agent are verbose enough to debug. For example:


F:\<redacted>objection --debug --gadget "<redacted>" explore --startup-script "main_v3.1.4_clean.js"
[debug] Agent path is: c:\users\admin\appdata\local\programs\python\python37\lib\site-packages\objection\agent.js
[debug] Injecting agent...
Using USB device `Minh’s iPad`
[debug] Attempting to attach to process: `<redacted>`
[debug] Unable to find process: `<redacted>`, attempting spawn
[debug] PID `20078` spawned, attaching...
[debug] Resuming PID `20078`
Agent injected and responds ok!
Importing and running startup script at: <_io.TextIOWrapper name='main_v3.1.4_clean.js' mode='r' encoding='cp1252'>
[*] Patching...
[*] Patching...
[*] nop call suspend
[*] Patching...
[*] Patching...
[*] Patching...
[*] Patching...
[*] Patching...
[debug] Resuming PID `20078`
Traceback (most recent call last):
  File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\Scripts\objection-script.py", line 33, in <module>
    sys.exit(load_entry_point('objection==1.11.0', 'console_scripts', 'objection')())
  File "c:\users\admin\appdata\local\programs\python\python37\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\admin\appdata\local\programs\python\python37\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "c:\users\admin\appdata\local\programs\python\python37\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\admin\appdata\local\programs\python\python37\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\admin\appdata\local\programs\python\python37\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "c:\users\admin\appdata\local\programs\python\python37\lib\site-packages\objection\console\cli.py", line 149, in explore
    response = agent.single(startup_script.read())
  File "c:\users\admin\appdata\local\programs\python\python37\lib\site-packages\objection\utils\agent.py", line 249, in single
    self.device.resume(self.spawned_pid)
  File "c:\users\admin\appdata\local\programs\python\python37\lib\site-packages\frida\core.py", line 26, in wrapper
    return f(*args, **kwargs)
  File "c:\users\admin\appdata\local\programs\python\python37\lib\site-packages\frida\core.py", line 148, in resume
    self._impl.resume(self._pid_of(target))
frida.InvalidOperationError: process is not suspended
Asking jobs to stop...
Unloading objection agent...
[debug] Calling unload()

Environment (please complete the following information):

Application I tested with my private app, probably you reproduce with others app

Additional context I think it's probably resume command cause the crash of REPL When objection is load without startup-script it's just fine, when load with startup-script it's just automatically add --no-pause but in objection it sends resume action then REPL crash

IPMegladon commented 2 months ago

This logic has been refactored at some point an may have resolved this issue. Closing issue as stale for now, feel free to reopen.