-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathScrCpy_GUI.py
206 lines (151 loc) · 6.39 KB
/
ScrCpy_GUI.py
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
from tkinter import *
import urllib.request
import os, time, json, threading
from tkinter import filedialog
from ppadb.client import Client as AdbClient
ip = input('''
----------------------------------------
Press `CTRL + PAUSE/BREAK` keys to exit.
Press ENTER for default IP
192.168.0.102
----------------------------------------
Paste IP Address of Device : ''')
try: os.mkdir('ScreenRecord')
except: pass
def task1():
global ip
print()
print("Task 1 assigned to thread: {}".format(threading.current_thread().name))
print("ID of process running task 1: {}".format(os.getpid()))
if ip == '':
ip = '192.168.0.102'
while True:
print()
os.system(f'scrcpy --tcpip={ip}')
def task2():
print()
print("Task 2 assigned to thread: {}".format(threading.current_thread().name))
print("ID of process running task 2: {}".format(os.getpid()))
def power():
os.system(f'adb -s {ip} shell input keyevent 26')
def volup():
os.system(f'adb -s {ip} shell input keyevent 24')
def voldown():
os.system(f'adb -s {ip} shell input keyevent 25')
def submit():
try:
urllib.request.urlretrieve("https://raw.githubusercontent.com/imvickykumar999/Android-Trojan-Horse/main/keyevents.json", "keyevents.json")
time.sleep(1)
root.destroy()
except Exception as e:
print(e)
def fun():
key = num_list.get(num_list.curselection()[0])
key = key.split(' : ')[0]
os.system(f'adb -s {ip} shell input keyevent {key}')
def pull_file(file="screenshot.png", pull_start_path='Download/Telegram/static/'):
client = AdbClient(host="127.0.0.1", port=5037)
device = client.device(f'{ip}:5555')
file = dir_list.get(dir_list.curselection()[0])
pull_start_path = entry.get()
event.set(f'{pull_start_path}/{file}')
if file[-1] == '/':
print(f'\n>>> "{pull_start_path}/{file}" Selected ...')
else:
try:
print(f'\n>>> Receiving {file} ...')
device.pull(f"/sdcard/{pull_start_path}/{file}", f"ScreenRecord/{file}")
print(f'\tReceived Successfully.')
except:
print(f'\tFile NOT Received.')
event.set(pull_start_path)
def push_file(push_stop_path='Download/Telegram/static/'):
client = AdbClient(host="127.0.0.1", port=5037)
device = client.device(f'{ip}:5555')
push_start_file = filedialog.askopenfilename()
push_stop_path = entry.get()
try:
file = os.path.basename(push_start_file)
if file.split('.')[-1] in ['apk', ]:
print(f'\n>>> Installing {file} ...')
device.install(push_start_file)
print(f'\n>>>\tInstalled.')
else:
print(f'\n>>> Sending {file} ...')
device.push(f"{push_start_file}", f"/sdcard/{push_stop_path}/{file}")
print(f'\tSent Successfully.')
except:
print(f'\tFile NOT Selected.')
pass
def back():
slash_path = entry.get()
slash = slash_path.split('/')
slash.pop()
slash.pop()
event.set('/'.join(slash) + '/')
while True:
root = Tk()
root.geometry("300x600")
root.title("ScrCpy GUI")
root.config(bg="gray")
event = StringVar()
dir_list = Listbox(root, height=7, width=30)
dir_list.place(relx=0.5, rely=0.3, anchor='center')
entry = Entry(root, textvariable = event)
entry.place(relx=0.56, rely=0.14, anchor='center', width=150)
back_btn = Button(root, bg='orange', text='. . /', command=back)
back_btn.place(relx=0.25, rely=0.14, anchor='center')
rely3 = rely4 = 0.8
rely5 = 0.9
try:
num_list = Listbox(root, height=8, width=30)
with open('keyevents.json') as f:
data = json.load(f)
for i in data['key_events']:
j = data['key_events'][i]
k = j.split('adb shell input keyevent ')
num_list.insert(k[1], f'{k[1]} : {i.split("key_")[1]}')
num_list.place(relx=0.5, rely=0.6, anchor='center')
get_num_btn = Button(root, bg='light green', text="Run ADB", command=fun)
get_num_btn.place(relx=0.5, rely=0.67, anchor='center')
except:
btn = StringVar()
btn1 = Entry(root, textvariable = btn)
btn1.insert(0, 'keyevent.json')
btn1.place(relx=0.5, rely=0.6, anchor='center')
btn2 = Button(root, bg='light green', text = 'Download', command=submit)
btn2.place(relx=0.5, rely=0.65, anchor='center')
path='DCIM/Camera/'
event.set(path)
upload = Button(root, bg='yellow', text='Send File', command = lambda: push_file(path))
upload.place(relx=0.5, rely=0.08, anchor='center')
def on_click():
path = event.get()
output = os.popen(f'adb shell ls -p /sdcard/{path}')
output = output.read().split('\n')[:-1]
dir_list.delete(0, END)
for i,j in enumerate(output):
dir_list.insert(i, j)
dir_list.place(relx=0.5, rely=0.3, anchor='center')
button = Button(root, bg='light blue', text="Update Folder", command=on_click)
button.place(relx=0.33, rely=0.43, anchor='center')
download = Button(root, bg='yellow', text='Receive Selected', command = lambda: pull_file(path))
download.place(relx=0.65, rely=0.43, anchor='center')
btn3 = Button(root, text="Volume Up", bg='green', command=volup)
btn3.place(relx=0.32, rely=rely3, anchor='center')
btn4 = Button(root, text="Volume Down", bg='red', command=voldown)
btn4.place(relx=0.63, rely=rely4, anchor='center')
btn5 = Button(root, bg='pink', text="Power ON / OFF", command=power)
btn5.place(relx=0.5, rely=rely5, anchor='center')
root.mainloop()
if __name__ == "__main__":
os.system('color 2')
print()
print("ID of process running main program: {}".format(os.getpid()))
print("Main thread name: {}".format(threading.current_thread().name))
t1 = threading.Thread(target=task1, name='t1')
t2 = threading.Thread(target=task2, name='t2')
t1.start()
t2.start()
t1.join()
t2.join()