def get_parser(base_parser, config): parser = base_parser(description='Generate payloads for windows, linux, osx and android.') parser.add_argument('-f', '--format', default=config.get('gen', 'format'), choices=PAYLOAD_FORMATS, help="(default: client)") parser.add_argument('-O', '--os', default=config.get('gen', 'os'), choices=CLIENT_OS, help='Target OS (default: windows)') parser.add_argument('-A', '--arch', default=config.get('gen', 'arch'), choices=CLIENT_ARCH, help='Target arch (default: x86)') parser.add_argument('-S', '--shared', default=False, action='store_true', help='Create shared object') parser.add_argument('-o', '--output', help="output path") parser.add_argument('-D', '--output-dir', default=config.get('gen', 'output'), help="output folder") parser.add_argument('-s', '--scriptlet', default=[], action='append', help="offline python scriptlets to execute before starting the connection. Multiple scriptlets can be privided.") parser.add_argument('-l', '--list', action=ListOptions, nargs=0, help="list available formats, transports, scriptlets and options") parser.add_argument('-E', '--prefer-external', default=config.getboolean('gen', 'external'), action='store_true', help="In case of autodetection prefer external IP") parser.add_argument('--no-use-proxy', action='store_true', help="Don't use the target's proxy configuration even if it is used by target (for ps1_oneliner only for now)") parser.add_argument('--randomize-hash', action='store_true', help="add a random string in the exe to make it's hash unknown") parser.add_argument('--oneliner-listen-port', default=8080, type=int, help="Port used by oneliner listeners ps1,py (default: %(default)s)") 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('--workdir', help='Set Workdir (Default = current workdir)') parser.add_argument( 'launcher', choices=[ x for x in launchers.iterkeys() ], default=config.get('gen', 'launcher') or 'connect', nargs='?', help="Choose a launcher. Launchers make payloads behave differently at startup." ) parser.add_argument( 'launcher_args', default=config.get('gen', 'launcher_args'), nargs=argparse.REMAINDER, help="launcher options") check_templates_version() return parser
def get_parser(base_parser, config): parser = base_parser(description='Generate payloads for windows, linux, osx and android.') parser.add_argument('-f', '--format', default=config.get('gen', 'format'), choices=PAYLOAD_FORMATS, help="(default: client)") parser.add_argument('-O', '--os', default=config.get('gen', 'os'), choices=CLIENT_OS, help='Target OS (default: windows)') parser.add_argument('-A', '--arch', default=config.get('gen', 'arch'), choices=CLIENT_ARCH, help='Target arch (default: x86)') parser.add_argument('-U', '--uncompressed', default=False, action='store_true', help='Use uncompressed template') parser.add_argument('-P', '--packer', default=config.get('gen', 'packer'), help='Use packer') parser.add_argument('-S', '--shared', default=False, action='store_true', help='Create shared object') parser.add_argument('-o', '--output', help="output path") parser.add_argument('-D', '--output-dir', default=config.get('gen', 'output'), help="output folder") parser.add_argument('-s', '--scriptlet', default=[], action='append', help="offline python scriptlets to execute before starting the connection. Multiple scriptlets can be privided.") parser.add_argument('-l', '--list', action=ListOptions, nargs=0, help="list available formats, transports, scriptlets and options") parser.add_argument('-E', '--prefer-external', default=config.getboolean('gen', 'external'), action='store_true', help="In case of autodetection prefer external IP") parser.add_argument('--no-use-proxy', action='store_true', help="Don't use the target's proxy configuration even if it is used by target (for ps1_oneliner only for now)") parser.add_argument('--randomize-hash', action='store_true', help="add a random string in the exe to make it's hash unknown") parser.add_argument('--oneliner-listen-port', default=8080, type=int, help="Port used by ps1_oneliner locally (default: %(default)s)") parser.add_argument('--oneliner-no-ssl', default=False, action='store_true', help="No ssl for ps1_oneliner stages (default: %(default)s)") parser.add_argument('--oneliner-nothidden', default=False, action='store_true', help="Powershell script not hidden target side (default: %(default)s)") 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('--workdir', help='Set Workdir (Default = current workdir)') parser.add_argument( 'launcher', choices=[ x for x in launchers.iterkeys() ], default=config.get('gen', 'launcher') or 'connect', nargs='?', help="Choose a launcher. Launchers make payloads behave differently at startup." ) parser.add_argument( 'launcher_args', default=config.get('gen', 'launcher_args'), nargs=argparse.REMAINDER, help="launcher options") return parser
for name, sc in scriptlets_dic.iteritems(): print "\t- {:<15} : ".format(name) print '\n'.join(["\t"+x for x in sc.get_help().split("\n")]) exit() PAYLOAD_FORMATS=['apk', 'exe_x86', 'exe_x64', 'dll_x86', 'dll_x64', 'py', 'py_oneliner'] if __name__=="__main__": parser = argparse.ArgumentParser(description='Generate payloads for windows, linux, osx and android.') parser.add_argument('-f', '--format', default='exe_x86', choices=PAYLOAD_FORMATS, help="(default: exe_x86)") parser.add_argument('-o', '--output', help="output path") parser.add_argument('-s', '--scriptlet', default=[], action='append', help="offline python scriptlets to execute before starting the connection. Multiple scriptlets can be privided.") parser.add_argument('-l', '--list', action=ListOptions, nargs=0, help="list available formats, transports, scriptlets and options") parser.add_argument('-i', '--interface', default="eth0", help="The default interface to listen on") parser.add_argument('--randomize-hash', action='store_true', help="add a random string in the exe to make it's hash unknown") parser.add_argument('--debug-scriptlets', action='store_true', help="don't catch scriptlets exceptions on the client for debug purposes") 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") args=parser.parse_args() script_code="" if args.scriptlet: script_code=parse_scriptlets(args.scriptlet, debug=args.debug_scriptlets) l=launchers[args.launcher]() while True: try: l.parse_args(args.launcher_args)
'--list', action=ListOptions, nargs=0, help="list available formats, scriptlets and options") parser.add_argument( '--randomize-hash', action='store_true', help="add a random string in the exe to make it's hash unknown") parser.add_argument( '--debug-scriptlets', action='store_true', help= "don't catch scriptlets exceptions on the client for debug purposes") 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") args = parser.parse_args() script_code = "" if args.scriptlet: script_code = parse_scriptlets(args.scriptlet, debug=args.debug_scriptlets)
#signing the tar res=subprocess.check_output("jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore crypto/pupy-apk-release-key.keystore -storepass pupyp4ssword '%s' pupy_key"%new_path, shell=True) # -tsa http://timestamp.digicert.com print(res) finally: #cleaning up shutil.rmtree(tempdir, ignore_errors=True) if __name__=="__main__": parser = argparse.ArgumentParser(description='Generate EXE/DLL for windows and APK for android.') parser.add_argument('-t', '--type', default='exe_x86', choices=['apk','exe_x86','exe_x64','dll_x86','dll_x64'], help="(default: exe_x86)") parser.add_argument('-o', '--output', help="output path") parser.add_argument('-s', '--offline-script', help="offline python script to execute before starting the connection") parser.add_argument('--randomize-hash', action='store_true', help="add a random string in the exe to make it's hash unknown") 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") args=parser.parse_args() l=launchers[args.launcher]() while True: try: l.parse_args(args.launcher_args) except LauncherError as e: if str(e).strip().endswith("--host is required") and not "--host" in args.launcher_args: myip=get_local_ip() if not myip: sys.exit("[-] --host parameter missing and couldn't find your local IP. You must precise an ip or a fqdn manually") print("[!] required argument missing, automatically adding parameter --host %s:443 from local ip address"%myip) args.launcher_args.insert(0,"%s:443"%myip) args.launcher_args.insert(0,"--host")
parser.add_argument('-D', '--output-dir', default=default_payload_output, help="output folder (default: %(default)s)") parser.add_argument('-s', '--scriptlet', default=[], action='append', help="offline python scriptlets to execute before starting the connection. Multiple scriptlets can be privided.") parser.add_argument('-l', '--list', action=ListOptions, nargs=0, help="list available formats, transports, scriptlets and options") parser.add_argument('-E', '--prefer-external', default=config.getboolean('gen', 'external'), action='store_true', help="In case of autodetection prefer external IP") parser.add_argument('--no-use-proxy', action='store_true', help="Don't use the target's proxy configuration even if it is used by target (for ps1_oneliner only for now)") parser.add_argument('--randomize-hash', action='store_true', help="add a random string in the exe to make it's hash unknown") parser.add_argument('--oneliner-listen-port', default=8080, type=int, help="Port used by ps1_oneliner locally (default: %(default)s)") parser.add_argument('--oneliner-no-ssl', default=False, action='store_true', help="No ssl for ps1_oneliner stages (default: %(default)s)") parser.add_argument('--oneliner-nothidden', default=False, action='store_true', help="Powershell script not hidden target side (default: %(default)s)") 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('--workdir', help='Set Workdir (Default = current workdir)') parser.add_argument( 'launcher', choices=[ x for x in launchers.iterkeys() ], default=config.get('gen', 'launcher') or 'connect', nargs='?', help="Choose a launcher. Launchers make payloads behave differently at startup." ) parser.add_argument( 'launcher_args', default=config.get('gen', 'launcher_args'), nargs=argparse.REMAINDER, help="launcher options") return parser def pupygen(args, config): ok = colorize("[+] ","green") if args.workdir: os.chdir(args.workdir) script_code=""