-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDroidRemote3.py
More file actions
133 lines (111 loc) · 4.14 KB
/
Copy pathDroidRemote3.py
File metadata and controls
133 lines (111 loc) · 4.14 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
from flask import Flask, render_template, request, redirect, url_for, session
import subprocess
import os
import re
import paramiko
import socket
import qrcode
from io import BytesIO
from flask import send_file
app = Flask(__name__)
app.secret_key = "your_secret_key_here"
# Configuration
DEVICE_IP = "192.168.1.100" # Will be dynamically updated
ADB_PORT = "5555"
FRIDA_PORT = "27042"
SCRCPY_PORT = "1234"
SCRCPY_BINARY = "/usr/bin/scrcpy" # Adjust if needed
@app.route("/", methods=["GET", "POST"])
def index():
if request.method == "POST":
if "start" in request.form:
try:
subprocess.run(["adb", "connect", f"{DEVICE_IP}:{ADB_PORT}"], check=True)
subprocess.Popen(["adb", "shell", "frida-server &"])
subprocess.Popen([SCRCPY_BINARY, "-s", f"{DEVICE_IP}:{SCRCPY_PORT}"])
subprocess.Popen(["adb", "shell", "frida-trace -U -l /data/local/tmp/frida_hook.js &"])
return redirect(url_for("index"))
except Exception as e:
return f"Error: {e}"
elif "stop" in request.form:
try:
subprocess.run(["adb", "disconnect"])
subprocess.run(["adb", "shell", "killall frida-server"])
subprocess.run(["pkill", "scrcpy"])
return redirect(url_for("index"))
except Exception as e:
return f"Error: {e}"
elif "file_transfer" in request.form:
file = request.files.get("file")
if file:
file.save(f"/data/local/tmp/{file.filename}")
return "File uploaded!"
elif "file_explorer" in request.form:
return redirect(url_for("file_explorer"))
elif "mic_capture" in request.form:
return redirect(url_for("mic_capture"))
elif "speak" in request.form:
return redirect(url_for("speak"))
elif "qr_code" in request.form:
return redirect(url_for("qr_code"))
elif "notification" in request.form:
message = request.form.get("message")
if message:
subprocess.run(["adb", "shell", "am start -a android.intent.action.SEND -d 'text/plain' --es 'android.intent.extra.TEXT' '{}'.format(message)"])
return redirect(url_for("index"))
elif "media_send" in request.form:
file = request.files.get("media")
if file:
file.save(f"/data/local/tmp/{file.filename}")
subprocess.run(["adb", "push", f"/data/local/tmp/{file.filename}", "/sdcard/Download/"])
return "Media uploaded!"
return render_template("index.html")
@app.route("/file_explorer")
def file_explorer():
return render_template("file_explorer.html")
@app.route("/mic_capture")
def mic_capture():
return render_template("mic_capture.html")
@app.route("/speak")
def speak():
return render_template("speak.html")
@app.route("/qr_code")
def qr_code():
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=4,
)
qr.add_data("http://192.168.40.241:5000")
img = qr.make_image(fill_color="black", back_color="white")
img_buffer = BytesIO()
img.save(img_buffer, format="PNG")
img_buffer.seek(0)
return send_file(
img_buffer,
mimetype="image/png",
as_attachment=False,
download_name="qr_code.png"
)
@app.route("/notification")
def notification():
return render_template("notification.html")
@app.route("/media_send")
def media_send():
return render_template("media_send.html")
@app.route("/ssh")
def ssh():
return render_template("ssh.html")
@app.route("/ssh", methods=["POST"])
def ssh_post():
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("your_device_ip", username="root", password="your_password")
stdin, stdout, stderr = ssh.exec_command("ls")
output = stdout.read().decode()
error = stderr.read().decode()
ssh.close()
return f"Output: {output}\nError: {error}"
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000)