AndroidFridaManager 1.7.9__py3-none-any.whl → 1.8.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- AndroidFridaManager/FridaManager.py +52 -18
- AndroidFridaManager/about.py +1 -1
- AndroidFridaManager/job.py +1 -1
- AndroidFridaManager/job_manager.py +5 -3
- {AndroidFridaManager-1.7.9.dist-info → androidfridamanager-1.8.3.dist-info}/METADATA +17 -5
- androidfridamanager-1.8.3.dist-info/RECORD +11 -0
- {AndroidFridaManager-1.7.9.dist-info → androidfridamanager-1.8.3.dist-info}/WHEEL +1 -1
- AndroidFridaManager-1.7.9.dist-info/RECORD +0 -11
- {AndroidFridaManager-1.7.9.dist-info → androidfridamanager-1.8.3.dist-info}/entry_points.txt +0 -0
- {AndroidFridaManager-1.7.9.dist-info → androidfridamanager-1.8.3.dist-info/licenses}/LICENSE +0 -0
- {AndroidFridaManager-1.7.9.dist-info → androidfridamanager-1.8.3.dist-info}/top_level.txt +0 -0
|
@@ -15,8 +15,6 @@ from shutil import copyfile
|
|
|
15
15
|
import tempfile
|
|
16
16
|
import argparse
|
|
17
17
|
|
|
18
|
-
warnings.filterwarnings("error")
|
|
19
|
-
|
|
20
18
|
# some parts are taken from ttps://github.com/Mind0xP/Frida-Python-Binding/
|
|
21
19
|
|
|
22
20
|
class FridaManager():
|
|
@@ -44,7 +42,7 @@ class FridaManager():
|
|
|
44
42
|
self.logger = logging.getLogger(__name__)
|
|
45
43
|
|
|
46
44
|
if self.is_remote:
|
|
47
|
-
frida.get_device_manager().add_remote_device(self.
|
|
45
|
+
frida.get_device_manager().add_remote_device(self.device_socket)
|
|
48
46
|
|
|
49
47
|
|
|
50
48
|
def _setup_logging(self):
|
|
@@ -77,6 +75,12 @@ class FridaManager():
|
|
|
77
75
|
|
|
78
76
|
|
|
79
77
|
def run_frida_server(self, frida_server_path="/data/local/tmp/"):
|
|
78
|
+
# Check if frida-server is already running
|
|
79
|
+
if self.is_frida_server_running():
|
|
80
|
+
if self.verbose:
|
|
81
|
+
self.logger.info("[*] frida-server is already running, skipping start")
|
|
82
|
+
return
|
|
83
|
+
|
|
80
84
|
if frida_server_path is self.run_frida_server.__defaults__[0]:
|
|
81
85
|
cmd = self.frida_install_dst + "frida-server &"
|
|
82
86
|
else:
|
|
@@ -87,22 +91,50 @@ class FridaManager():
|
|
|
87
91
|
else:
|
|
88
92
|
command = "adb shell su 0 "+ cmd
|
|
89
93
|
|
|
90
|
-
|
|
94
|
+
try:
|
|
95
|
+
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
96
|
+
# Give it a moment to start and potentially fail
|
|
97
|
+
import time
|
|
98
|
+
time.sleep(1)
|
|
99
|
+
|
|
100
|
+
# Check if process failed immediately
|
|
101
|
+
if process.poll() is not None:
|
|
102
|
+
stdout, stderr = process.communicate()
|
|
103
|
+
if "Address already in use" in stderr.decode():
|
|
104
|
+
print("[*] frida-server is already running on the device")
|
|
105
|
+
return
|
|
106
|
+
else:
|
|
107
|
+
self.logger.error(f"Failed to start frida-server: {stderr.decode()}")
|
|
108
|
+
raise RuntimeError(f"Failed to start frida-server: {stderr.decode()}")
|
|
109
|
+
except Exception as e:
|
|
110
|
+
self.logger.error(f"Error starting frida-server: {e}")
|
|
111
|
+
raise
|
|
91
112
|
|
|
92
113
|
|
|
93
114
|
def is_frida_server_running(self):
|
|
94
115
|
"""
|
|
95
116
|
Checks if on the connected device a frida server is running.
|
|
96
|
-
The test is done by
|
|
117
|
+
The test is done by trying multiple methods to detect the frida-server process.
|
|
97
118
|
|
|
98
119
|
:return: True if a frida-server is running otherwise False.
|
|
99
120
|
:rtype: bool
|
|
100
121
|
"""
|
|
101
|
-
|
|
102
|
-
|
|
122
|
+
# Try pidof first (most reliable if available)
|
|
123
|
+
result = self.run_adb_command_as_root("pidof frida-server")
|
|
124
|
+
if result.stdout.strip():
|
|
103
125
|
return True
|
|
104
|
-
|
|
105
|
-
|
|
126
|
+
|
|
127
|
+
# Fallback to ps grep if pidof doesn't work
|
|
128
|
+
result = self.run_adb_command_as_root("ps | grep frida-server | grep -v grep")
|
|
129
|
+
if result.stdout.strip():
|
|
130
|
+
return True
|
|
131
|
+
|
|
132
|
+
# Try alternative ps command format
|
|
133
|
+
result = self.run_adb_command_as_root("ps -A | grep frida-server | grep -v grep")
|
|
134
|
+
if result.stdout.strip():
|
|
135
|
+
return True
|
|
136
|
+
|
|
137
|
+
return False
|
|
106
138
|
|
|
107
139
|
|
|
108
140
|
def stop_frida_server(self):
|
|
@@ -225,13 +257,15 @@ class FridaManager():
|
|
|
225
257
|
try:
|
|
226
258
|
res = requests.get(url)
|
|
227
259
|
except requests.exceptions.RequestException as e:
|
|
228
|
-
self.logger.error("
|
|
229
|
-
|
|
260
|
+
self.logger.error(f"Error making request to {url}: {e}")
|
|
261
|
+
raise RuntimeError(f"Failed to fetch Frida release information: {e}")
|
|
230
262
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
263
|
+
with warnings.catch_warnings():
|
|
264
|
+
warnings.simplefilter("ignore", SyntaxWarning)
|
|
265
|
+
try:
|
|
266
|
+
frida_server_path = re.findall(r'\/download\/\d+\.\d+\.\d+\/frida\-server\-\d+\.\d+\.\d+\-android\-'+arch+'\.xz',res.text)
|
|
267
|
+
except SyntaxWarning:
|
|
268
|
+
frida_server_path = re.findall(r'/download/\d+\.\d+\.\d+/frida-server-\d+\.\d+\.\d+-android-' + arch + r'\.xz', res.text)
|
|
235
269
|
|
|
236
270
|
final_url = frida_download_prefix + frida_server_path[0]
|
|
237
271
|
|
|
@@ -245,7 +279,7 @@ class FridaManager():
|
|
|
245
279
|
return final_url
|
|
246
280
|
|
|
247
281
|
|
|
248
|
-
def make_frida_server_executable(self, frida_server_path="/data/
|
|
282
|
+
def make_frida_server_executable(self, frida_server_path="/data/local/tmp/"):
|
|
249
283
|
if frida_server_path is self.make_frida_server_executable.__defaults__[0]:
|
|
250
284
|
cmd = self.frida_install_dst + "frida-server"
|
|
251
285
|
else:
|
|
@@ -264,8 +298,8 @@ class FridaManager():
|
|
|
264
298
|
|
|
265
299
|
def run_adb_command_as_root(self,command):
|
|
266
300
|
if self.adb_check_root() == False:
|
|
267
|
-
self.logger.error("
|
|
268
|
-
|
|
301
|
+
self.logger.error("Device is not rooted. Please root it before using FridaAndroidManager and ensure that you are able to run commands with the su-binary.")
|
|
302
|
+
raise RuntimeError("Device not rooted or su binary not accessible")
|
|
269
303
|
|
|
270
304
|
if self.is_magisk_mode:
|
|
271
305
|
output = subprocess.run(['adb', 'shell','su -c '+command], capture_output=True, text=True)
|
AndroidFridaManager/about.py
CHANGED
AndroidFridaManager/job.py
CHANGED
|
@@ -45,7 +45,7 @@ class Job:
|
|
|
45
45
|
self.script.on("message", self.wrap_custom_hooking_handler_with_job_id(self.custom_hooking_handler))
|
|
46
46
|
self.script.load()
|
|
47
47
|
self.state = "running"
|
|
48
|
-
print("[+] hooks
|
|
48
|
+
print("[+] hooks successfully loaded")
|
|
49
49
|
|
|
50
50
|
#if self.is_running_as_thread:
|
|
51
51
|
# Keep the thread alive to handle messages until stop_event is set
|
|
@@ -256,7 +256,7 @@ class JobManager(object):
|
|
|
256
256
|
if job_id in self.jobs:
|
|
257
257
|
return self.jobs[job_id]
|
|
258
258
|
else:
|
|
259
|
-
raise ValueError(f"Job
|
|
259
|
+
raise ValueError(f"Job with ID {job_id} not found.")
|
|
260
260
|
|
|
261
261
|
|
|
262
262
|
def detach_from_app(self):
|
|
@@ -299,13 +299,15 @@ class JobManager(object):
|
|
|
299
299
|
# to handle forks
|
|
300
300
|
def on_child_added(child):
|
|
301
301
|
print(f"Attached to child process with pid {child.pid}")
|
|
302
|
-
self.first_instrumenation_script
|
|
302
|
+
if callable(self.first_instrumenation_script):
|
|
303
|
+
self.first_instrumenation_script(device.attach(child.pid))
|
|
303
304
|
device.resume(child.pid)
|
|
304
305
|
|
|
305
306
|
# if the target process is starting another process
|
|
306
307
|
def on_spawn_added(spawn):
|
|
307
308
|
print(f"Process spawned with pid {spawn.pid}. Name: {spawn.identifier}")
|
|
308
|
-
self.first_instrumenation_script
|
|
309
|
+
if callable(self.first_instrumenation_script):
|
|
310
|
+
self.first_instrumenation_script(device.attach(spawn.pid))
|
|
309
311
|
device.resume(spawn.pid)
|
|
310
312
|
|
|
311
313
|
device.on("child_added", on_child_added)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: AndroidFridaManager
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.8.3
|
|
4
4
|
Summary: A python API in order to install and run the frida-server on an Android device.
|
|
5
5
|
Home-page: https://github.com/fkie-cad/AndroidFridaManager
|
|
6
6
|
Author: Daniel Baier
|
|
@@ -17,11 +17,23 @@ Classifier: Topic :: Software Development :: Debuggers
|
|
|
17
17
|
Requires-Python: >=3.6
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
License-File: LICENSE
|
|
20
|
-
Requires-Dist: frida
|
|
20
|
+
Requires-Dist: frida>=15.0.0
|
|
21
21
|
Requires-Dist: colorlog
|
|
22
22
|
Requires-Dist: requests
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
Dynamic: author
|
|
24
|
+
Dynamic: author-email
|
|
25
|
+
Dynamic: classifier
|
|
26
|
+
Dynamic: description
|
|
27
|
+
Dynamic: description-content-type
|
|
28
|
+
Dynamic: home-page
|
|
29
|
+
Dynamic: keywords
|
|
30
|
+
Dynamic: license
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
Dynamic: requires-dist
|
|
33
|
+
Dynamic: requires-python
|
|
34
|
+
Dynamic: summary
|
|
35
|
+
|
|
36
|
+
 [](https://badge.fury.io/py/AndroidFridaManager) [](https://github.com/fkie-cad/AndroidFridaManager/actions/workflows/publish-to-pypi.yml)
|
|
25
37
|
|
|
26
38
|
# AndroidFridaManager
|
|
27
39
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
AndroidFridaManager/FridaManager.py,sha256=kaOua90QoYCZYjE-PLv2jKNbjGsR049iSdguzpS7IOo,15108
|
|
2
|
+
AndroidFridaManager/__init__.py,sha256=T6AKtrGSLQ9M5bJoWDQcsRTJbSEbksdgrx3AAAdozRI,171
|
|
3
|
+
AndroidFridaManager/about.py,sha256=9PIAKC-I68GSVhurcOpqSExKNmRXqkqGHjeJ0eQtdIg,98
|
|
4
|
+
AndroidFridaManager/job.py,sha256=QTSNjdV7XqawSTV19HQt53aiwoT3UaQeQw2K4AWPxY8,3265
|
|
5
|
+
AndroidFridaManager/job_manager.py,sha256=icdNlfqorEM3XVw4h_83IcoupEFDlkzb29VhEZ6dxrQ,12294
|
|
6
|
+
androidfridamanager-1.8.3.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
7
|
+
androidfridamanager-1.8.3.dist-info/METADATA,sha256=Juumzl4unTLH2Ee6M0ByzYEDGq7kWCES3YijRSt2htM,5141
|
|
8
|
+
androidfridamanager-1.8.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
+
androidfridamanager-1.8.3.dist-info/entry_points.txt,sha256=GmNngu2fDNCxUcquFRegBa7GWknPKG1jsM4lvWeyKnY,64
|
|
10
|
+
androidfridamanager-1.8.3.dist-info/top_level.txt,sha256=oH2lVMSRlghmt-_tVrOEUqvY462P9hd5Ktgp5-1qF3o,20
|
|
11
|
+
androidfridamanager-1.8.3.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
AndroidFridaManager/FridaManager.py,sha256=jxoqFGUwkBTYee7DEYAxo_-qk06DCQa8U9i9OZxAc5M,13381
|
|
2
|
-
AndroidFridaManager/__init__.py,sha256=T6AKtrGSLQ9M5bJoWDQcsRTJbSEbksdgrx3AAAdozRI,171
|
|
3
|
-
AndroidFridaManager/about.py,sha256=_5RG2s3Y8tV5jnC9LpY8sCOQuLsL8NxR2vl90rx4c3s,97
|
|
4
|
-
AndroidFridaManager/job.py,sha256=NWgU7RzheNfEazL8CcmAIoVwylTdEDNbTPqmiAY7ZhY,3264
|
|
5
|
-
AndroidFridaManager/job_manager.py,sha256=f4ByEiAU8I6JUz7eNrdk8hnaD9VUJW3D-dtX79eEu68,12164
|
|
6
|
-
AndroidFridaManager-1.7.9.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
7
|
-
AndroidFridaManager-1.7.9.dist-info/METADATA,sha256=AEvdZVQXypMKZfhsBEmBPVHFS-44BEEJp5BJMqUHWRM,4633
|
|
8
|
-
AndroidFridaManager-1.7.9.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
9
|
-
AndroidFridaManager-1.7.9.dist-info/entry_points.txt,sha256=GmNngu2fDNCxUcquFRegBa7GWknPKG1jsM4lvWeyKnY,64
|
|
10
|
-
AndroidFridaManager-1.7.9.dist-info/top_level.txt,sha256=oH2lVMSRlghmt-_tVrOEUqvY462P9hd5Ktgp5-1qF3o,20
|
|
11
|
-
AndroidFridaManager-1.7.9.dist-info/RECORD,,
|
{AndroidFridaManager-1.7.9.dist-info → androidfridamanager-1.8.3.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{AndroidFridaManager-1.7.9.dist-info → androidfridamanager-1.8.3.dist-info/licenses}/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|