Skip to content

Commit

Permalink
Add support for frida-gadget in filesystem tools
Browse files Browse the repository at this point in the history
Which means the system session is not available.

Co-authored-by: Håvard Sørbø <[email protected]>
  • Loading branch information
oleavr and hsorbo committed Jul 4, 2024
1 parent 566aa69 commit cb8aaa6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions frida_tools/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,15 @@ def _try_start(self) -> None:
self._start()
self._started = True

def _pick_worker_pid(self) -> int:
try:
frontmost = self._device.get_frontmost_application()
if frontmost is not None and frontmost.identifier == "re.frida.Gadget":
return frontmost.pid
except:
pass
return 0

def _attach(self, pid: int) -> None:
self._target_pid = pid

Expand Down
2 changes: 1 addition & 1 deletion frida_tools/ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _needs_target(self) -> bool:

def _start(self) -> None:
try:
self._attach(0)
self._attach(self._pick_worker_pid())

data_dir = os.path.dirname(__file__)
with codecs.open(os.path.join(data_dir, "fs_agent.js"), "r", "utf-8") as f:
Expand Down
2 changes: 1 addition & 1 deletion frida_tools/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _needs_target(self) -> bool:

def _start(self) -> None:
try:
self._attach(0)
self._attach(self._pick_worker_pid())

data_dir = os.path.dirname(__file__)
with codecs.open(os.path.join(data_dir, "fs_agent.js"), "r", "utf-8") as f:
Expand Down
2 changes: 1 addition & 1 deletion frida_tools/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def _needs_target(self) -> bool:

def _start(self) -> None:
try:
self._attach(0)
self._attach(self._pick_worker_pid())

data_dir = os.path.dirname(__file__)
with codecs.open(os.path.join(data_dir, "fs_agent.js"), "r", "utf-8") as f:
Expand Down
2 changes: 1 addition & 1 deletion frida_tools/rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _needs_target(self) -> bool:

def _start(self) -> None:
try:
self._attach(0)
self._attach(self._pick_worker_pid())

data_dir = os.path.dirname(__file__)
with codecs.open(os.path.join(data_dir, "fs_agent.js"), "r", "utf-8") as f:
Expand Down

0 comments on commit cb8aaa6

Please sign in to comment.