From 0d0e2a2228ac446d65101d39cc0df7d6c1b87345 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Mon, 8 Nov 2010 09:49:57 +0000 Subject: [PATCH] minor update --- lib/controller/checks.py | 8 +++++--- lib/core/enums.py | 6 +++++- lib/request/connect.py | 9 +++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/controller/checks.py b/lib/controller/checks.py index 214e20a14..0d5437e74 100644 --- a/lib/controller/checks.py +++ b/lib/controller/checks.py @@ -26,6 +26,8 @@ from lib.core.data import conf from lib.core.data import kb from lib.core.data import logger from lib.core.data import paths +from lib.core.enums import HTTPMETHOD +from lib.core.enums import NULLCONNECTION from lib.core.exception import sqlmapConnectionException from lib.core.exception import sqlmapGenericException from lib.core.exception import sqlmapNoneDataException @@ -368,16 +370,16 @@ def checkNullConnection(): logger.info(infoMsg) try: - page, headers = Request.getPage(method="HEAD") + page, headers = Request.getPage(method=HTTPMETHOD.HEAD) if not page and 'Content-Length' in headers: - kb.nullConnection = "HEAD" + kb.nullConnection = NULLCONNECTION.HEAD infoMsg = "NULL connection is supported with HEAD header" logger.info(infoMsg) else: page, headers = Request.getPage(auxHeaders={"Range":"bytes=-1"}) if page and len(page) == 1 and 'Content-Range' in headers: - kb.nullConnection = "Range" + kb.nullConnection = NULLCONNECTION.RANGE infoMsg = "NULL connection is supported with GET header " infoMsg += "'%s'" % kb.nullConnection diff --git a/lib/core/enums.py b/lib/core/enums.py index f68d4d310..32e43429d 100644 --- a/lib/core/enums.py +++ b/lib/core/enums.py @@ -37,4 +37,8 @@ class PLACE: class HTTPMETHOD: GET = "GET" POST = "POST" - HEAD = "HEAD" \ No newline at end of file + HEAD = "HEAD" + +class NULLCONNECTION: + HEAD = "HEAD" + RANGE = "Range" diff --git a/lib/request/connect.py b/lib/request/connect.py index feb3e626c..ebef31513 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -27,6 +27,7 @@ from lib.core.data import kb from lib.core.data import logger from lib.core.common import sanitizeAsciiString from lib.core.enums import HTTPMETHOD +from lib.core.enums import NULLCONNECTION from lib.core.enums import PLACE from lib.core.exception import sqlmapConnectionException from lib.request.basic import decodePage @@ -354,9 +355,9 @@ class Connect: Connect.getPage(url=conf.safUrl, cookie=cookie, direct=True, silent=True, ua=ua) if not content and not response and kb.nullConnection: - if kb.nullConnection == "HEAD": + if kb.nullConnection == NULLCONNECTION.HEAD: method = HTTPMETHOD.HEAD - elif kb.nullConnection == "Range": + elif kb.nullConnection == NULLCONNECTION.RANGE: if not auxHeaders: auxHeaders = {} @@ -364,9 +365,9 @@ class Connect: _, headers = Connect.getPage(url=uri, get=get, post=post, cookie=cookie, ua=ua, silent=silent, method=method, auxHeaders=auxHeaders, raise404=raise404) - if kb.nullConnection == "HEAD" and 'Content-Length' in headers: + if kb.nullConnection == NULLCONNECTION.HEAD and 'Content-Length' in headers: pageLength = int(headers['Content-Length']) - elif kb.nullConnection == "Range" and 'Content-Range' in headers: + elif kb.nullConnection == NULLCONNECTION.RANGE and 'Content-Range' in headers: pageLength = int(headers['Content-Range'][headers['Content-Range'].find('/') + 1:]) if not pageLength: