Skip to content

Commit

Permalink
burplog python2/3 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
xmendez committed Apr 24, 2019
1 parent 83c9b9f commit 43553f7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/wfuzz/externals/reqresp/Response.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ def parseResponse(self, rawheader, rawbody=None, type="curl"):
self._headers = []

tp = TextParser()
rawheader = python2_3_convert_from_unicode(rawheader.decode("utf-8", errors='replace'))
tp.setSource("string", rawheader)

tp.readUntil(r"(HTTP\S*) ([0-9]+)")
Expand Down
6 changes: 4 additions & 2 deletions src/wfuzz/fuzzobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from .facade import Facade, ERROR_CODE
from .mixins import FuzzRequestUrlMixing, FuzzRequestSoupMixing

from .utils import python2_3_convert_to_unicode
from .utils import python2_3_convert_to_unicode, python2_3_convert_from_unicode
from .utils import MyCounter
from .utils import rgetattr
from .utils import DotDict
Expand Down Expand Up @@ -323,7 +323,8 @@ def to_http_object(self, c):
return pycurl_c

def from_http_object(self, c, bh, bb):
return self._request.response_from_conn_object(c, bh, bb)
raw_header = python2_3_convert_from_unicode(bh.decode("utf-8", errors='surrogateescape'))
return self._request.response_from_conn_object(c, raw_header, bb)

def update_from_raw_http(self, raw, scheme, raw_response=None, raw_content=None):
self._request.parseRequest(raw, scheme)
Expand All @@ -334,6 +335,7 @@ def update_from_raw_http(self, raw, scheme, raw_response=None, raw_content=None)

if raw_response:
rp = Response()
raw_response = python2_3_convert_from_unicode(raw_response.decode("utf-8", errors='surrogateescape'))
rp.parseResponse(raw_response, raw_content)
self._request.response = rp

Expand Down
8 changes: 6 additions & 2 deletions src/wfuzz/plugins/payloads/burplog.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

import re

CRLF = "\r\n"
import sys
if sys.version_info < (3, 0):
from io import open

CRLF = "\n"
DELIMITER = "%s%s" % ('=' * 54, CRLF)
CRLF_DELIMITER = CRLF + DELIMITER
HEADER = re.compile(r'(\d{1,2}:\d{2}:\d{2} (AM|PM|))[ \t]+(\S+)([ \t]+\[(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|unknown host)\])?')
Expand Down Expand Up @@ -51,7 +55,7 @@ def parse_burp_log(self, burp_log):
burp_file = None

try:
burp_file = open(self.find_file(burp_log), 'rb')
burp_file = open(self.find_file(burp_log), 'r', encoding="utf-8", errors="surrogateescape")

history = 'START'

Expand Down

0 comments on commit 43553f7

Please sign in to comment.