mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-22 09:36:35 +03:00
Update and fix for an Issue #182
This commit is contained in:
parent
10b671d625
commit
511c3b8dcc
|
@ -5,6 +5,9 @@ Copyright (c) 2006-2012 sqlmap developers (http://sqlmap.org/)
|
|||
See the file 'doc/COPYING' for copying permission
|
||||
"""
|
||||
|
||||
class sqlmapCompressionException(Exception):
|
||||
pass
|
||||
|
||||
class sqlmapConnectionException(Exception):
|
||||
pass
|
||||
|
||||
|
@ -60,6 +63,7 @@ class sqlmapValueException(Exception):
|
|||
pass
|
||||
|
||||
exceptionsTuple = (
|
||||
sqlmapCompressionException,
|
||||
sqlmapConnectionException,
|
||||
sqlmapDataException,
|
||||
sqlmapFilePathException,
|
||||
|
|
|
@ -1513,6 +1513,7 @@ def __setKnowledgeBaseAttributes(flushAll=True):
|
|||
kb.multiThreadMode = False
|
||||
kb.negativeLogic = False
|
||||
kb.nullConnection = None
|
||||
kb.pageCompress = True
|
||||
kb.pageTemplate = None
|
||||
kb.pageTemplates = dict()
|
||||
kb.previousMethod = None
|
||||
|
|
|
@ -18,11 +18,13 @@ from lib.core.common import getUnicode
|
|||
from lib.core.common import readInput
|
||||
from lib.core.common import resetCookieJar
|
||||
from lib.core.common import singleTimeLogMessage
|
||||
from lib.core.common import singleTimeWarnMessage
|
||||
from lib.core.data import conf
|
||||
from lib.core.data import kb
|
||||
from lib.core.data import logger
|
||||
from lib.core.enums import HTTPHEADER
|
||||
from lib.core.enums import PLACE
|
||||
from lib.core.exception import sqlmapCompressionException
|
||||
from lib.core.htmlentities import htmlEntities
|
||||
from lib.core.settings import DEFAULT_COOKIE_DELIMITER
|
||||
from lib.core.settings import ML
|
||||
|
@ -181,7 +183,7 @@ def decodePage(page, contentEncoding, contentType):
|
|||
|
||||
if isinstance(contentEncoding, basestring) and contentEncoding.lower() in ("gzip", "x-gzip", "deflate"):
|
||||
try:
|
||||
if contentEncoding == "deflate":
|
||||
if contentEncoding.lower() == "deflate":
|
||||
# http://stackoverflow.com/questions/1089662/python-inflate-and-deflate-implementations
|
||||
data = StringIO.StringIO(zlib.decompress(page, -15))
|
||||
else:
|
||||
|
@ -192,7 +194,12 @@ def decodePage(page, contentEncoding, contentType):
|
|||
errMsg = "detected invalid data for declared content "
|
||||
errMsg += "encoding '%s' ('%s')" % (contentEncoding, msg)
|
||||
singleTimeLogMessage(errMsg, logging.ERROR)
|
||||
return page
|
||||
|
||||
warnMsg = "turning off page compression"
|
||||
singleTimeWarnMessage(warnMsg)
|
||||
|
||||
kb.pageCompress = False
|
||||
raise sqlmapCompressionException
|
||||
|
||||
if not conf.charset:
|
||||
httpCharset, metaCharset = None, None
|
||||
|
|
|
@ -46,6 +46,7 @@ from lib.core.enums import NULLCONNECTION
|
|||
from lib.core.enums import PAYLOAD
|
||||
from lib.core.enums import PLACE
|
||||
from lib.core.enums import REDIRECTION
|
||||
from lib.core.exception import sqlmapCompressionException
|
||||
from lib.core.exception import sqlmapConnectionException
|
||||
from lib.core.exception import sqlmapSyntaxException
|
||||
from lib.core.settings import CUSTOM_INJECTION_MARK_CHAR
|
||||
|
@ -108,7 +109,7 @@ class Connect:
|
|||
warnMsg += "(e.g. https://help.ubuntu.com/community/Tor)"
|
||||
else:
|
||||
warnMsg = "if the problem persists please check that the provided "
|
||||
warnMsg += "target url is valid. If it is, you can try to rerun "
|
||||
warnMsg += "target url is valid. In case that it is, you can try to rerun "
|
||||
warnMsg += "with the switch '--random-agent' turned on "
|
||||
warnMsg += "and/or proxy switches (--ignore-proxy, --proxy,...)"
|
||||
singleTimeWarnMessage(warnMsg)
|
||||
|
@ -279,7 +280,7 @@ class Connect:
|
|||
headers[HTTPHEADER.PROXY_AUTHORIZATION] = kb.proxyAuthHeader
|
||||
|
||||
headers[HTTPHEADER.ACCEPT] = HTTP_ACCEPT_HEADER_VALUE
|
||||
headers[HTTPHEADER.ACCEPT_ENCODING] = HTTP_ACCEPT_ENCODING_HEADER_VALUE if method != HTTPMETHOD.HEAD else "identity"
|
||||
headers[HTTPHEADER.ACCEPT_ENCODING] = HTTP_ACCEPT_ENCODING_HEADER_VALUE if method != HTTPMETHOD.HEAD and kb.pageCompress else "identity"
|
||||
headers[HTTPHEADER.HOST] = host or getHostHeader(url)
|
||||
|
||||
if auxHeaders:
|
||||
|
@ -467,7 +468,7 @@ class Connect:
|
|||
debugMsg = "got HTTP error code: %d (%s)" % (code, status)
|
||||
logger.debug(debugMsg)
|
||||
|
||||
except (urllib2.URLError, socket.error, socket.timeout, httplib.BadStatusLine, httplib.IncompleteRead, ProxyError), e:
|
||||
except (urllib2.URLError, socket.error, socket.timeout, httplib.BadStatusLine, httplib.IncompleteRead, ProxyError, sqlmapCompressionException), e:
|
||||
tbMsg = traceback.format_exc()
|
||||
|
||||
if "no host given" in tbMsg:
|
||||
|
|
Loading…
Reference in New Issue
Block a user