-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule_manager.py
More file actions
76 lines (68 loc) · 2.55 KB
/
Copy pathmodule_manager.py
File metadata and controls
76 lines (68 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python3
"""
module_manager.py -- List, enable, disable, and uninstall LSPosed modules via ADB
Usage: python3 module_manager.py --list
python3 module_manager.py --disable com.example.module
python3 module_manager.py --uninstall com.example.module
"""
import subprocess, json, argparse, sys
def adb(cmd):
r = subprocess.run(f"adb shell {cmd}", shell=True, capture_output=True, text=True)
return r.stdout.strip()
def list_modules():
"""List all installed LSPosed modules"""
out = adb("cmd package dump com.example.lsposed | grep -A 100 'module'")
# Fallback: check installed packages with 'lsposed' in name
pkgs = adb("pm list packages | grep -i lsposed")
print("\n📦 LSPosed Modules")
print("=" * 50)
if not pkgs:
print("No LSPosed modules found. Install via LSPosed Manager app.")
return
for pkg in pkgs.splitlines():
pkg = pkg.replace("package:", "")
label = adb(f"pm dump {pkg} | grep 'android.app.ApplicationInfo' | head -1")
print(f" {pkg}")
def enable_module(pkg):
"""Enable a module in LSPosed"""
# Uses LSPosed's private API (requires root or system app)
result = adb(f"cmd appops set {pkg} ACTIVITY_RECOGNITION allow")
if "Success" in result or result == "":
print(f"✓ Enabled: {pkg}")
else:
print(f"✗ Failed: {result}")
def disable_module(pkg):
"""Disable a module"""
result = adb(f"cmd appops set {pkg} ACTIVITY_RECOGNITION deny")
if "Success" in result or result == "":
print(f"✓ Disabled: {pkg}")
else:
print(f"✗ Failed: {result}")
def uninstall_module(pkg):
"""Uninstall a module"""
result = adb(f"pm uninstall {pkg}")
if "Success" in result:
print(f"✓ Uninstalled: {pkg}")
else:
print(f"✗ Failed: {result}")
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--list", action="store_true", help="List all modules")
parser.add_argument("--enable", help="Enable a module")
parser.add_argument("--disable", help="Disable a module")
parser.add_argument("--uninstall", help="Uninstall a module")
args = parser.parse_args()
if args.list:
list_modules()
elif args.enable:
enable_module(args.enable)
elif args.disable:
disable_module(args.disable)
elif args.uninstall:
confirm = input(f"Uninstall {args.uninstall}? (y/N): ").strip().lower()
if confirm == 'y':
uninstall_module(args.uninstall)
else:
parser.print_help()
if __name__ == "__main__":
main()