Skip to content

Commit 5edf99e

Browse files
committed
fix: support bundle identifier when attaching to iOS processes
Adds support for using bundle identifiers (e.g., com.apple.Preferences) in addition to process names when attaching to running processes. Previously, objection only supported process names or PIDs when attaching. Using a bundle identifier would result in a ProcessNotFoundError because get_process() only matches against process names. This change implements a fallback mechanism that: 1. First tries the existing get_process() with the provided name 2. If that fails, enumerates all running applications 3. Matches the bundle identifier to find the correct application 4. Maps the application name to its running process 5. Returns the PID for attachment This makes the attach workflow more user-friendly by accepting the same bundle identifier format used by frida-ps and other tools, eliminating the need to manually look up process names. Fixes #401 Fixes #445 Tested-on: - Frida 17.0.7 - iOS 17.x (jailbroken device) - Multiple iOS applications with bundle identifiers
1 parent e282ea0 commit 5edf99e

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

objection/utils/agent.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,34 @@ def set_target_pid(self):
231231
pass
232232

233233
if self.pid is None:
234-
# last resort, maybe we have a process name
235-
self.pid = self.device.get_process(self.config.name).pid
234+
try:
235+
self.pid = self.device.get_process(self.config.name).pid
236+
except:
237+
processes = self.device.enumerate_processes()
238+
for process in processes:
239+
try:
240+
app = self.device.get_frontmost_application()
241+
if app and app.identifier == self.config.name:
242+
self.pid = app.pid
243+
break
244+
except:
245+
pass
246+
247+
if self.pid is None:
248+
try:
249+
applications = self.device.enumerate_applications()
250+
for app in applications:
251+
if app.identifier == self.config.name:
252+
for process in processes:
253+
if process.name == app.name:
254+
self.pid = process.pid
255+
break
256+
break
257+
except:
258+
pass
259+
260+
if self.pid is None:
261+
raise Exception(f'Unable to find process with name or identifier: {self.config.name}')
236262

237263
debug_print(f'process PID determined as {self.pid}')
238264

0 commit comments

Comments
 (0)