コード例 #1
0
ファイル: burplog.py プロジェクト: digininja/wfuzz
    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()
コード例 #2
0
ファイル: burpstate.py プロジェクト: zkuns5/wfuzz
    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()
コード例 #3
0
ファイル: burpstate.py プロジェクト: xmendez/wfuzz
    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()
コード例 #4
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()