Example #1
0
    def test_params_set(self):
        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/path?param=1&param2=2"

        fuzz_res = FuzzResult(history=fr)

        ffilter = FuzzResFilter(filter_string="r.params.get.param=+'test'")
        ffilter.is_visible(fuzz_res)
        self.assertEqual(fuzz_res.history.params.get.param, "1test")
        self.assertEqual(fuzz_res.history.params.get, {'param': "1test", 'param2': "2"})

        ffilter = FuzzResFilter(filter_string="r.params.get.param=-'test'")
        ffilter.is_visible(fuzz_res)
        self.assertEqual(fuzz_res.history.params.get.param, "test1test")
        self.assertEqual(fuzz_res.history.params.get, {'param': "test1test", 'param2': "2"})

        ffilter = FuzzResFilter(filter_string="r.params.get.param:='test'")
        ffilter.is_visible(fuzz_res)
        self.assertEqual(fuzz_res.history.params.get.param, "test")
        self.assertEqual(fuzz_res.history.params.get, {'param': "test", 'param2': "2"})

        ffilter = FuzzResFilter(filter_string="r.params.get.param2='2'")
        self.assertEqual(ffilter.is_visible(fuzz_res), True)

        fr.url = "http://www.wfuzz.org/path?param=1&param2=2"
        ffilter = FuzzResFilter(filter_string="r.params.all=+'2'")
        ffilter.is_visible(fuzz_res)
        self.assertEqual(fuzz_res.history.params.all, {'param': "12", 'param2': "22"})

        fr.url = "http://www.wfuzz.org/path?param=1&param2=2"
        ffilter = FuzzResFilter(filter_string="r.params.all:='2'")
        ffilter.is_visible(fuzz_res)
        self.assertEqual(fuzz_res.history.params.all, {'param': "2", 'param2': "2"})
Example #2
0
    def _gen_burpitem(self, output_fn):
        try:
            tree = ET.parse(self.find_file(output_fn))
            for item in tree.getroot().iter('item'):
                fr = FuzzRequest()
                fr.update_from_raw_http(
                    raw=b64decode(item.find('request').text
                                  or "").decode('utf-8'),
                    scheme=item.find('protocol').text,
                    raw_response=b64decode(item.find('response').text or ""))
                fr.wf_ip = {
                    'ip':
                    item.find('host').attrib.get('ip', None)
                    or item.find('host').text,
                    'port':
                    item.find('port').text
                }
                frr = FuzzResult(history=fr)

                yield frr.update()
            return
        except IOError as e:
            raise FuzzExceptBadFile(
                "Error opening Burp items payload file. %s" % str(e))
        except EOFError:
            return
Example #3
0
    def parse_burp_log(self, burp_log):
        burp_file = None

        try:
            burp_file = open(self.find_file(burp_log), 'rb')

            history = 'START'

            rl = burp_file.readline()
            while rl != "":
                if history == "START":
                    if rl == DELIMITER:
                        history = "HEADER"
                elif history == "HEADER":
                    if rl == DELIMITER:
                        raw_request = ""
                        history = "REQUEST"
                    else:
                        matched = HEADER.match(rl)
                        ctime, host, ip_address = matched.group(1, 3, 5)
                elif history == "REQUEST":
                    if rl == DELIMITER:
                        history = "DELIM1"
                    else:
                        raw_request += rl
                elif history == "DELIM1":
                    if rl == CRLF:
                        raw_response = ""
                        history = "DELIM3"
                    else:
                        raw_response = rl
                        history = "RESPONSE"
                elif history == "RESPONSE":
                    if rl == DELIMITER:
                        history = "DELIM2"
                    else:
                        raw_response += rl
                elif history == "DELIM2":
                    if rl == CRLF:
                        history = "DELIM3"
                elif history == "DELIM3":
                    if rl == CRLF:
                        history = "DELIM4"
                elif history == "DELIM4":
                    if rl == CRLF:
                        fr = FuzzRequest()
                        fr.update_from_raw_http(raw_request, host[:host.find("://")], raw_response)
                        frr = FuzzResult(history=fr)

                        yield frr.update()

                        history = "START"

                rl = burp_file.readline()

        except IOError as e:
            raise FuzzExceptBadFile("Error opening burp log file. %s" % str(e))
        finally:
            if burp_file is not None:
                burp_file.close()
Example #4
0
    def test_urlp(self):
        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/path/test.php?param=1&param2=2"

        fuzz_res = FuzzResult(history=fr)

        ffilter = FuzzResFilter(filter_string="r.urlp.scheme='http'")
        self.assertEqual(True, ffilter.is_visible(fuzz_res))

        ffilter = FuzzResFilter(filter_string="r.urlp.netloc='www.wfuzz.org'")
        self.assertEqual(True, ffilter.is_visible(fuzz_res))

        ffilter = FuzzResFilter(filter_string="r.urlp.path='/path/test.php'")
        self.assertEqual(True, ffilter.is_visible(fuzz_res))

        ffilter = FuzzResFilter(filter_string="r.urlp.ffname='test.php'")
        self.assertEqual(True, ffilter.is_visible(fuzz_res))

        ffilter = FuzzResFilter(filter_string="r.urlp.fext='.php'")
        self.assertEqual(True, ffilter.is_visible(fuzz_res))

        ffilter = FuzzResFilter(filter_string="r.urlp.fname='test'")
        self.assertEqual(True, ffilter.is_visible(fuzz_res))

        ffilter = FuzzResFilter(filter_string="r.urlp.hasquery")
        self.assertEqual(True, ffilter.is_visible(fuzz_res))

        ffilter = FuzzResFilter(filter_string="not r.urlp.isbllist")
        self.assertEqual(True, ffilter.is_visible(fuzz_res))
Example #5
0
    def test_cache_key_json_header_after(self):
        fr = FuzzRequest()
        fr.headers.request = {'Content-Type': 'application/json'}
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = '1'

        self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-p1')
Example #6
0
    def test_setgetdata(self):
        fr = FuzzRequest()

        fr.url = "http://www.wfuzz.org/"
        fr.params.get = {'a': '1'}
        self.assertEqual(fr.method, "GET")
        self.assertEqual(fr.params.get, {'a': '1'})
Example #7
0
    def test_from_conn(self):
        fr = FuzzRequest()
        fr.update_from_raw_http(raw_req, 'https', raw_response_header,
                                raw_response_body)

        self.assertEqual(fr.code, 404)
        self.assertEqual(fr.content.count("\n"), 11)
Example #8
0
    def test_setgetdata(self):
        fr = FuzzRequest()

        fr.url = "http://www.wfuzz.org/"
        fr.params.get = {'a': '1'}
        self.assertEqual(fr.method, "GET")
        self.assertEqual(fr.params.get, {'a': '1'})
Example #9
0
    def test_parse_raw_multi_response(self):
        fr = FuzzRequest()
        fr.update_from_raw_http(http_multi_request, "https",
                                http_follow_response)

        self.assertEqual(fr.content, "LINE_1")
        self.assertEqual(fr.code, 200)
Example #10
0
    def test_parse_multi_raw_request(self):
        fr = FuzzRequest()
        fr.update_from_raw_http(http_multi_request, "https", http_response)

        self.assertEqual(fr.params.post.id, "561358470665569")
        self.assertEqual(fr.params.post.rqm, "SB")
        self.assertEqual(fr.content, "LINE_1")
Example #11
0
    def parse_burp_log(self, burp_log):
        burp_file = None

        try:
            burp_file = open(self.find_file(burp_log), 'rb')

            history = 'START'

            rl = burp_file.readline()
            while rl != "":
                if history == "START":
                    if rl == DELIMITER:
                        history = "HEADER"
                elif history == "HEADER":
                    if rl == DELIMITER:
                        raw_request = ""
                        history = "REQUEST"
                    else:
                        matched = HEADER.match(rl)
                        ctime, host, ip_address = matched.group(1, 3, 5)
                elif history == "REQUEST":
                    if rl == DELIMITER:
                        history = "DELIM1"
                    else:
                        raw_request += rl
                elif history == "DELIM1":
                    if rl == CRLF:
                        raw_response = ""
                        history = "DELIM3"
                    else:
                        raw_response = rl
                        history = "RESPONSE"
                elif history == "RESPONSE":
                    if rl == DELIMITER:
                        history = "DELIM2"
                    else:
                        raw_response += rl
                elif history == "DELIM2":
                    if rl == CRLF:
                        history = "DELIM3"
                elif history == "DELIM3":
                    if rl == CRLF:
                        history = "DELIM4"
                elif history == "DELIM4":
                    if rl == CRLF:
                        fr = FuzzRequest()
                        fr.update_from_raw_http(raw_request,
                                                host[:host.find("://")],
                                                raw_response)
                        frr = FuzzResult(history=fr)

                        yield frr.update()

                        history = "START"

                rl = burp_file.readline()

        except IOError, e:
            raise FuzzExceptBadFile("Error opening burp log file. %s" % str(e))
Example #12
0
    def test_lwh(self):
        fr = FuzzRequest()
        fr.update_from_raw_http(raw_req, "http", raw_resp, b"Some line\n and words\nasdsdas")

        fuzz_res = FuzzResult(history=fr)

        ffilter = FuzzResFilter(filter_string="h=28 or w=6 or l=2")
        ffilter.is_visible(fuzz_res)
        self.assertEqual(True, ffilter.is_visible(fuzz_res))
Example #13
0
    def test_location(self):
        fr = FuzzRequest()
        fr.update_from_raw_http(raw_req, "http", raw_resp, b"Some line\n and words\nasdsdas")

        fuzz_res = FuzzResult(history=fr)

        ffilter = FuzzResFilter(filter_string="r.headers.response.Location")
        ffilter.is_visible(fuzz_res)
        self.assertEqual('https://wfuzz.readthedocs.io/en/latest/', ffilter.is_visible(fuzz_res))
Example #14
0
    def test_params_set_no_value(self):
        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/path?param"

        fuzz_res = FuzzResult(history=fr)

        ffilter = FuzzResFilter(filter_string="r.params.all=+'test'")
        ffilter.is_visible(fuzz_res)
        self.assertEqual(fuzz_res.history.params.get, {'param': None})
Example #15
0
    def get_filtered_fuzzrequest(self, filter_str):
        fr = FuzzRequest()
        fr.update_from_raw_http(raw_req, "http", raw_resp, b"")

        fuzz_res = FuzzResult(history=fr)

        ffilter = FuzzResFilter(filter_string=filter_str)
        ffilter.is_visible(fuzz_res)

        return fuzz_res
Example #16
0
    def test_ispath(self):
        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/path?param=1&param2=2"
        fuzz_res = FuzzResult(history=fr)

        ffilter = FuzzResFilter(filter_string="r.is_path")
        self.assertEqual(False, ffilter.is_visible(fuzz_res))

        ffilter = FuzzResFilter(filter_string="r.pstrip")
        self.assertEqual(ffilter.is_visible(fuzz_res), "http://www.wfuzz.org/path-gparam-gparam2")
Example #17
0
            def __init__(self, description, show_field):
                fr = FuzzRequest()
                fr.url = "http://www.wfuzz.org/path?param=1&param2=2"
                fuzz_res = FuzzResult(history=fr)
                fuzz_res._description = description
                fuzz_res._show_field = show_field

                self.outfile = BytesIO()

                with gzip.GzipFile(fileobj=self.outfile, mode="wb") as f:
                    pickle.dump(fuzz_res, f)

                self.outfile.seek(0)
                self.outfile.name = "mockfile"
Example #18
0
    def test_get_vars(self):
        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/?a&b=1"
        self.assertEqual(fr.params.get, {'a': None, 'b': '1'})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/?"
        self.assertEqual(fr.params.get, {})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        self.assertEqual(fr.params.get, {})
Example #19
0
    def test_url_set(self):
        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/path?param=1&param2=2"

        fuzz_res = FuzzResult(history=fr)

        ffilter = FuzzResFilter(filter_string="r.url=+'test'")
        ffilter.is_visible(fuzz_res)
        self.assertEqual(fuzz_res.history.url, "http://www.wfuzz.org/path?param=1&param2=2test")

        ffilter = FuzzResFilter(filter_string="r.url:='test'")
        ffilter.is_visible(fuzz_res)
        self.assertEqual(fuzz_res.history.url, "http://test/")

        ffilter = FuzzResFilter(filter_string="r.url=-'test'")
        ffilter.is_visible(fuzz_res)
        self.assertEqual(fuzz_res.history.url, "testhttp://test/")
Example #20
0
    def burp_to_xml(self, filename):
        '''Unzip Burp's file, remove non-printable characters, CDATA any HTML,
            include a valid XML header and trailer, and return a valid XML string.'''

        z = zipfile.ZipFile(self.find_file(filename))  # Open Burp's zip file
        burp = z.read('burp', 'rb')  # Read-in the main burp file
        m = TAG.match(burp, 0)  # Match a tag at the start of the string
        while m:
            index = m.end()
            etag = m.group().replace('<', '</')  # Matching tag

            m = TAG.match(burp, index)  # Attempt to get the next tag
            if not m:  # Data folows
                # Read the type of data using Burp's binary data headers
                value, length = self.burp_binary_field(burp, index)
                if value is None:
                    break

                index += length + len(etag)  # Point our index to the next tag
                m = TAG.match(burp, index)  # And retrieve it

                if self.params[
                        "checkversion"] and etag == "</version>" and value not in [
                            "65", "67"
                        ]:
                    raise FuzzExceptBadFile("Unknown burp log version %s" %
                                            value)

                if etag == "</https>":
                    https_tag = value == "True"

                if etag in self.request_tags:
                    raw_request = self.strip_cdata(value)

                if etag in self.response_tags:
                    fr = FuzzRequest()
                    fr.update_from_raw_http(
                        raw_request, "http" if not https_tag else "https",
                        self.strip_cdata(value))
                    frr = FuzzResult(history=fr)

                    raw_request = ""
                    https_tag = ""

                    yield frr.update()
Example #21
0
    def test_nonexisting(self):
        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/path?param=1&param2=2"

        fuzz_res = FuzzResult(history=fr)

        with self.assertRaises(Exception) as context:
            ffilter = FuzzResFilter(filter_string="url=-'test'")
            ffilter.is_visible(fuzz_res)
            self.assertTrue("rsetattr: Can't set" in str(context.exception))

        with self.assertRaises(Exception) as context:
            ffilter = FuzzResFilter(filter_string="notthere=-'test'")
            ffilter.is_visible(fuzz_res)
            self.assertTrue("rgetattr: Can't get" in str(context.exception))

        with self.assertRaises(Exception) as context:
            ffilter = FuzzResFilter(filter_string="r.params.get.notthere=-'test'")
            ffilter.is_visible(fuzz_res)
            self.assertTrue("DotDict: Non-existing field" in str(context.exception))
Example #22
0
    def test_seturl(self):
        fr = FuzzRequest()

        fr.url = "http://www.wfuzz.org/"
        self.assertEqual(fr.url, "http://www.wfuzz.org/")
        self.assertEqual(fr.host, "www.wfuzz.org")
        self.assertEqual(fr.redirect_url, "http://www.wfuzz.org/")
        self.assertEqual(fr.scheme, "http")
        self.assertEqual(fr.path, "/")
        self.assertEqual(fr.follow, False)

        fr.url = "http://www.wfuzz.org"
        self.assertEqual(fr.url, "http://www.wfuzz.org/")

        fr.url = "www.wfuzz.org"
        self.assertEqual(fr.url, "http://www.wfuzz.org/")

        fr.url = "FUZZ://www.wfuzz.org/"
        self.assertEqual(fr.url, "FUZZ://www.wfuzz.org/")
        self.assertEqual(fr.scheme, "FUZZ")

        fr.url = "http://www.wfuzz.org/FUZZ"
        self.assertEqual(fr.url, "http://www.wfuzz.org/FUZZ")

        fr.url = "http://www.wfuzz.org/a"
        self.assertEqual(fr.url, "http://www.wfuzz.org/a")
        self.assertEqual(fr.path, "/a")

        fr.url = "http://www.wfuzz.org/a"
        self.assertEqual(sorted(str(fr).split("\n")), sorted(raw_req.split("\n")))

        fr.auth = ('basic', 'admin:admin')
        self.assertEqual(fr.auth, ('basic', 'admin:admin'))

        fr.url = "FUZZ"
        self.assertEqual(fr.url, "FUZZ")
        self.assertEqual(fr.host, "")
        self.assertEqual(fr.redirect_url, "FUZZ")
        self.assertEqual(fr.scheme, "")
        self.assertEqual(fr.path, "FUZZ")
        self.assertEqual(fr.follow, False)
Example #23
0
    def burp_to_xml(self, filename):
        '''Unzip Burp's file, remove non-printable characters, CDATA any HTML,
        include a valid XML header and trailer, and return a valid XML string.'''

        z = zipfile.ZipFile(self.find_file(filename))  # Open Burp's zip file
        burp = z.read('burp', 'rb')  # Read-in the main burp file
        m = TAG.match(burp, 0)  # Match a tag at the start of the string
        while m:
            index = m.end()
            etag = m.group().replace('<', '</')  # Matching tag

            m = TAG.match(burp, index)  # Attempt to get the next tag
            if not m:  # Data folows
                # Read the type of data using Burp's binary data headers
                value, length = self.burp_binary_field(burp, index)
                if value is None:
                    break

                index += length + len(etag)  # Point our index to the next tag
                m = TAG.match(burp, index)  # And retrieve it

                if self.params["checkversion"] and etag == "</version>" and value not in ["65", "67"]:
                    raise FuzzExceptBadFile("Unknown burp log version %s" % value)

                if etag == "</https>":
                    https_tag = value == "True"

                if etag in self.request_tags:
                    raw_request = self.strip_cdata(value)

                if etag in self.response_tags:
                    fr = FuzzRequest()
                    fr.update_from_raw_http(raw_request, "http" if not https_tag else "https", self.strip_cdata(value))
                    frr = FuzzResult(history=fr)

                    raw_request = ""
                    https_tag = ""

                    yield frr.update()
Example #24
0
    def test_empy_post(self):
        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = ''
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {'': None})
        self.assertEqual(fr.params.raw_post, '')

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = {}
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {})
        self.assertEqual(fr.params.raw_post, '')

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = None
        self.assertEqual(fr.method, "GET")
        self.assertEqual(fr.params.post, {})
        self.assertEqual(fr.params.raw_post, None)
Example #25
0
    def test_allvars(self):
        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.get = {'a': '1', 'b': '2'}
        fr.wf_allvars = "allvars"
        self.assertEqual(fr.wf_allvars_set, {'a': '1', 'b': '2'})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = {'a': '1', 'b': '2'}
        fr.wf_allvars = "allpost"
        self.assertEqual(fr.wf_allvars_set, {'a': '1', 'b': '2'})

        default_headers = dict([
            ('Content-Type', 'application/x-www-form-urlencoded'),
            ('User-Agent', 'Wfuzz/{}'.format(wfuzz_version)),
            ('Host', 'www.wfuzz.org')
        ])

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.wf_allvars = "allheaders"
        self.assertEqual(fr.wf_allvars_set, default_headers)
Example #26
0
    def _gen_wfuzz(self, output_fn):
        try:

            with open(self.find_file(output_fn), 'r') as f:
                for url1, port1, schema1, req1, resp1, url2, port2, schema2, req2, resp2, url3, port3, schema3, req3, resp3, res1, res2 in map(
                        lambda x: re.split(r'\t+', x), f.readlines()):
                    raw_req1 = base64.decodestring(req2)
                    raw_res1 = base64.decodestring(res2)

                    item = FuzzResult()
                    item.history = FuzzRequest()
                    item.history.update_from_raw_http(raw_req1, schema1)

                    item.type = FuzzResult.result

                    yield item
        except IOError, e:
            raise FuzzExceptBadFile("Error opening wfuzz payload file. %s" %
                                    str(e))
Example #27
0
    def test_setpostdata_with_json(self):
        fr = FuzzRequest()
        fr.headers.request = {'Content-Type': 'application/json'}
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = '{"string": "Foo bar","boolean": false}'
        self.assertEqual(fr.params.post, {
            'string': 'Foo bar',
            'boolean': False
        })

        fr = FuzzRequest()
        fr.headers.request = {'Content-Type': 'application/json'}
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = '{"array": [1,2]}'
        self.assertEqual(fr.params.post, {'array': [1, 2]})
Example #28
0
    def test_post_bad_json(self):
        fr = FuzzRequest()
        fr.headers.request = {'Content-Type': 'application/json'}
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = '1'

        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {'1': None})
        self.assertEqual(fr.params.raw_post, '1')

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.headers.request = {'Content-Type': 'application/json'}
        fr.params.post = 'a=1'
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.raw_post, "a=1")
        self.assertEqual(fr.params.post, {'a': '1'})
Example #29
0
    def test_parse_get_crlf_request(self):
        fr = FuzzRequest()
        fr.update_from_raw_http(http_get_request, "https", "\n\n\n")

        self.assertEqual(fr.method, "GET")
        self.assertEqual(fr.params.raw_post, None)
Example #30
0
    def test_setpostdata(self):
        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = 'a=1'
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {'a': '1'})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = '1'
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {'1': None})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = ''
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {'': None})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = {}
        self.assertEqual(fr.method, "GET")
        self.assertEqual(fr.params.post, {})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = {'a': 1}
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {'a': '1'})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = {'a': '1'}
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {'a': '1'})
Example #31
0
    def test_seturl(self):
        fr = FuzzRequest()

        fr.url = "http://www.wfuzz.org/"
        self.assertEqual(fr.url, "http://www.wfuzz.org/")
        self.assertEqual(fr.host, "www.wfuzz.org")
        self.assertEqual(fr.redirect_url, "http://www.wfuzz.org/")
        self.assertEqual(fr.scheme, "http")
        self.assertEqual(fr.path, "/")
        self.assertEqual(fr.follow, False)

        fr.url = "http://www.wfuzz.org"
        self.assertEqual(fr.url, "http://www.wfuzz.org/")

        fr.url = "www.wfuzz.org"
        self.assertEqual(fr.url, "http://www.wfuzz.org/")

        fr.url = "FUZZ://www.wfuzz.org/"
        self.assertEqual(fr.url, "FUZZ://www.wfuzz.org/")
        self.assertEqual(fr.scheme, "FUZZ")

        fr.url = "http://www.wfuzz.org/FUZZ"
        self.assertEqual(fr.url, "http://www.wfuzz.org/FUZZ")

        fr.url = "http://www.wfuzz.org/a"
        self.assertEqual(fr.url, "http://www.wfuzz.org/a")
        self.assertEqual(fr.path, "/a")

        fr.url = "http://www.wfuzz.org/a"
        self.assertEqual(sorted(str(fr).split("\n")),
                         sorted(raw_req.split("\n")))

        fr.auth = ('basic', 'admin:admin')
        self.assertEqual(fr.auth, ('basic', 'admin:admin'))

        fr.url = "FUZZ"
        self.assertEqual(fr.url, "FUZZ")
        self.assertEqual(fr.host, "")
        self.assertEqual(fr.redirect_url, "FUZZ")
        self.assertEqual(fr.scheme, "")
        self.assertEqual(fr.path, "FUZZ")
        self.assertEqual(fr.follow, False)
Example #32
0
    def test_cache_key(self):
        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-')

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.get = {'a': '1', 'b': '2'}
        self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-ga-gb')

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = {'c': '1', 'd': '2'}
        self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-pc-pd')

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.get = {'a': '1', 'b': '2'}
        fr.params.post = {'c': '1', 'd': '2'}
        self.assertEqual(fr.to_cache_key(),
                         'http://www.wfuzz.org/-ga-gb-pc-pd')

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.get = {'a': '1', 'b': '2'}
        fr.params.post = {'a': '1', 'b': '2'}
        self.assertEqual(fr.to_cache_key(),
                         'http://www.wfuzz.org/-ga-gb-pa-pb')

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = '1'
        self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-p1')

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = ''
        self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-p')
Example #33
0
    def test_allvars(self):
        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.get = {'a': '1', 'b': '2'}
        fr.wf_allvars = "allvars"
        self.assertEqual(fr.wf_allvars_set, {'a': '1', 'b': '2'})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = {'a': '1', 'b': '2'}
        fr.wf_allvars = "allpost"
        self.assertEqual(fr.wf_allvars_set, {'a': '1', 'b': '2'})

        default_headers = dict([
            ('Content-Type', 'application/x-www-form-urlencoded'),
            ('User-Agent', 'Wfuzz/{}'.format(wfuzz_version)),
            ('Host', 'www.wfuzz.org')
        ])

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.wf_allvars = "allheaders"
        self.assertEqual(fr.wf_allvars_set, default_headers)
Example #34
0
    def test_setpostdata(self):
        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = 'a=1'
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {'a': '1'})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = '1'
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {'1': None})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = ''
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {'': None})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = {}
        self.assertEqual(fr.method, "GET")
        self.assertEqual(fr.params.post, {})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = {'a': 1}
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {'a': '1'})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = {'a': '1'}
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {'a': '1'})
    def test_setpostdata(self):
        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = 'a=1'
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {'a': '1'})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = '1'
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {'1': None})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = ''
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {'': None})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = {}
        self.assertEqual(fr.method, "GET")
        self.assertEqual(fr.params.post, {})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = {'a': 1}
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {'a': '1'})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = {'a': '1'}
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {'a': '1'})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = "{'a': '1'}"
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {"{'a': '1'}": None})

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = '1'
        fr.headers.request = {'Content-Type': 'application/json'}
        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {'1': None})
Example #36
0
    def test_2_ways_of_parsing_content(self):
        fr = FuzzRequest()
        fr.update_from_raw_http(http_multi_request, "https", http_response)

        fr2 = FuzzRequest()
        fr2.update_from_raw_http(http_multi_request, "https",
                                 http_response_no_content, b"LINE_1")

        # raw content takes precedence
        fr3 = FuzzRequest()
        fr3.update_from_raw_http(http_multi_request, "https", http_response,
                                 b"LINE_0")

        self.assertEqual(fr.content, fr2.content)
        self.assertEqual(fr3.content, "LINE_0")
Example #37
0
    def test_parse_crlf_post_request(self):
        fr = FuzzRequest()
        fr.update_from_raw_http(http_post_request, "https", "\n\n\n")

        self.assertEqual(fr.method, "POST")
        self.assertEqual(fr.params.post, {'a': '1'})
Example #38
0
    def test_cache_key_get_var(self):
        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/?a&b=1"

        self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-ga-gb')
Example #39
0
    def test_cache_key(self):
        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-')

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.get = {'a': '1', 'b': '2'}
        self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-ga-gb')

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = {'c': '1', 'd': '2'}
        self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-pc-pd')

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.get = {'a': '1', 'b': '2'}
        fr.params.post = {'c': '1', 'd': '2'}
        self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-ga-gb-pc-pd')

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.get = {'a': '1', 'b': '2'}
        fr.params.post = {'a': '1', 'b': '2'}
        self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-ga-gb-pa-pb')

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = '1'
        self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-p1')

        fr = FuzzRequest()
        fr.url = "http://www.wfuzz.org/"
        fr.params.post = ''
        self.assertEqual(fr.to_cache_key(), 'http://www.wfuzz.org/-p')
Example #40
0
    def test_from_conn(self):
        fr = FuzzRequest()
        fr.update_from_raw_http(raw_req, 'https', raw_response_header, raw_response_body)

        self.assertEqual(fr.code, 404)
        self.assertEqual(fr.content.count("\n"), 11)