Exemple #1
0
def pcs_init(pcs_options=None):
    paths.POCSUITE_ROOT_PATH = module_path
    set_paths()

    if not os.path.exists(paths.POCSUITE_DIR):
        os.makedirs(paths.POCSUITE_OUTPUT_PATH)
    elif not os.path.exists(paths.POCSUITE_OUTPUT_PATH):
        os.mkdir(paths.POCSUITE_OUTPUT_PATH)
    # 应该直接放到set_paths里

    args_dict = pcs_options or parse_cmd_options()
    cmd_line_options.update(args_dict)
    init_options(cmd_line_options)

    if conf.quiet:
        logger.log = None

    banner()
    conf.showTime = True

    data_to_stdout(f"[!] legal disclaimer: {LEGAL_DISCLAIMER}\n\n")
    data_to_stdout(f"[*] starting at {time.strftime('%X')}\n\n")

    if conf.dork:
        pass
        # TODO

    if not any((
            conf.url or conf.url_file,
            conf.requires,
            conf.requires_freeze,
    )):
        err_msg = "No 'url' or 'url_file' or 'dork' assigned."
        sys.exit(logger.error(err_msg))
Exemple #2
0
    def __init__(self):
        if IS_WIN:
            coloramainit()
        BaseInterpreter.__init__(self)

        conf.report = False
        conf.retry = 0
        conf.delay = 0
        conf.quiet = False
        conf.isPocString = False
        conf.isPycFile = False
        conf.requires = False
        conf.requiresFreeze = False

        conf.url = None
        conf.proxy = None
        conf.params = None
        conf.urlFile = None
        conf.agent = None
        conf.referer = None
        conf.cookie = None
        conf.proxy = None
        conf.randomAgent = False

        conf.threads = 1
        conf.timeout = 5
        conf.httpHeaders = HTTP_DEFAULT_HEADER

        self.prompt = "Pocsuite> "
        banner()
        self.case_insensitive = False
        self.showcommands = [_ for _ in dir(self) if _.startswith('show_')]

        self.current_pocid = 1
Exemple #3
0
    def __init__(self):
        if IS_WIN:
            coloramainit()
        Cmd.__init__(self)
        os.system("clear")

        conf.report = False
        conf.retry = False
        conf.delay = 0
        conf.quiet = False
        conf.isPocString = False
        conf.isPycFile = False
        conf.requires = False
        conf.requiresFreeze = False

        conf.url = None
        conf.proxy = None
        conf.params = None
        conf.urlFile = None
        conf.agent = None
        conf.referer = None
        conf.cookie = None
        conf.proxy = None
        conf.randomAgent = False

        conf.threads = 1
        conf.timeout = 5
        conf.httpHeaders = HTTP_DEFAULT_HEADER

        self.prompt = "Pcs> "
        banner()
        self.case_insensitive = False
Exemple #4
0
    def __init__(self):
        if IS_WIN:
            coloramainit()
        Cmd.__init__(self)
        os.system("clear")

        conf.report = False
        conf.retry = False
        conf.delay = 0
        conf.quiet = False
        conf.isPocString = False
        conf.isPycFile = False
        conf.requires = False
        conf.requiresFreeze = False

        conf.url = None
        conf.proxy = None
        conf.params = None
        conf.urlFile = None
        conf.agent = None
        conf.referer = None
        conf.cookie = None
        conf.proxy = None
        conf.randomAgent = False

        conf.threads = 1
        conf.timeout = 5
        conf.httpHeaders = HTTP_DEFAULT_HEADER

        self.prompt = "Pcs> "
        banner()
        self.case_insensitive = False
Exemple #5
0
    def __init__(self):
        if IS_WIN:
            coloramainit()
        Cmd.__init__(self)
        os.system("clear")
        banner()
        self.case_insensitive = False
        self.prompt = "Pcs> "

        conf.url = None
        conf.proxy = None
        conf.params = None
        conf.urlFile = None
        conf.agent = None
        conf.referer = None
        conf.cookie = None
        conf.proxy = None
        conf.randomAgent = False

        conf.threads = 1
        conf.timeout = 5
        conf.httpHeaders = HTTP_DEFAULT_HEADER
Exemple #6
0
    def __init__(self):
        if IS_WIN:
            coloramainit()
        Cmd.__init__(self)
        os.system("clear")
        banner()
        self.case_insensitive = False
        self.prompt = "Pcs> "

        conf.url = None
        conf.proxy = None
        conf.params = None
        conf.urlFile = None
        conf.agent = None
        conf.referer = None
        conf.cookie = None
        conf.proxy = None
        conf.randomAgent = False

        conf.threads = 1
        conf.timeout = 5
        conf.httpHeaders = HTTP_DEFAULT_HEADER
Exemple #7
0
 def do_banner(self, line):
     """Display an awesome framework banner"""
     banner()
Exemple #8
0
def pcsInit(PCS_OPTIONS=None):
    try:
        paths.POCSUITE_ROOT_PATH = modulePath()
        setPaths()
        if not os.path.exists(paths.POCSUITE_HOME_PATH + '/.pocsuite'):
            os.mkdir(paths.POCSUITE_HOME_PATH + '/.pocsuite')
        if not os.path.exists(paths.POCSUITE_OUTPUT_PATH):
            os.mkdir(paths.POCSUITE_OUTPUT_PATH)

        argsDict = PCS_OPTIONS or parseCmdOptions()

        cmdLineOptions.update(argsDict)
        initOptions(cmdLineOptions)

        def doNothin(*args, **kw):
            return

        if conf.quiet:
            logger.log = doNothin

        banner()
        conf.showTime = True

        dataToStdout("[!] legal disclaimer: %s\n\n" % LEGAL_DISCLAIMER)
        dataToStdout("[*] starting at %s\n\n" % time.strftime("%X"))

        if argsDict['update']:
            update()
            return

        if argsDict['dork']:
            z = ZoomEye(paths.POCSUITE_RC_PATH)
            if z.newToken():
                logger.log(CUSTOM_LOGGING.SUCCESS, 'ZoomEye API authorization success.')
                z.resourceInfo()
            else:
                logger.log(CUSTOM_LOGGING.SUCCESS, 'ZoomEye API authorization failed,Please input Telnet404 Email account and Password for use ZoomEye API!')
                z.write_conf()
                if z.newToken():
                    logger.log(CUSTOM_LOGGING.SUCCESS, 'ZoomEye API authorization success.')
                    z.resourceInfo()
                else:
                    sys.exit(logger.log(CUSTOM_LOGGING.ERROR, 'ZoomEye API authorization failed, make sure correct credentials provided in "~/.pocsuiterc".'))

            info = z.resources
            logger.log(
                CUSTOM_LOGGING.SYSINFO,
                'Available ZoomEye web search limit count: {}, host search limit count: {}'.format(info['web-search'], info['host-search'])
            )

            tmpIpFile = paths.POCSUITE_OUTPUT_PATH + '/zoomeye_%s.txt' % time.strftime('%Y_%m_%d_%H_%M_%S')
            with open(tmpIpFile, 'w') as fp:
                search_types = argsDict.get('search_type', 'web')
                if 'host' not in search_types and 'web' not in search_types:
                    search_types = 'web'
                for page in range(argsDict.get('max_page', 1)):
                    for search_type in search_types.split(','):
                        if search_type in ['web', 'host']:
                            for ip in z.search(argsDict['dork'], page, search_type):
                                if type(ip) == list:
                                    fp.write('%s\n' % ip[0])
                                else:
                                    fp.write('%s\n' % ip)
            conf.urlFile = argsDict['urlFile'] = tmpIpFile

        if not any((argsDict['url'] or argsDict['urlFile'], conf.requires, conf.requiresFreeze)):
            errMsg = 'No "url" or "urlFile" or "dork" assigned.'
            sys.exit(logger.log(CUSTOM_LOGGING.ERROR, errMsg))

        if not any((argsDict['pocFile'], argsDict['vulKeyword'], argsDict['ssvid'])):
            errMsg = 'No "--url" or "--file" or "--vul-keyword" or "--ssv-id" assigned.'
            sys.exit(logger.log(CUSTOM_LOGGING.ERROR, errMsg))

        if argsDict['ssvid']:
            if not os.path.exists(paths.POCSUITE_MODULES_PATH):
                os.mkdir(paths.POCSUITE_MODULES_PATH)
            if not argsDict['ssvid'].isdigit():
                warnMsg = "Paramenter SSV ID must be integer number"
                logger.log(CUSTOM_LOGGING.WARNING, warnMsg)
            else:
                s = Seebug(paths.POCSUITE_RC_PATH)
                if not s.newToken():
                    logger.log(CUSTOM_LOGGING.ERROR,
                               'Seebug API authorization failed, Please input Telnet404 Email account for use Seebug API,you can get it in [https://www.seebug.org/accounts/detail].')
                    s.write_conf()
                    if not s.static():
                        sys.exit(logger.log(CUSTOM_LOGGING.ERROR,
                                            'Seebug API authorization failed, make sure correct credentials provided in "~/.pocsuiterc".'))
                logger.log(CUSTOM_LOGGING.SUCCESS, 'Seebug API authorization succeed.')
                p = s.retrieve(argsDict['ssvid'])
                if 'code' in p:
                    tmp = '%s/%s.py' % (paths.POCSUITE_MODULES_PATH, argsDict['ssvid'])
                    with open(tmp, 'w') as fp:
                        fp.write(p['code'])
                    conf.pocFile = tmp
                else:
                    warnMsg = "Fetch SSV-ID '%s' PoC failed! Check your Telnet404 account API permission." % argsDict['ssvid']
                    logger.log(CUSTOM_LOGGING.WARNING, warnMsg)

        if argsDict['vulKeyword']:
            if not os.path.exists(paths.POCSUITE_MODULES_PATH):
                os.mkdir(paths.POCSUITE_MODULES_PATH)
            folderPath = '%s/%s' % (paths.POCSUITE_MODULES_PATH, argsDict['vulKeyword'])
            if not os.path.exists(folderPath):
                os.mkdir(folderPath)
            s = Seebug(paths.POCSUITE_RC_PATH)
            if not s.newToken():
                    logger.log(CUSTOM_LOGGING.ERROR, 'Seebug API authorization failed, Please input Telnet404 Email account for use Seebug API,you can get it in [https://www.seebug.org/accounts/detail].')
                    s.write_conf()
                    if not s.static():
                        sys.exit(logger.log(CUSTOM_LOGGING.ERROR, 'Seebug API authorization failed, make sure correct credentials provided in "~/.pocsuiterc".'))
            logger.log(CUSTOM_LOGGING.SUCCESS, 'Seebug API authorization succeed.')
            logger.log(CUSTOM_LOGGING.SYSINFO, s.seek(argsDict['vulKeyword']))

            if len(s.pocs) == 0:
                infoMsg = "No available PoC for your Telnet404 account, Try exchange PoC on Seebug website!\n(https://www.seebug.org)"
                logger.log(CUSTOM_LOGGING.WARNING, infoMsg)

            for poc in s.pocs:
                p = s.retrieve(poc['id'])
                tmp = '%s/%s.py' % (folderPath, poc['id'])

                with open(tmp, 'w') as fp:
                    fp.write(p['code'])

        init()
        start()

    except PocsuiteUserQuitException:
        errMsg = "user quit"
        logger.log(CUSTOM_LOGGING.ERROR, errMsg)

    except KeyboardInterrupt:
        print
        errMsg = "user aborted"
        logger.log(CUSTOM_LOGGING.ERROR, errMsg)

    except EOFError:
        print
        errMsg = "exit"
        logger.log(CUSTOM_LOGGING.ERROR, errMsg)

    except SystemExit:
        pass

    except Exception, ex:
        print
        print ex
        # errMsg = unhandledExceptionMessage()
        # logger.log(CUSTOM_LOGGING.WARNING, errMsg)
        excMsg = traceback.format_exc()
        dataToStdout(excMsg)