def _set_network_proxy(): if conf.proxy: debug_msg = "setting the HTTP/SOCKS proxy for all network requests" logger.debug(debug_msg) try: _ = urlsplit(conf.proxy) except Exception as ex: err_msg = "invalid proxy address '{0}' ('{1}')".format( conf.proxy, str(ex)) raise PocsuiteSyntaxException(err_msg) hostname_port = _.netloc.split(":") scheme = _.scheme.upper() hostname = hostname_port[0] port = None username = None password = None if len(hostname_port) == 2: try: port = int(hostname_port[1]) except Exception: pass if not all((scheme, hasattr(PROXY_TYPE, scheme), hostname, port)): err_msg = "proxy value must be in format '({0})://address:port'".format( "|".join(_[0].lower() for _ in get_public_type_members(PROXY_TYPE))) raise PocsuiteSyntaxException(err_msg) if conf.proxy_cred: _ = re.search(r"\A(.*?):(.*?)\Z", conf.proxy_cred) if not _: err_msg = "proxy authentication credentials " err_msg += "value must be in format username:password" raise PocsuiteSyntaxException(err_msg) else: username = _.group(1) password = _.group(2) if scheme in (PROXY_TYPE.SOCKS4, PROXY_TYPE.SOCKS5): socks.set_default_proxy( socks.PROXY_TYPE_SOCKS5 if scheme == PROXY_TYPE.SOCKS5 else socks.PROXY_TYPE_SOCKS4, hostname, port, username=username, password=password) socket.socket = socks.socksocket else: if conf.proxy_cred: proxy_string = "{0}@".format(conf.proxy_cred) else: proxy_string = "" proxy_string = "{0}{1}:{2}".format(proxy_string, hostname, port) conf.proxies = {"http": proxy_string, "https": proxy_string}
def _set_pocs_modules(): # TODO # load poc scripts .pyc file support if conf.poc: load_poc_sucess = False # step1. load system packed poc from pocsuite3/pocs folder for found in glob.glob(os.path.join(paths.POCSUITE_POCS_PATH, "*.py*")): dirname, filename = os.path.split(found) poc_name = os.path.splitext(filename)[0] for poc in conf.poc: if found.endswith(('__init__.py', '__init__.pyc')): continue if poc in (filename, poc_name): info_msg = "loading PoC script '{0}'".format(found) logger.info(info_msg) load_poc_sucess = load_file_to_module(found) # step2. load poc from given file path try: if not load_poc_sucess: for poc in conf.poc: if not poc.startswith('ssvid-') and check_file(poc): info_msg = "loading PoC script '{0}'".format(poc) logger.info(info_msg) load_poc_sucess = load_file_to_module(poc) except PocsuiteSystemException: logger.error('PoC file "{0}" not found'.format(repr(conf.poc))) raise SystemExit # step3. load poc from seebug website using plugin 'poc_from_seebug' if not load_poc_sucess: for poc in conf.poc: if poc.startswith('ssvid-'): info_msg = "loading Poc script 'https://www.seebug.org/vuldb/{0}'".format( poc) logger.info(info_msg) if "poc_from_seebug" not in conf.plugins: conf.plugins.append('poc_from_seebug') load_poc_sucess = True if conf.vul_keyword: # step4. load poc with vul_keyword search seebug website info_msg = "loading PoC script from seebug website using search keyword '{0}' ".format( conf.vul_keyword) logger.info(info_msg) conf.plugins.append('poc_from_seebug') load_poc_sucess = True if (conf.poc or conf.vul_keyword) and not load_poc_sucess: error_msg = "" logger.error(error_msg) raise PocsuiteSyntaxException(error_msg)