-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
102 lines (73 loc) · 2.8 KB
/
run.py
File metadata and controls
102 lines (73 loc) · 2.8 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import subprocess
import sys
import time
import signal
import userinteraction
import config
# Get configuration variables
ip = config.ip
package_name = config.package_name
# Store subprocesses to kill them all on Ctrl+C
processes = []
def kill_handler(sig, frame):
"""Handler for Ctrl+C: terminates all subprocesses."""
print("\n[CTRL+C detected] Closing all subprocesses and reversing global proxy...")
# Logout
userinteraction.logout()
# Close app
subprocess.run(f"adb shell am force-stop {package_name}")
# Reverse global proxy
subprocess.run("adb shell settings put global http_proxy :0")
for p in processes:
try:
p.terminate() # Try graceful shutdown
except:
pass
time.sleep(1)
for p in processes:
try:
p.kill() # Force kill if needed
except:
pass
print("All subprocesses closed.")
sys.exit(0)
def main():
"""Main execution: starts all tools and handles user interaction."""
# Register Ctrl+C handler
signal.signal(signal.SIGINT, kill_handler)
# Start global proxy to capture traffic
print("[INFO] Changing proxy to mitm address...")
subprocess.run(f"adb shell settings put global http_proxy {ip}:8080")
# Start screen mirroring
print("[INFO] Starting screen mirroring...")
screen = subprocess.Popen("programs\scrcpy-win64-v3.3.3\scrcpy.exe", creationflags=subprocess.CREATE_NEW_CONSOLE)
processes.append(screen)
# Start mitmproxy web interface
print("[INFO] Starting mitmproxy web interface...")
mitmproxy = subprocess.Popen("mitmweb",creationflags=subprocess.CREATE_NEW_CONSOLE)
processes.append(mitmproxy)
# # Start Frida certificate unpinning
# print("[INFO] Starting Frida certificate unpinning script...")
# fridaunpin = subprocess.Popen(f"frida --codeshare akabe1/frida-multiple-unpinning -U -f {package_name}",creationflags=subprocess.CREATE_NEW_CONSOLE)
# processes.append(fridaunpin)
# Start app
subprocess.run(f"frida -U -f {package_name} -l .\\fridascript.js")
# Wait for the app to load
print("[INFO] Waiting for the app to start...")
time.sleep(15)
print("[INFO] All services started. Press Ctrl+C to exit.")
# Run user interaction logic
print("[INFO] Running user interaction logic...")
userinteraction.login()
# Do some user interactions
time.sleep(1)
print("[INFO] Guided app traverse...")
userinteraction.traverseApp()
time.sleep(1)
print("[INFO] Random app traverse...")
userinteraction.randomthings(123, 50)
# Keep the script alive to catch Ctrl+C
while True:
time.sleep(1)
if __name__ == "__main__":
main()