Skip to content

Commit 7bfd21c

Browse files
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 7bfd21c

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

objection/utils/agent.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,40 @@ 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+
# last resort, maybe we have a process name or bundle identifier
235+
# try to find the process by name first, then by matching identifier
236+
try:
237+
self.pid = self.device.get_process(self.config.name).pid
238+
except:
239+
# If get_process fails, enumerate all processes and find by identifier
240+
processes = self.device.enumerate_processes()
241+
for process in processes:
242+
# Check if we need to get the full application info for identifier
243+
try:
244+
app = self.device.get_frontmost_application()
245+
if app and app.identifier == self.config.name:
246+
self.pid = app.pid
247+
break
248+
except:
249+
pass
250+
251+
# If still not found, try enumerate_applications for iOS
252+
if self.pid is None:
253+
try:
254+
applications = self.device.enumerate_applications()
255+
for app in applications:
256+
if app.identifier == self.config.name:
257+
# Found the app by identifier, now find its PID
258+
for process in processes:
259+
if process.name == app.name:
260+
self.pid = process.pid
261+
break
262+
break
263+
except:
264+
pass
265+
266+
if self.pid is None:
267+
raise Exception(f'Unable to find process with name or identifier: {self.config.name}')
236268

237269
debug_print(f'process PID determined as {self.pid}')
238270

0 commit comments

Comments
 (0)