Skip to content

Commit

Permalink
deflate encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
xmendez committed May 26, 2018
1 parent 5ebf50d commit 907f63d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/wfuzz/externals/reqresp/Response.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import string
from io import BytesIO
import gzip
import zlib

from .TextParser import TextParser

Expand Down Expand Up @@ -152,5 +153,20 @@ def parseResponse(self, rawheader, rawbody=None, type="curl"):
gzipper = gzip.GzipFile(fileobj=compressedstream)
rawbody = gzipper.read()
self.delHeader("Content-Encoding")
elif self.header_equal("Content-Encoding", "deflate"):
deflated_data = None
try:
deflater = zlib.decompressobj()
deflated_data = deflater.decompress(rawbody)
deflated_data += deflater.flush()
except zlib.error:
try:
deflater = zlib.decompressobj(-zlib.MAX_WBITS)
deflated_data = deflater.decompress(rawbody)
deflated_data += deflater.flush()
except zlib.error:
deflated_data = ''
rawbody = deflated_data
self.delHeader("Content-Encoding")

self.__content = rawbody.decode('utf-8', errors='replace')
1 change: 1 addition & 0 deletions tests/test_acceptance.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
("test_gzip", "%s/FUZZ" % HTTPBIN_URL, [["gzip"]], dict(filter="content~'\"gzipped\":true'"), [(200, '/gzip')], None),
("test_response_utf8", "%s/encoding/FUZZ" % HTTPBIN_URL, [["utf8"]], dict(), [(200, '/encoding/utf8')], None),
("test_image", "%s/image/FUZZ" % HTTPBIN_URL, [["jpeg"]], dict(filter="content~'JFIF'"), [(200, '/image/jpeg')], None),
("test_deflate", "%s/FUZZ" % HTTPBIN_URL, [["deflate"]], dict(filter="content~'\"deflated\":true'"), [(200, '/deflate')], None),

("test_robots_disallow", "%s/FUZZ" % HTTPBIN_URL, [["robots.txt"]], dict(script="robots"), [(200, '/deny'), (200, '/robots.txt')], None),
("test_response_base64", "%s/base64/FUZZ" % HTTPBIN_URL, None, dict(filter="content~'HTTPBIN is awesome'", payloads=[("list", dict(values="HTTPBIN is awesome", encoder=["base64"]))]), [(200, '/base64/SFRUUEJJTiBpcyBhd2Vzb21l')], None),
Expand Down

0 comments on commit 907f63d

Please sign in to comment.