sensepost / objection

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

[bug] Only name works, but not identifier of app to attach to process #401

Closed sushi2k closed 3 months ago

sushi2k commented 4 years ago

Describe the bug Objection is not attaching to a running process when using the identifier, but it's working when using the name only. When using the identifier objection always spawns the process (App re-opens on device) instead of attaching.

To Reproduce Steps to reproduce the behavior:

  1. Run command objection -d -g com.apple.mobilesafari explore

Similar issues Please link the issues in this repository that is similar to yours.

Expected behavior objection should attach when using the identifier of an app

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:

~ ❯ frida-ps -Ua                                                                                                       
 PID  Name       Identifier
----  ---------  ----------------------
3744  Mail       com.apple.mobilemail
3747  Safari     com.apple.mobilesafari
❯ objection -d -g com.apple.mobilesafari explore                                                                             base
[debug] Agent path is: /usr/local/lib/python3.7/site-packages/objection/agent.js
[debug] Injecting agent...
Using USB device `iPhone`
[debug] Attempting to attach to process: `com.apple.mobilesafari`
[debug] Unable to find process: `com.apple.mobilesafari`, attempting spawn
Traceback (most recent call last):
  File "/usr/local/bin/objection", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/objection/console/cli.py", line 114, in explore
    agent.inject()
  File "/usr/local/lib/python3.7/site-packages/objection/utils/agent.py", line 202, in inject
    session = self.get_session()
  File "/usr/local/lib/python3.7/site-packages/objection/utils/agent.py", line 166, in get_session
    self.spawned_pid = self.device.spawn(state_connection.gadget_name)
  File "/usr/local/lib/python3.7/site-packages/frida/core.py", line 26, in wrapper
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/frida/core.py", line 140, in spawn
    return self._impl.spawn(program, argv, envp, env, cwd, stdio, aux_options)
frida.TimedOutError: unexpectedly timed out while waiting for app to launch
~ ❯ objection -d -g Safari explore                                                                                        21s  base
[debug] Agent path is: /usr/local/lib/python3.7/site-packages/objection/agent.js
[debug] Injecting agent...
Using USB device `iPhone`
[debug] Attempting to attach to process: `Safari`
[debug] Process attached!
Agent injected and responds ok!

     _   _         _   _
 ___| |_|_|___ ___| |_|_|___ ___
| . | . | | -_|  _|  _| | . |   |
|___|___| |___|___|_| |_|___|_|_|
      |___|(object)inject(ion) v1.9.6

     Runtime Mobile Exploration
        by: @leonjza from @sensepost

[tab] for command suggestions
com.apple.mobilesafari on (iPhone: 12.4) [usb] # exit
Exiting...
Asking jobs to stop...
Unloading objection agent...
[debug] Calling unload()

Environment (please complete the following information):

Application Was trying it with Safari and also other apps. Same behaviour.

Additional context Add any other context about the problem here.

az0mb13 commented 3 years ago

It's a problem with Frida. I'm getting the same error on an android using Frida and objection both. Not sure about the fix.

IPMegladon commented 3 months ago

Stale issue, as mentioned this is just due to how Frida works - don't think it is worth adding extra checks to change this functionality.