AndroidFridaManager 1.9.1__py3-none-any.whl → 1.9.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 +77 -11
- AndroidFridaManager/about.py +1 -1
- {androidfridamanager-1.9.1.dist-info → androidfridamanager-1.9.3.dist-info}/METADATA +2 -2
- androidfridamanager-1.9.3.dist-info/RECORD +11 -0
- androidfridamanager-1.9.1.dist-info/RECORD +0 -11
- {androidfridamanager-1.9.1.dist-info → androidfridamanager-1.9.3.dist-info}/WHEEL +0 -0
- {androidfridamanager-1.9.1.dist-info → androidfridamanager-1.9.3.dist-info}/entry_points.txt +0 -0
- {androidfridamanager-1.9.1.dist-info → androidfridamanager-1.9.3.dist-info}/licenses/LICENSE +0 -0
- {androidfridamanager-1.9.1.dist-info → androidfridamanager-1.9.3.dist-info}/top_level.txt +0 -0
|
@@ -41,6 +41,7 @@ class FridaManager():
|
|
|
41
41
|
self.device_socket = socket
|
|
42
42
|
self.verbose = verbose
|
|
43
43
|
self.is_magisk_mode = False
|
|
44
|
+
self.is_adb_root_mode = False # LineageOS adb root mode (adbd runs as root)
|
|
44
45
|
self.frida_install_dst = frida_install_dst
|
|
45
46
|
self._setup_logging()
|
|
46
47
|
self.logger = logging.getLogger(__name__)
|
|
@@ -73,7 +74,10 @@ class FridaManager():
|
|
|
73
74
|
"""Set the target device serial."""
|
|
74
75
|
self._validate_device(serial)
|
|
75
76
|
self._device_serial = serial
|
|
76
|
-
|
|
77
|
+
# Reset cached root status and mode flags for new device
|
|
78
|
+
self._is_rooted = None
|
|
79
|
+
self.is_magisk_mode = False
|
|
80
|
+
self.is_adb_root_mode = False
|
|
77
81
|
|
|
78
82
|
def _setup_logging(self):
|
|
79
83
|
"""
|
|
@@ -270,7 +274,9 @@ class FridaManager():
|
|
|
270
274
|
:return: Complete command list including device targeting
|
|
271
275
|
"""
|
|
272
276
|
cmd = ['adb']
|
|
273
|
-
if
|
|
277
|
+
# Always include device serial if set - important when user explicitly
|
|
278
|
+
# specifies a device or when multiple devices are connected
|
|
279
|
+
if self._device_serial:
|
|
274
280
|
cmd.extend(['-s', self._device_serial])
|
|
275
281
|
cmd.extend(args)
|
|
276
282
|
return cmd
|
|
@@ -308,15 +314,26 @@ class FridaManager():
|
|
|
308
314
|
self.logger.info("[*] frida-server is already running, skipping start")
|
|
309
315
|
return True
|
|
310
316
|
|
|
317
|
+
# Ensure root access is available
|
|
318
|
+
if not self.is_device_rooted():
|
|
319
|
+
self.logger.error("Cannot start frida-server: device is not rooted")
|
|
320
|
+
return False
|
|
321
|
+
|
|
311
322
|
if frida_server_path is self.run_frida_server.__defaults__[0]:
|
|
312
|
-
|
|
323
|
+
frida_bin = self.frida_install_dst + "frida-server"
|
|
313
324
|
else:
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
325
|
+
frida_bin = frida_server_path + "frida-server"
|
|
326
|
+
|
|
327
|
+
# Build the command based on root mode
|
|
328
|
+
if self.is_adb_root_mode:
|
|
329
|
+
# ADB root mode (LineageOS): run directly, adbd is already root
|
|
330
|
+
shell_cmd = f"{frida_bin} &"
|
|
331
|
+
elif self.is_magisk_mode:
|
|
332
|
+
# Magisk mode
|
|
333
|
+
shell_cmd = f"""su -c 'sh -c "{frida_bin} &"'"""
|
|
318
334
|
else:
|
|
319
|
-
|
|
335
|
+
# Traditional su mode
|
|
336
|
+
shell_cmd = f"""su 0 sh -c "{frida_bin} &" """
|
|
320
337
|
|
|
321
338
|
try:
|
|
322
339
|
adb_cmd = self._build_adb_command(['shell', shell_cmd])
|
|
@@ -426,13 +443,24 @@ class FridaManager():
|
|
|
426
443
|
:type dst_dir: string
|
|
427
444
|
:param version: The version. By default the latest version will be used.
|
|
428
445
|
:type version: string
|
|
446
|
+
:raises RuntimeError: If device is not rooted
|
|
429
447
|
|
|
430
448
|
"""
|
|
449
|
+
# Check root access BEFORE downloading - fail fast to save time
|
|
450
|
+
if not self.is_device_rooted():
|
|
451
|
+
self.logger.error(
|
|
452
|
+
"Device is not rooted. Frida server installation requires root access. "
|
|
453
|
+
"Please root the device or use an emulator."
|
|
454
|
+
)
|
|
455
|
+
raise RuntimeError("Cannot install frida-server: device not rooted")
|
|
456
|
+
|
|
431
457
|
if dst_dir is self.install_frida_server.__defaults__[0]:
|
|
432
458
|
frida_dir = self.frida_install_dst
|
|
433
459
|
else:
|
|
434
460
|
frida_dir = dst_dir
|
|
435
461
|
|
|
462
|
+
self.logger.info("Installing frida-server now...")
|
|
463
|
+
|
|
436
464
|
with tempfile.TemporaryDirectory() as dir:
|
|
437
465
|
if self.verbose:
|
|
438
466
|
self.logger.info(f"[*] downloading frida-server to {dir}")
|
|
@@ -574,17 +602,27 @@ class FridaManager():
|
|
|
574
602
|
"""
|
|
575
603
|
Run an ADB command as root on the target device.
|
|
576
604
|
|
|
605
|
+
Supports three root modes:
|
|
606
|
+
1. ADB root mode (LineageOS): Commands run directly (adbd is root)
|
|
607
|
+
2. Magisk mode: Uses 'su -c command'
|
|
608
|
+
3. Traditional su: Uses 'su 0 command'
|
|
609
|
+
|
|
577
610
|
:param command: Command to run as root
|
|
578
611
|
:return: subprocess.CompletedProcess with stdout/stderr
|
|
579
612
|
:raises RuntimeError: If device is not rooted
|
|
580
613
|
"""
|
|
581
614
|
if not self.is_device_rooted():
|
|
582
|
-
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.")
|
|
615
|
+
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 or enable ADB root mode.")
|
|
583
616
|
raise RuntimeError("Device not rooted or su binary not accessible")
|
|
584
617
|
|
|
585
|
-
if self.
|
|
618
|
+
if self.is_adb_root_mode:
|
|
619
|
+
# ADB root mode (LineageOS): adbd runs as root, no su needed
|
|
620
|
+
adb_cmd = self._build_adb_command(['shell', command])
|
|
621
|
+
elif self.is_magisk_mode:
|
|
622
|
+
# Magisk mode: use su -c
|
|
586
623
|
adb_cmd = self._build_adb_command(['shell', f'su -c {command}'])
|
|
587
624
|
else:
|
|
625
|
+
# Traditional su mode
|
|
588
626
|
adb_cmd = self._build_adb_command(['shell', f'su 0 {command}'])
|
|
589
627
|
|
|
590
628
|
return subprocess.run(adb_cmd, capture_output=True, text=True)
|
|
@@ -653,11 +691,32 @@ class FridaManager():
|
|
|
653
691
|
|
|
654
692
|
def adb_check_root(self) -> bool:
|
|
655
693
|
"""
|
|
656
|
-
Check if the device has root access
|
|
694
|
+
Check if the device has root access.
|
|
695
|
+
|
|
696
|
+
Supports three root modes:
|
|
697
|
+
1. ADB root mode (LineageOS): adbd runs as root, no su needed
|
|
698
|
+
2. Magisk mode: su -c command
|
|
699
|
+
3. Traditional su: su 0 command
|
|
657
700
|
|
|
658
701
|
:return: True if root is available, False otherwise
|
|
659
702
|
"""
|
|
660
703
|
try:
|
|
704
|
+
# First, check for ADB root mode (LineageOS with "adb root" enabled)
|
|
705
|
+
# In this mode, adbd runs as root and all shell commands are root
|
|
706
|
+
result = subprocess.run(
|
|
707
|
+
self._build_adb_command(['shell', 'id', '-u']),
|
|
708
|
+
capture_output=True,
|
|
709
|
+
text=True,
|
|
710
|
+
timeout=5
|
|
711
|
+
)
|
|
712
|
+
if result.stdout.strip() == "0":
|
|
713
|
+
# Shell is already running as root (adb root mode)
|
|
714
|
+
self.is_adb_root_mode = True
|
|
715
|
+
self.is_magisk_mode = False
|
|
716
|
+
if self.verbose:
|
|
717
|
+
self.logger.info("[*] Detected ADB root mode (adbd running as root)")
|
|
718
|
+
return True
|
|
719
|
+
|
|
661
720
|
# Try Magisk-style su
|
|
662
721
|
result = subprocess.run(
|
|
663
722
|
self._build_adb_command(['shell', 'su -v']),
|
|
@@ -667,6 +726,9 @@ class FridaManager():
|
|
|
667
726
|
)
|
|
668
727
|
if result.stdout.strip():
|
|
669
728
|
self.is_magisk_mode = True
|
|
729
|
+
self.is_adb_root_mode = False
|
|
730
|
+
if self.verbose:
|
|
731
|
+
self.logger.info("[*] Detected Magisk root mode")
|
|
670
732
|
return True
|
|
671
733
|
|
|
672
734
|
# Try traditional su
|
|
@@ -677,6 +739,10 @@ class FridaManager():
|
|
|
677
739
|
timeout=5
|
|
678
740
|
)
|
|
679
741
|
if result.stdout.strip() == "0":
|
|
742
|
+
self.is_magisk_mode = False
|
|
743
|
+
self.is_adb_root_mode = False
|
|
744
|
+
if self.verbose:
|
|
745
|
+
self.logger.info("[*] Detected traditional su root mode")
|
|
680
746
|
return True
|
|
681
747
|
|
|
682
748
|
return False
|
AndroidFridaManager/about.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: AndroidFridaManager
|
|
3
|
-
Version: 1.9.
|
|
3
|
+
Version: 1.9.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
|
|
@@ -33,7 +33,7 @@ Dynamic: requires-dist
|
|
|
33
33
|
Dynamic: requires-python
|
|
34
34
|
Dynamic: summary
|
|
35
35
|
|
|
36
|
-
 [](https://badge.fury.io/py/AndroidFridaManager) [](https://github.com/fkie-cad/AndroidFridaManager/actions/workflows/publish-to-pypi.yml)
|
|
37
37
|
|
|
38
38
|
# AndroidFridaManager
|
|
39
39
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
AndroidFridaManager/FridaManager.py,sha256=pTcis4oLPBN5U7CdBqdUufwuG6QQDWTPBleTC7rtTbI,32145
|
|
2
|
+
AndroidFridaManager/__init__.py,sha256=T6AKtrGSLQ9M5bJoWDQcsRTJbSEbksdgrx3AAAdozRI,171
|
|
3
|
+
AndroidFridaManager/about.py,sha256=T8Pv1VrgHp0Mn_kJwh5M0yzCUK5pILMP4LdeITJzGtM,98
|
|
4
|
+
AndroidFridaManager/job.py,sha256=1NNcfCjkyUtwUkMXSgT4uswA8UStHo3jxbeJwJoWhc8,3352
|
|
5
|
+
AndroidFridaManager/job_manager.py,sha256=S3biHhYrk-DUUfrHA-g8vbOqwgl4FnWELrUjMxsFyG8,15983
|
|
6
|
+
androidfridamanager-1.9.3.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
7
|
+
androidfridamanager-1.9.3.dist-info/METADATA,sha256=sScuKDxdfBmE7Ag4i-Nd9pu9Ps1Cif29Is4gDOunTvU,5141
|
|
8
|
+
androidfridamanager-1.9.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
+
androidfridamanager-1.9.3.dist-info/entry_points.txt,sha256=GmNngu2fDNCxUcquFRegBa7GWknPKG1jsM4lvWeyKnY,64
|
|
10
|
+
androidfridamanager-1.9.3.dist-info/top_level.txt,sha256=oH2lVMSRlghmt-_tVrOEUqvY462P9hd5Ktgp5-1qF3o,20
|
|
11
|
+
androidfridamanager-1.9.3.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
AndroidFridaManager/FridaManager.py,sha256=kdA79LW0idbJnch6HzXt_J115HysG9zVZS_WZQnIutk,29143
|
|
2
|
-
AndroidFridaManager/__init__.py,sha256=T6AKtrGSLQ9M5bJoWDQcsRTJbSEbksdgrx3AAAdozRI,171
|
|
3
|
-
AndroidFridaManager/about.py,sha256=DNJPRvDT-qbeIc-pXeyCemp2PRRwpIdaG2Du3iDNigk,98
|
|
4
|
-
AndroidFridaManager/job.py,sha256=1NNcfCjkyUtwUkMXSgT4uswA8UStHo3jxbeJwJoWhc8,3352
|
|
5
|
-
AndroidFridaManager/job_manager.py,sha256=S3biHhYrk-DUUfrHA-g8vbOqwgl4FnWELrUjMxsFyG8,15983
|
|
6
|
-
androidfridamanager-1.9.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
7
|
-
androidfridamanager-1.9.1.dist-info/METADATA,sha256=rvJB9NrUBVxqx7_j6cQyfE1jHtyx4wyqvA3PEgglOfE,5141
|
|
8
|
-
androidfridamanager-1.9.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
-
androidfridamanager-1.9.1.dist-info/entry_points.txt,sha256=GmNngu2fDNCxUcquFRegBa7GWknPKG1jsM4lvWeyKnY,64
|
|
10
|
-
androidfridamanager-1.9.1.dist-info/top_level.txt,sha256=oH2lVMSRlghmt-_tVrOEUqvY462P9hd5Ktgp5-1qF3o,20
|
|
11
|
-
androidfridamanager-1.9.1.dist-info/RECORD,,
|
|
File without changes
|
{androidfridamanager-1.9.1.dist-info → androidfridamanager-1.9.3.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{androidfridamanager-1.9.1.dist-info → androidfridamanager-1.9.3.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|