async def main(): #: Parsed Arguments a = parse_args() #: Logger object l = Logger(filename=a.output, colors=not a.no_colors, verbosity=a.verbosity) #: Urls to check urls = [] if a.url: urls = [a.url] if a.url_list: if not os.path.isfile(a.url_list): l.error(f"File not found: {a.url_list}") return urls = loadlist(a.url_list) nbt = len(urls) l.info(f"{nbt} hosts will be checked") #: HTTP Session object s = HTTPSession() l.info("Finding vulnerables hosts ...") futures = [ s.get(f"{u}/wp-content/plugins/{a.slug}/readme.txt") for u in urls ] nbv = 0 for f in tqdm.as_completed(futures, ascii=BARCURSOR, bar_format=BARFORMAT): try: #: HTTP Response object r = await f #: Founded version v = get_version(r) if v: if v < a.version: l.success( f"{r.host} - {a.slug} version is vulnerable: {v}") nbv += 1 else: l.partial(f"{r.host} - {a.slug} is not vulnerable: {v}") else: l.fail(f"{r.host} - plugin not found") except Exception as e: l.error(e) l.info(f"{nbv} hosts have vulnerable versions of {a.slug}")
def test_run(self, requests_mock): requests_mock.get(WEBSITE) session = HTTPSession() request = session.get(WEBSITE) assert session.run(request).pop().code == 200