Repository navigation
Expand file tree
/
Copy pathmain.py
More file actions
332 lines (314 loc) · 13 KB
/
Copy pathmain.py
File metadata and controls
332 lines (314 loc) · 13 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
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# © 2026-tromoSM. All rights reserved.
# tromoSM/xcreenDesk
# MADE FOR GUI MODE GET THE CLI VERSION AT CLI/
# main.py
# v1 GUI
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
XCR_VER=1.0
XCR_RELEASE='2026/03'
XCR_INTERFACE='GUI'
from datetime import datetime
a=datetime.now()
from colorama import Fore,Style
print(f"""
██╗ ██╗ ██████╗██████╗ ███████╗███████╗███╗ ██╗ ██████╗ ███████╗███████╗██╗ ██╗
╚██╗██╔╝██╔════╝██╔══██╗██╔════╝██╔════╝████╗ ██║ ██╔══██╗██╔════╝██╔════╝██║ ██╔╝
╚███╔╝ ██║ ██████╔╝█████╗ █████╗ ██╔██╗ ██║ ██║ ██║█████╗ ███████╗█████╔╝
██╔██╗ ██║ ██╔══██╗██╔══╝ ██╔══╝ ██║╚██╗██║ ██║ ██║██╔══╝ ╚════██║██╔═██╗
██╔╝ ██╗╚██████╗██║ ██║███████╗███████╗██║ ╚████║ ██████╔╝███████╗███████║██║ ██╗
╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝╚══════╝╚═╝ ╚═╝
{XCR_VER} [{XCR_RELEASE}] {XCR_INTERFACE}
""")
print(f"[{Fore.LIGHTMAGENTA_EX}{a.time()}{Style.RESET_ALL}] © 2026 tromoSM. All rights reserved.")
print(f"[{Fore.LIGHTMAGENTA_EX}{a.time()}{Style.RESET_ALL}] tromoSM/xcreenDesk.\n")
print(f"[{Fore.GREEN}{a.time()}{Style.RESET_ALL}] Please wait...")
import cv2 as cdih
from flask import Flask,render_template,request,abort
from flask_socketio import SocketIO,emit
import mss
import numpy as dihpy
import base64
import threading as threadihn
import ctypes
import sys
import pyautogui
import webview
import pymonctl
import os
import shutil
import platform
import socket
import webbrowser
ip="FAILED TO GET IP ADDRESS. run the command 'ipconfig' and find the wlan(wireless network) ip address(v4)"
def refreshA():
global ip
try:
if(platform.system()=='Windows'):
print(f"[{Fore.LIGHTMAGENTA_EX}{a.time()}{Style.RESET_ALL}] Finding ip address")
try:
sdih=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
sdih.connect(('8.8.8.8',80))
ip=sdih.getsockname()[0]
except Exception as dih:
print(f"[{Fore.LIGHTRED_EX}{a.time()}{Style.RESET_ALL}] Failed to find ip address. {dih}")
pass
print(f"[{Fore.LIGHTMAGENTA_EX}{a.time()}{Style.RESET_ALL}] ip address found.")
except PermissionError:
if(platform.system()=='Windows'):
ip="Permission error. reopen as admin to continue"
print(f"[{Fore.RED}{a.time()}{Style.RESET_ALL}] Failed to find ip address.")
APPDATAAHH=os.getenv("APPDATA")
APPROOT=os.path.join(APPDATAAHH,"xcreenDesk")
os.makedirs(APPROOT,exist_ok=True)
def exe():
if getattr(sys,'frozen',False):
return sys._MEIPASS
return os.path.dirname(os.path.abspath(__file__))
a=datetime.now()
print(f"[{Fore.CYAN}{a.time()}{Style.RESET_ALL}] First time running will take a few more seconds than usual.")
temp0dih0server=exe()
def packurbagsahh(dih,seconddih):
os.makedirs(seconddih,exist_ok=True)
for dihh in os.listdir(dih):
sdih=os.path.join(dih,dihh)
ddih=os.path.join(seconddih,dihh)
if not os.path.exists(ddih):
if os.path.isdir(sdih):
shutil.copytree(sdih,ddih)
else:
shutil.copy2(sdih,ddih)
packurbagsahh(os.path.join(temp0dih0server,"static"),
os.path.join(APPROOT,"static"))
packurbagsahh(os.path.join(temp0dih0server,"templates"),
os.path.join(APPROOT,"templates"))
iguessbro=False
iguesscro=None
print(f"[{Fore.GREEN}{a.time()}{Style.RESET_ALL}] Setting up emergency stop")
##VAR GUI vChng
chng0monitor=1
chng0NETcap=1280
chng0REMOTE=True
chng0MSG=True
chng0bannedARR=[]
ctypes.windll.user32.SetProcessDPIAware()
logging0level0info=True
app=Flask(__name__)
S=SocketIO(app,cors_allowed_origins='*',async_mode="threading")
a=datetime.now()
print(f"[{Fore.GREEN}{a.time()}{Style.RESET_ALL}] Turning on server")
class didhejustsayhislastnamewasburger():
def start0main(self,_=None):
global iguessbro,iguesscro
if(iguessbro):
return 'sybau'
iguessbro=True
iguesscro=threadihn.Thread(target=livetypeshi,daemon=True)
iguesscro.start()
a=datetime.now()
print(f"[{Fore.GREEN}{a.time()}{Style.RESET_ALL}] Starting screenshare")
return "yo screen is live yo"
def stopcro(self,_=None):
global iguessbro
iguessbro=False
a=datetime.now()
print(f"[{Fore.RED}{a.time()}{Style.RESET_ALL}] Stopped screenshare")
return 'i guess bro'
def chngremote(self,dih):
global chng0REMOTE
if(dih=='t'):
chng0REMOTE=True
print(f"[{Fore.YELLOW}{a.time()}{Style.RESET_ALL}] Host changed the screenshare mode to full control")
elif(dih=="f"):
chng0REMOTE=False
print(f"[{Fore.YELLOW}{a.time()}{Style.RESET_ALL}] Host changed the screenshare mode to view only")
def chngmsg(self,bigdih):
global chng0MSG
if(bigdih=='t'):
chng0MSG=True
print(f"[{Fore.YELLOW}{a.time()}{Style.RESET_ALL}] Host changed messaging permissions to allow all")
elif(bigdih=='f'):
chng0MSG=False
print(f"[{Fore.YELLOW}{a.time()}{Style.RESET_ALL}] Host changed messaging permissions to allow none")
def BAN(self,datashi):
if(datashi[0]=='b'):
S.emit("autoban",datashi[1])
chng0bannedARR.append(datashi[1])
elif(datashi[0]=='u'):
chng0bannedARR.remove(datashi[1])
S.emit('unban',datashi[1])
S.emit("refr",datashi[1])
def refresh(self,_=None):
refreshA()
S.emit("getip",ip)
def openwebdih(self,_=None):
webbrowser.open_new_tab(f"http://{ip}:1216")
class EmergencyStop(Exception):
a=datetime.now()
temp0a0exit0ex=datetime.now()
def __init__(self):
super().__init__("Stopped due to EmergencyStop.")
temp0a0exit0exa=datetime.now()
print(f"[{Fore.RED}{a.time()}{Style.RESET_ALL}] Took {((temp0a0exit0exa-EmergencyStop.temp0a0exit0ex).total_seconds()):.2f} to execute EmergencyStop")
print(f"[{Fore.RED}{a.time()}{Style.RESET_ALL}] Stopping all functions due to EmergencyStop")
sys.exit(self)
"Stopped due to EmergencyStop."
pass
rl0h=0
rl0w=0
ou0w=0
ou0h=0
temp0inf0offT=0
temp0inf0offL=0
S.emit("monitors",pymonctl.getMonitorsCount())
print(f"[{Fore.GREEN}{a.time()}{Style.RESET_ALL}] Loading preferences")
a=datetime.now()
print(f"[{Fore.GREEN}{a.time()}{Style.RESET_ALL}] Getting screenshare ready")
def livetypeshi():
global rl0w,rl0h,temp0inf0offL,ou0h,ou0w,temp0inf0offT
with mss.mss()as diddy:
maincord=diddy.monitors[chng0monitor]
rl0w=maincord["width"]
rl0h=maincord["height"]
temp0inf0offL=maincord["left"]
temp0inf0offT=maincord["top"]
if(chng0REMOTE):
a=datetime.now()
print(f"[{Fore.GREEN}{a.time()}{Style.RESET_ALL}] Getting ready for remote clicking")
if(rl0w>chng0NETcap):
incaseCAP=chng0NETcap/rl0w
ou0w=int(rl0w*incaseCAP)
ou0h=int(rl0h*incaseCAP)
a=datetime.now()
print(f"[{Fore.GREEN}{a.time()}{Style.RESET_ALL}] Getting ready to resize screenshare into web efficient quality")
print(f"[{Fore.GREEN}{a.time()}{Style.RESET_ALL}] Screenshare resized from {rl0w}x{rl0h} to {ou0w}x{ou0h}")
else:
ou0h=rl0h
ou0w=rl0w
while iguessbro:
if logging0level0info:
a=datetime.now()
print(f"[{Fore.BLUE}{a.time()}{Style.RESET_ALL}] Live capture sent")
ss=diddy.grab(maincord)
ech=dihpy.array(ss)
ech=cdih.cvtColor(ech,cdih.COLOR_BGRA2BGR)
ech=cdih.resize(ech,(ou0w,ou0h))
markgimmethe,succ=cdih.imencode('.jpg',ech,[cdih.IMWRITE_JPEG_QUALITY,60])
fcs=base64.b64encode(succ).decode('utf-8')
S.emit('imim_main',fcs)
S.sleep(0.02)
@S.on("message")
def rec(x,u):
if(chng0MSG):
#raise EmergencyStop()
def bgtsk():
a=datetime.now()
print(f"[{Fore.GREEN}{a.time()}{Style.RESET_ALL}] {u} sent the message '{x}' to host.")
try:
from windows_toasts import AudioSource, Toast, ToastAudio,WindowsToaster
burnttoast = WindowsToaster('xcreenDesk')
TotЯ = Toast()
TotЯ.text_fields = [f"{u} sent you a message",x]
TotЯ.audio=ToastAudio(AudioSource.Default, looping=False)
burnttoast.show_toast(TotЯ)
print(f"[{Fore.GREEN}{a.time()}{Style.RESET_ALL}] message notification sent to host")
except Exception:
S.emit("fail",'failed to send')
pass
print(f"[{Fore.GREEN}{a.time()}{Style.RESET_ALL}] message dialog sent to host")
S.emit("suc",'message sent')
ctypes.windll.user32.MessageBoxW(0,x,f"{u} via xcreenDesk",0x40) #replace with webviewapi gui
print(f"[{Fore.GREEN}{a.time()}{Style.RESET_ALL}] message dialog viewed by host")
tempthead=threadihn.Thread(target=bgtsk,daemon=True)
tempthead.start()
else:
S.emit("fail","messaging is off")
@S.on("eventclick")
def sybau(datashit):
global chng0REMOTE,rl0w,rl0h,temp0inf0offL,temp0inf0offT
if iguessbro:
if chng0REMOTE:
temp0forinstant0XPOS=datashit["temp$$instant$Xpos"]
temp0forinstant0YPOS=datashit["temp$$instant$Ypos"]
temp0absX=int(temp0forinstant0XPOS*rl0w)+temp0inf0offL
temp0absY=int(temp0forinstant0YPOS*rl0h)+temp0inf0offT
a=datetime.now()
if datashit["mode"]=="c":
pyautogui.click(temp0absX,temp0absY)
print(f"[{Fore.GREEN}{a.time()}{Style.RESET_ALL}] {datashit['temp$$instant$Ypos']} clicked {temp0absX}x{temp0absY}.")
elif datashit['mode']=="db":
pyautogui.doubleClick(temp0absX,temp0absY)
print(f"[{Fore.GREEN}{a.time()}{Style.RESET_ALL}] {datashit['temp$$instant$Ypos']} double clicked {temp0absX}x{temp0absY}.")
@S.on("typeshi")
def ngg(sybau):
temp0dih0sybau=['backspace','enter','shift','ctrl','alt','tab','esc','escape','delete','up','down','left',"right"]
if sybau.lower() in temp0dih0sybau:
pyautogui.press(sybau)
else:
pyautogui.write(sybau)
@S.on('scrollcro')
def ohiodih(u,d):
a=datetime.now()
if(d=="d"):
pyautogui.scroll(-10)
print(f"[{Fore.GREEN}{a.time()}{Style.RESET_ALL}]{u} scrolled down the host's screen.")
else:
pyautogui.scroll(10)
print(f"[{Fore.GREEN}{a.time()}{Style.RESET_ALL}]{u} scrolled up the host's screen.")
main0users00={}
allusrahh=[]
@S.on('dih')
def eatdih(u):
main0users00[request.sid]=u[0]
a=datetime.now()
allusrahh.append({
"userdih":u[0],
"mobiledih":u[1]
})
if u[0] in chng0bannedARR:
print(f"[{Fore.MAGENTA}{a.time()}{Style.RESET_ALL}] {u[0]} tried to join while being banned.")
S.emit("autoban",u[0])
print(f"[{Fore.LIGHTBLUE_EX}{a.time()}{Style.RESET_ALL}] {u[0]} joined.")
S.emit("viewerahh",[len(main0users00),allusrahh,u[1]])
@S.on("disconnect")
def sybau():
temp0sid=request.sid
u=main0users00.pop(temp0sid,"unknown user :(")
a=datetime.now()
if(u):
allusrahh[:]=[bdih for bdih in allusrahh if bdih["userdih"]!=u]
print(f"[{Fore.LIGHTBLUE_EX}{a.time()}{Style.RESET_ALL}] {u} left.")
S.emit("viewerahh",[len(main0users00),allusrahh])
@app.route('/_tromoSM-dashboard')
def sybau():
if(request.remote_addr!='127.0.0.1'):
abort(403)
return 'sybau'
return render_template('tromoSM-admin.html')
@app.route('/')
def dih():
return render_template('index.html')
if __name__=="__main__":
dihpi=didhejustsayhislastnamewasburger()
def tempahhtypeshitdawg():
S.run(app,host='0.0.0.0',port=1216,allow_unsafe_werkzeug=True,use_reloader=False)
import time
tempahhthread=threadihn.Thread(target=tempahhtypeshitdawg,daemon=True)
tempahhthread.start()
time.sleep(2)
tempdawg=webview.create_window("XcreenDesk","http://127.0.0.1:1216/_tromoSM-dashboard",js_api=dihpi,min_size=(769,502),background_color="#f7f7f7",resizable=True,draggable=False)
try:
import pyi_splash
pyi_splash.close()
except:
a=datetime.now()
print(f"[{Fore.RED}{a.time()}{Style.RESET_ALL}] PYINSTALLER SPLASH NOT FOUND")
pass
webview.start(private_mode=False,debug=False)