mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-02-10 08:30:36 +03:00
Implementation for an Issue #183
This commit is contained in:
parent
a64438fb5c
commit
e570858db9
|
@ -10,6 +10,7 @@ import gzip
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import StringIO
|
import StringIO
|
||||||
|
import struct
|
||||||
import zlib
|
import zlib
|
||||||
|
|
||||||
from lib.core.common import extractErrorMessage
|
from lib.core.common import extractErrorMessage
|
||||||
|
@ -27,6 +28,7 @@ from lib.core.enums import PLACE
|
||||||
from lib.core.exception import sqlmapCompressionException
|
from lib.core.exception import sqlmapCompressionException
|
||||||
from lib.core.htmlentities import htmlEntities
|
from lib.core.htmlentities import htmlEntities
|
||||||
from lib.core.settings import DEFAULT_COOKIE_DELIMITER
|
from lib.core.settings import DEFAULT_COOKIE_DELIMITER
|
||||||
|
from lib.core.settings import MAX_CONNECTION_TOTAL_SIZE
|
||||||
from lib.core.settings import ML
|
from lib.core.settings import ML
|
||||||
from lib.core.settings import META_CHARSET_REGEX
|
from lib.core.settings import META_CHARSET_REGEX
|
||||||
from lib.core.settings import PARSE_HEADERS_LIMIT
|
from lib.core.settings import PARSE_HEADERS_LIMIT
|
||||||
|
@ -182,12 +184,17 @@ def decodePage(page, contentEncoding, contentType):
|
||||||
return getUnicode(page)
|
return getUnicode(page)
|
||||||
|
|
||||||
if isinstance(contentEncoding, basestring) and contentEncoding.lower() in ("gzip", "x-gzip", "deflate"):
|
if isinstance(contentEncoding, basestring) and contentEncoding.lower() in ("gzip", "x-gzip", "deflate"):
|
||||||
|
if not kb.pageCompress:
|
||||||
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if contentEncoding.lower() == "deflate":
|
if contentEncoding.lower() == "deflate":
|
||||||
# http://stackoverflow.com/questions/1089662/python-inflate-and-deflate-implementations
|
data = StringIO.StringIO(zlib.decompress(page, -15)) # Reference: http://stackoverflow.com/questions/1089662/python-inflate-and-deflate-implementations
|
||||||
data = StringIO.StringIO(zlib.decompress(page, -15))
|
|
||||||
else:
|
else:
|
||||||
data = gzip.GzipFile("", "rb", 9, StringIO.StringIO(page))
|
data = gzip.GzipFile("", "rb", 9, StringIO.StringIO(page))
|
||||||
|
size = struct.unpack("<l", page[-4:])[0] # Reference: http://pydoc.org/get.cgi/usr/local/lib/python2.5/gzip.py
|
||||||
|
if size > MAX_CONNECTION_TOTAL_SIZE:
|
||||||
|
raise Exception, "size too large"
|
||||||
|
|
||||||
page = data.read()
|
page = data.read()
|
||||||
except Exception, msg:
|
except Exception, msg:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user