mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-02-17 03:50:42 +03:00
added null connection check
This commit is contained in:
parent
ecd6b573f7
commit
b745331974
|
@ -437,6 +437,29 @@ def checkRegexp():
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def checkNullConnection():
|
||||||
|
infoMsg = "testing NULL connection to the target url"
|
||||||
|
logger.info(infoMsg)
|
||||||
|
|
||||||
|
try:
|
||||||
|
page, headers = Request.getPage(method="HEAD")
|
||||||
|
if not page and 'Content-Length' in headers:
|
||||||
|
kb.nullConnection = "HEAD"
|
||||||
|
else:
|
||||||
|
page, headers = Request.getPage(auxHeaders={"Range":"bytes=-1"})
|
||||||
|
if page and len(page) == 1 and 'Content-Range' in headers:
|
||||||
|
kb.nullConnection = "Range"
|
||||||
|
|
||||||
|
except sqlmapConnectionException, errMsg:
|
||||||
|
errMsg = getUnicode(errMsg)
|
||||||
|
raise sqlmapConnectionException, errMsg
|
||||||
|
|
||||||
|
if kb.nullConnection:
|
||||||
|
infoMsg = "method '%s' seems to be working" % kb.nullConnection
|
||||||
|
logger.info(infoMsg)
|
||||||
|
|
||||||
|
return kb.nullConnection is not None
|
||||||
|
|
||||||
def checkConnection():
|
def checkConnection():
|
||||||
try:
|
try:
|
||||||
socket.gethostbyname(conf.hostname)
|
socket.gethostbyname(conf.hostname)
|
||||||
|
|
|
@ -29,6 +29,7 @@ from lib.controller.checks import checkStability
|
||||||
from lib.controller.checks import checkString
|
from lib.controller.checks import checkString
|
||||||
from lib.controller.checks import checkRegexp
|
from lib.controller.checks import checkRegexp
|
||||||
from lib.controller.checks import checkConnection
|
from lib.controller.checks import checkConnection
|
||||||
|
from lib.controller.checks import checkNullConnection
|
||||||
from lib.core.common import getUnicode
|
from lib.core.common import getUnicode
|
||||||
from lib.core.common import paramToDict
|
from lib.core.common import paramToDict
|
||||||
from lib.core.common import parseTargetUrl
|
from lib.core.common import parseTargetUrl
|
||||||
|
@ -165,6 +166,8 @@ def start():
|
||||||
if not checkConnection() or not checkString() or not checkRegexp():
|
if not checkConnection() or not checkString() or not checkRegexp():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
checkNullConnection()
|
||||||
|
|
||||||
if not conf.dropSetCookie:
|
if not conf.dropSetCookie:
|
||||||
for _, cookie in enumerate(conf.cj):
|
for _, cookie in enumerate(conf.cj):
|
||||||
cookie = getUnicode(cookie)
|
cookie = getUnicode(cookie)
|
||||||
|
|
|
@ -1010,6 +1010,7 @@ def __setKnowledgeBaseAttributes():
|
||||||
kb.injPlace = None
|
kb.injPlace = None
|
||||||
kb.injType = None
|
kb.injType = None
|
||||||
kb.hintValue = None
|
kb.hintValue = None
|
||||||
|
kb.nullConnection = None
|
||||||
|
|
||||||
# Back-end DBMS underlying operating system fingerprint via banner (-b)
|
# Back-end DBMS underlying operating system fingerprint via banner (-b)
|
||||||
# parsing
|
# parsing
|
||||||
|
|
|
@ -69,16 +69,17 @@ class Connect:
|
||||||
delay = 0.00001 * (conf.cpuThrottle ** 2)
|
delay = 0.00001 * (conf.cpuThrottle ** 2)
|
||||||
time.sleep(delay)
|
time.sleep(delay)
|
||||||
|
|
||||||
url = kwargs.get('url', conf.url).replace(" ", "%20")
|
url = kwargs.get('url', conf.url).replace(" ", "%20")
|
||||||
get = kwargs.get('get', None)
|
get = kwargs.get('get', None)
|
||||||
post = kwargs.get('post', None)
|
post = kwargs.get('post', None)
|
||||||
method = kwargs.get('method', None)
|
method = kwargs.get('method', None)
|
||||||
cookie = kwargs.get('cookie', None)
|
cookie = kwargs.get('cookie', None)
|
||||||
ua = kwargs.get('ua', None)
|
ua = kwargs.get('ua', None)
|
||||||
direct = kwargs.get('direct', False)
|
direct = kwargs.get('direct', False)
|
||||||
multipart = kwargs.get('multipart', False)
|
multipart = kwargs.get('multipart', False)
|
||||||
silent = kwargs.get('silent', False)
|
silent = kwargs.get('silent', False)
|
||||||
raise404 = kwargs.get('raise404', True)
|
raise404 = kwargs.get('raise404', True)
|
||||||
|
auxHeaders = kwargs.get('auxHeaders', None)
|
||||||
|
|
||||||
page = ""
|
page = ""
|
||||||
cookieStr = ""
|
cookieStr = ""
|
||||||
|
@ -130,6 +131,10 @@ class Connect:
|
||||||
# Perform HTTP request
|
# Perform HTTP request
|
||||||
headers = forgeHeaders(cookie, ua)
|
headers = forgeHeaders(cookie, ua)
|
||||||
|
|
||||||
|
if auxHeaders:
|
||||||
|
for key, item in auxHeaders.items():
|
||||||
|
headers[key] = item
|
||||||
|
|
||||||
if method:
|
if method:
|
||||||
req = MethodRequest(url, post, headers)
|
req = MethodRequest(url, post, headers)
|
||||||
req.set_method(method)
|
req.set_method(method)
|
||||||
|
@ -272,7 +277,7 @@ class Connect:
|
||||||
return page, responseHeaders
|
return page, responseHeaders
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def queryPage(value=None, place=None, content=False, getSeqMatcher=False, silent=False, method=None):
|
def queryPage(value=None, place=None, content=False, getSeqMatcher=False, silent=False, method=None, auxHeaders=dict()):
|
||||||
"""
|
"""
|
||||||
This method calls a function to get the target url page content
|
This method calls a function to get the target url page content
|
||||||
and returns its page MD5 hash or a boolean value in case of
|
and returns its page MD5 hash or a boolean value in case of
|
||||||
|
@ -305,7 +310,7 @@ class Connect:
|
||||||
if conf.safUrl and conf.saFreq > 0:
|
if conf.safUrl and conf.saFreq > 0:
|
||||||
kb.queryCounter += 1
|
kb.queryCounter += 1
|
||||||
if kb.queryCounter % conf.saFreq == 0:
|
if kb.queryCounter % conf.saFreq == 0:
|
||||||
Connect.getPage(url=conf.safUrl, cookie=cookie, direct=True, silent=True, ua=ua)
|
Connect.getPage(url=conf.safUrl, cookie=cookie, direct=True, silent=True, ua=ua, auxHeaders=auxHeaders)
|
||||||
|
|
||||||
page, headers = Connect.getPage(get=get, post=post, cookie=cookie, ua=ua, silent=silent, method=method)
|
page, headers = Connect.getPage(get=get, post=post, cookie=cookie, ua=ua, silent=silent, method=method)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user