mirror of https://github.com/n1nj4sec/pupy.git
Pass server transport to gen arguments, if no arguments specified
This commit is contained in:
parent
68c6c60c81
commit
6e48ea897c
|
@ -365,6 +365,13 @@ def get_parser(base_parser, default_arch='x86', default_os='windows', default_fo
|
||||||
parser.add_argument('--debug-scriptlets', action='store_true', help="don't catch scriptlets exceptions on the client for debug purposes")
|
parser.add_argument('--debug-scriptlets', action='store_true', help="don't catch scriptlets exceptions on the client for debug purposes")
|
||||||
parser.add_argument('--debug', action='store_true', help="build with the debug template (the payload open a console)")
|
parser.add_argument('--debug', action='store_true', help="build with the debug template (the payload open a console)")
|
||||||
parser.add_argument('--workdir', help='Set Workdir (Default = current workdir)')
|
parser.add_argument('--workdir', help='Set Workdir (Default = current workdir)')
|
||||||
|
parser.add_argument(
|
||||||
|
'launcher', choices=[
|
||||||
|
x for x in launchers.iterkeys()
|
||||||
|
], default='connect', nargs='?',
|
||||||
|
help="Choose a launcher. Launchers make payloads behave differently at startup."
|
||||||
|
)
|
||||||
|
parser.add_argument('launcher_args', nargs=argparse.REMAINDER, help="launcher options")
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
@ -382,6 +389,7 @@ def pupygen(args):
|
||||||
l=launchers[args.launcher]()
|
l=launchers[args.launcher]()
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
print "LAUNCHER ARGS: {}".format(args.launcher_args)
|
||||||
l.parse_args(args.launcher_args)
|
l.parse_args(args.launcher_args)
|
||||||
except LauncherError as e:
|
except LauncherError as e:
|
||||||
if str(e).strip().endswith("--host is required") and not "--host" in args.launcher_args:
|
if str(e).strip().endswith("--host is required") and not "--host" in args.launcher_args:
|
||||||
|
@ -499,13 +507,6 @@ def pupygen(args):
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
Credentials.DEFAULT_ROLE = 'CLIENT'
|
Credentials.DEFAULT_ROLE = 'CLIENT'
|
||||||
parser = get_parser(argparse.ArgumentParser)
|
parser = get_parser(argparse.ArgumentParser)
|
||||||
parser.add_argument(
|
|
||||||
'launcher', choices=[
|
|
||||||
x for x in launchers.iterkeys()
|
|
||||||
], default='auto_proxy',
|
|
||||||
help="Choose a launcher. Launchers make payloads behave differently at startup."
|
|
||||||
)
|
|
||||||
parser.add_argument('launcher_args', nargs=argparse.REMAINDER, help="launcher options")
|
|
||||||
try:
|
try:
|
||||||
pupygen(parser.parse_args())
|
pupygen(parser.parse_args())
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
|
|
@ -687,8 +687,9 @@ class PupyCmd(cmd.Cmd):
|
||||||
self.display_success('Stopping DNSCNC')
|
self.display_success('Stopping DNSCNC')
|
||||||
self.dnscnc.stop()
|
self.dnscnc.stop()
|
||||||
|
|
||||||
self.display_success('Stopping listener')
|
if self.pupsrv.server:
|
||||||
self.pupsrv.server.close()
|
self.display_success('Stopping listener')
|
||||||
|
self.pupsrv.server.close()
|
||||||
|
|
||||||
self.display_success('Restarting')
|
self.display_success('Restarting')
|
||||||
os.execv(argv0, argv)
|
os.execv(argv0, argv)
|
||||||
|
@ -786,18 +787,24 @@ class PupyCmd(cmd.Cmd):
|
||||||
default_arch=default_arch,
|
default_arch=default_arch,
|
||||||
default_format=default_format
|
default_format=default_format
|
||||||
)
|
)
|
||||||
arg_parser.add_argument('-t', '--transport', default=self.pupsrv.transport, help='Transport')
|
|
||||||
arg_parser.add_argument('launcher', nargs='?', default='connect', help='Launcher')
|
print "DEBUG: {} / {}/{}".format(self.pupsrv.transport,
|
||||||
arg_parser.add_argument(
|
self.pupsrv.transport_kwargs, type(self.pupsrv.transport_kwargs))
|
||||||
'launcher_args', nargs=REMAINDER,
|
|
||||||
default=self.pupsrv.transport_kwargs, help='Transport args'
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
args = arg_parser.parse_args(shlex.split(arg))
|
args = arg_parser.parse_args(shlex.split(arg))
|
||||||
except PupyModuleExit:
|
except PupyModuleExit:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
print "DEBUG: After parse: {}".format(args.launcher_args)
|
||||||
|
if not args.launcher_args:
|
||||||
|
args.launcher_args = [
|
||||||
|
x for x in [
|
||||||
|
'-t', self.pupsrv.transport,
|
||||||
|
self.pupsrv.transport_kwargs
|
||||||
|
] if x
|
||||||
|
]
|
||||||
|
|
||||||
if self.pupsrv.httpd:
|
if self.pupsrv.httpd:
|
||||||
wwwroot = self.config.get_folder('wwwroot')
|
wwwroot = self.config.get_folder('wwwroot')
|
||||||
if not args.output_dir:
|
if not args.output_dir:
|
||||||
|
@ -1070,8 +1077,9 @@ class PupyCmd(cmd.Cmd):
|
||||||
self.display_success('Stopping DNSCNC')
|
self.display_success('Stopping DNSCNC')
|
||||||
self.dnscnc.stop()
|
self.dnscnc.stop()
|
||||||
|
|
||||||
self.display_success('Stopping listener')
|
if self.pupsrv.server:
|
||||||
self.pupsrv.server.close()
|
self.display_success('Stopping listener')
|
||||||
|
self.pupsrv.server.close()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue