Skip to content

(feat) Add local connection option for iOS simulator.#795

Merged
IPMegladon merged 4 commits into
sensepost:masterfrom
IPMegladon:master
Apr 12, 2026
Merged

(feat) Add local connection option for iOS simulator.#795
IPMegladon merged 4 commits into
sensepost:masterfrom
IPMegladon:master

Conversation

@IPMegladon
Copy link
Copy Markdown
Collaborator

Should fix #794

Copy link
Copy Markdown
Contributor

@cpholguera cpholguera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for me, thanks!

In terms of the commands some of them worked fine and some didn't. I can open a separate ticket for this bug since it seems unrelated to these changes.

These worked:

  • ios keychain dump
  • ios ui dump
  • ios nsuserdefaults get
  • ios bundles list_frameworks
  • ios bundles list_bundles

These failed:

  • ls
  • env

Error:

MASTestApp (run) on (macOS: 26.4) [local] # ls
An unexpected internal exception has occurred. If this looks like a code related error, please file a bug report!
'DeviceState' object has no attribute 'platform'

Python stack trace: Traceback (most recent call last):
  File "/Users/carlos/git/objection/objection/console/repl.py", line 392, in run
    self.run_command(document)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/Users/carlos/git/objection/objection/console/repl.py", line 170, in run_command
    exec_method(arguments)
    ~~~~~~~~~~~^^^^^^^^^^^
  File "/Users/carlos/git/objection/objection/commands/filemanager.py", line 258, in ls
    path = pwd()
  File "/Users/carlos/git/objection/objection/commands/filemanager.py", line 195, in pwd
    if device_state.platform == Ios:
       ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'DeviceState' object has no attribute 'platform'

Comment thread objection/console/cli.py Outdated
Copy link
Copy Markdown
Contributor

@cpholguera cpholguera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it may be related or at least something missing that could go into this PR, please let me know what you think. The fix I found for this was:

For local devices (e.g. iOS Simulator on macOS), the OS id will be 'macos' rather than 'ios'. We can ask the agent which runtime is actually available inside the attached process.

In objection/utils/agent.py, add after 335:

        else:
            rt = self.exports().env_runtime()
            if rt == 'ios':
                device_state.set_platform(Ios)
            elif rt == 'android':
                device_state.set_platform(Android)

With this fix I can run env and ls normally:

$ objection -l -n MASTestApp start

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

     Runtime Mobile Exploration
        by: @leonjza from @sensepost

[tab] for command suggestions
MASTestApp (run) on (macOS: 26.4) [local] # env

Name               Path
-----------------  ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BundlePath         /Users/carlos/Library/Developer/CoreSimulator/Devices/982403FF-3489-4FB7-8B13-4787302F8CB4/data/Containers/Bundle/Application/85B386F4-D689-472B-9268-DE260FB8CA35/MASTestApp.app
CachesDirectory    /Users/carlos/Library/Developer/CoreSimulator/Devices/982403FF-3489-4FB7-8B13-4787302F8CB4/data/Containers/Data/Application/52A81CBD-41F2-4708-8898-AF379324351B/Library/Caches
DocumentDirectory  /Users/carlos/Library/Developer/CoreSimulator/Devices/982403FF-3489-4FB7-8B13-4787302F8CB4/data/Containers/Data/Application/52A81CBD-41F2-4708-8898-AF379324351B/Documents
LibraryDirectory   /Users/carlos/Library/Developer/CoreSimulator/Devices/982403FF-3489-4FB7-8B13-4787302F8CB4/data/Containers/Data/Application/52A81CBD-41F2-4708-8898-AF379324351B/Library


MASTestApp (run) on (macOS: 26.4) [local] # ls /Users/carlos/Library/Developer/CoreSimulator/Devices/982403FF
-3489-4FB7-8B13-4787302F8CB4/data/Containers/Data/Application/52A81CBD-41F2-4708-8898-AF379324351B/Documents
NSFileType  Perms  NSFileProtection  Read  Write  Owner      Group       Size     Creation                   Name
----------  -----  ----------------  ----  -----  ---------  ----------  -------  -------------------------  -------------------
Regular       420  n/a               True  True   n/a (501)  staff (20)  68.0 B   2026-04-11 16:22:01 +0000  apikey_chacha.enc
Regular       420  n/a               True  True   n/a (501)  staff (20)  108.0 B  2026-04-11 16:22:01 +0000  apikey_plain_1e.txt
Regular       420  n/a               True  True   n/a (501)  staff (20)  56.0 B   2026-04-11 16:22:01 +0000  apikey_plain_1d.txt
Regular       420  n/a               True  True   n/a (501)  staff (20)  60.0 B   2026-04-11 16:22:01 +0000  apikey_aes.enc
Regular       420  n/a               True  True   n/a (501)  staff (20)  40.0 B   2026-04-11 16:22:01 +0000  apikey_plain_1c.txt
Regular       384  n/a               True  True   n/a (501)  staff (20)  20.0 B   2026-04-11 16:22:01 +0000  apikey_plain_1b.txt
Regular       420  n/a               True  True   n/a (501)  staff (20)  51.0 B   2026-04-11 16:22:01 +0000  apikey_plain_1a.txt

Readable: True  Writable: True

Co-authored-by: Carlos Holguera <perezholguera@gmail.com>
@IPMegladon
Copy link
Copy Markdown
Collaborator Author

Ah thanks yes that will work for now! I wanted to move to doing the env at runtime a while back but because its displayed in the shell and used for a version compatibility check that wasn't feasible. This fallback I think works ideal for now - until I look at integrating the MacOS support at least. Yeah also agree on the -L, thanks for catching that.

@cpholguera
Copy link
Copy Markdown
Contributor

Awesome, thanks a lot for the quick response @IPMegladon!

@IPMegladon IPMegladon merged commit 228c5e3 into sensepost:master Apr 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for iOS Simulator (local device) via --local flag

2 participants