예제 #1
0
 def test_next(self, requests_mock):
     requests_mock.get(WEBSITE)
     requests_mock.get(WEBSITE2)
     session = HTTPSession()
     session.goto(WEBSITE)
     session.goto(WEBSITE2)
     session.prev()
     assert session.next().host == WEBSITE2
예제 #2
0
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}")
예제 #3
0
 def test_follow(self, requests_mock):
     requests_mock.get(WEBSITE,
                       status_code=301,
                       headers={"Location": WEBSITE2})
     requests_mock.get(WEBSITE2)
     session = HTTPSession()
     session.goto(WEBSITE)
     session.follow()
     assert session.host == WEBSITE2
예제 #4
0
 def test_goout(self, requests_mock):
     #: http://test.com/parent/child
     fullurl = "".join([WEBSITE, PARENTPATH, CHILDPATH])
     #: http://test.com/parent
     parenturl = "".join([WEBSITE, PARENTPATH])
     requests_mock.get(WEBSITE)
     requests_mock.get(fullurl)
     requests_mock.get(parenturl)
     session = HTTPSession()
     session.goto(fullurl)
     assert session.goout().path == PARENTPATH
     # Test goout to root
     assert session.goout().path == "/"
     # Test goout to root when already in root
     assert session.goout().path == "/"
예제 #5
0
 def test_goin(self, requests_mock):
     #: http://test.com/parent/child
     fullurl = "".join([WEBSITE, PARENTPATH, CHILDPATH])
     #: http://test.com/parent
     parenturl = "".join([WEBSITE, PARENTPATH])
     requests_mock.get(WEBSITE)
     requests_mock.get(parenturl)
     requests_mock.get(fullurl)
     session = HTTPSession()
     session.goto(WEBSITE)
     # Test goin from root
     assert session.goin(PARENTPATH).path == PARENTPATH
     # Test goin from parent
     assert session.goin(CHILDPATH).path == "".join([PARENTPATH, CHILDPATH])
예제 #6
0
 def test_goto(self, requests_mock):
     requests_mock.get(WEBSITE)
     session = HTTPSession()
     session.goto(WEBSITE)
     assert session.page.isok and session.host == WEBSITE
예제 #7
0
 def test_run(self, requests_mock):
     requests_mock.get(WEBSITE)
     session = HTTPSession()
     request = session.get(WEBSITE)
     assert session.run(request).pop().code == 200
예제 #8
0
 async def test_request(self, requests_mock, host, path, result):
     session = HTTPSession()
     requests_mock.get("/".join([WEBSITE, "test"]))
     session.host = host
     response = await session.get(path)
     assert response.url == result
예제 #9
0
 def test_workers(self):
     session = HTTPSession()
     session.workers = 10
     assert session.workers == 10
예제 #10
0
 def test_agent(self):
     session = HTTPSession()
     session.agent = "test"
     assert session.agent == "test"