mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-02-16 19:40:37 +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
|
See the file 'doc/COPYING' for copying permission
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
class sqlmapCompressionException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
class sqlmapConnectionException(Exception):
|
class sqlmapConnectionException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -60,6 +63,7 @@ class sqlmapValueException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
exceptionsTuple = (
|
exceptionsTuple = (
|
||||||
|
sqlmapCompressionException,
|
||||||
sqlmapConnectionException,
|
sqlmapConnectionException,
|
||||||
sqlmapDataException,
|
sqlmapDataException,
|
||||||
sqlmapFilePathException,
|
sqlmapFilePathException,
|
||||||
|
|
|
@ -1513,6 +1513,7 @@ def __setKnowledgeBaseAttributes(flushAll=True):
|
||||||
kb.multiThreadMode = False
|
kb.multiThreadMode = False
|
||||||
kb.negativeLogic = False
|
kb.negativeLogic = False
|
||||||
kb.nullConnection = None
|
kb.nullConnection = None
|
||||||
|
kb.pageCompress = True
|
||||||
kb.pageTemplate = None
|
kb.pageTemplate = None
|
||||||
kb.pageTemplates = dict()
|
kb.pageTemplates = dict()
|
||||||
kb.previousMethod = None
|
kb.previousMethod = None
|
||||||
|
|
|
@ -18,11 +18,13 @@ from lib.core.common import getUnicode
|
||||||
from lib.core.common import readInput
|
from lib.core.common import readInput
|
||||||
from lib.core.common import resetCookieJar
|
from lib.core.common import resetCookieJar
|
||||||
from lib.core.common import singleTimeLogMessage
|
from lib.core.common import singleTimeLogMessage
|
||||||
|
from lib.core.common import singleTimeWarnMessage
|
||||||
from lib.core.data import conf
|
from lib.core.data import conf
|
||||||
from lib.core.data import kb
|
from lib.core.data import kb
|
||||||
from lib.core.data import logger
|
from lib.core.data import logger
|
||||||
from lib.core.enums import HTTPHEADER
|
from lib.core.enums import HTTPHEADER
|
||||||
from lib.core.enums import PLACE
|
from lib.core.enums import PLACE
|
||||||
|
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 ML
|
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"):
|
if isinstance(contentEncoding, basestring) and contentEncoding.lower() in ("gzip", "x-gzip", "deflate"):
|
||||||
try:
|
try:
|
||||||
if contentEncoding == "deflate":
|
if contentEncoding.lower() == "deflate":
|
||||||
# http://stackoverflow.com/questions/1089662/python-inflate-and-deflate-implementations
|
# http://stackoverflow.com/questions/1089662/python-inflate-and-deflate-implementations
|
||||||
data = StringIO.StringIO(zlib.decompress(page, -15))
|
data = StringIO.StringIO(zlib.decompress(page, -15))
|
||||||
else:
|
else:
|
||||||
|
@ -192,7 +194,12 @@ def decodePage(page, contentEncoding, contentType):
|
||||||
errMsg = "detected invalid data for declared content "
|
errMsg = "detected invalid data for declared content "
|
||||||
errMsg += "encoding '%s' ('%s')" % (contentEncoding, msg)
|
errMsg += "encoding '%s' ('%s')" % (contentEncoding, msg)
|
||||||
singleTimeLogMessage(errMsg, logging.ERROR)
|
singleTimeLogMessage(errMsg, logging.ERROR)
|
||||||
return page
|
|
||||||
|
warnMsg = "turning off page compression"
|
||||||
|
singleTimeWarnMessage(warnMsg)
|
||||||
|
|
||||||
|
kb.pageCompress = False
|
||||||
|
raise sqlmapCompressionException
|
||||||
|
|
||||||
if not conf.charset:
|
if not conf.charset:
|
||||||
httpCharset, metaCharset = None, None
|
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 PAYLOAD
|
||||||
from lib.core.enums import PLACE
|
from lib.core.enums import PLACE
|
||||||
from lib.core.enums import REDIRECTION
|
from lib.core.enums import REDIRECTION
|
||||||
|
from lib.core.exception import sqlmapCompressionException
|
||||||
from lib.core.exception import sqlmapConnectionException
|
from lib.core.exception import sqlmapConnectionException
|
||||||
from lib.core.exception import sqlmapSyntaxException
|
from lib.core.exception import sqlmapSyntaxException
|
||||||
from lib.core.settings import CUSTOM_INJECTION_MARK_CHAR
|
from lib.core.settings import CUSTOM_INJECTION_MARK_CHAR
|
||||||
|
@ -108,7 +109,7 @@ class Connect:
|
||||||
warnMsg += "(e.g. https://help.ubuntu.com/community/Tor)"
|
warnMsg += "(e.g. https://help.ubuntu.com/community/Tor)"
|
||||||
else:
|
else:
|
||||||
warnMsg = "if the problem persists please check that the provided "
|
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 += "with the switch '--random-agent' turned on "
|
||||||
warnMsg += "and/or proxy switches (--ignore-proxy, --proxy,...)"
|
warnMsg += "and/or proxy switches (--ignore-proxy, --proxy,...)"
|
||||||
singleTimeWarnMessage(warnMsg)
|
singleTimeWarnMessage(warnMsg)
|
||||||
|
@ -279,7 +280,7 @@ class Connect:
|
||||||
headers[HTTPHEADER.PROXY_AUTHORIZATION] = kb.proxyAuthHeader
|
headers[HTTPHEADER.PROXY_AUTHORIZATION] = kb.proxyAuthHeader
|
||||||
|
|
||||||
headers[HTTPHEADER.ACCEPT] = HTTP_ACCEPT_HEADER_VALUE
|
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)
|
headers[HTTPHEADER.HOST] = host or getHostHeader(url)
|
||||||
|
|
||||||
if auxHeaders:
|
if auxHeaders:
|
||||||
|
@ -467,7 +468,7 @@ class Connect:
|
||||||
debugMsg = "got HTTP error code: %d (%s)" % (code, status)
|
debugMsg = "got HTTP error code: %d (%s)" % (code, status)
|
||||||
logger.debug(debugMsg)
|
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()
|
tbMsg = traceback.format_exc()
|
||||||
|
|
||||||
if "no host given" in tbMsg:
|
if "no host given" in tbMsg:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user