Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0d0e2a2

Browse files
committed
minor update
1 parent d551423 commit 0d0e2a2

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

lib/controller/checks.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
from lib.core.data import kb
2727
from lib.core.data import logger
2828
from lib.core.data import paths
29+
from lib.core.enums import HTTPMETHOD
30+
from lib.core.enums import NULLCONNECTION
2931
from lib.core.exception import sqlmapConnectionException
3032
from lib.core.exception import sqlmapGenericException
3133
from lib.core.exception import sqlmapNoneDataException
@@ -368,16 +370,16 @@ def checkNullConnection():
368370
logger.info(infoMsg)
369371

370372
try:
371-
page, headers = Request.getPage(method="HEAD")
373+
page, headers = Request.getPage(method=HTTPMETHOD.HEAD)
372374
if not page and 'Content-Length' in headers:
373-
kb.nullConnection = "HEAD"
375+
kb.nullConnection = NULLCONNECTION.HEAD
374376

375377
infoMsg = "NULL connection is supported with HEAD header"
376378
logger.info(infoMsg)
377379
else:
378380
page, headers = Request.getPage(auxHeaders={"Range":"bytes=-1"})
379381
if page and len(page) == 1 and 'Content-Range' in headers:
380-
kb.nullConnection = "Range"
382+
kb.nullConnection = NULLCONNECTION.RANGE
381383

382384
infoMsg = "NULL connection is supported with GET header "
383385
infoMsg += "'%s'" % kb.nullConnection

lib/core/enums.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,8 @@ class PLACE:
3737
class HTTPMETHOD:
3838
GET = "GET"
3939
POST = "POST"
40-
HEAD = "HEAD"
40+
HEAD = "HEAD"
41+
42+
class NULLCONNECTION:
43+
HEAD = "HEAD"
44+
RANGE = "Range"

lib/request/connect.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from lib.core.data import logger
2828
from lib.core.common import sanitizeAsciiString
2929
from lib.core.enums import HTTPMETHOD
30+
from lib.core.enums import NULLCONNECTION
3031
from lib.core.enums import PLACE
3132
from lib.core.exception import sqlmapConnectionException
3233
from lib.request.basic import decodePage
@@ -354,19 +355,19 @@ def queryPage(value=None, place=None, content=False, getSeqMatcher=False, silent
354355
Connect.getPage(url=conf.safUrl, cookie=cookie, direct=True, silent=True, ua=ua)
355356

356357
if not content and not response and kb.nullConnection:
357-
if kb.nullConnection == "HEAD":
358+
if kb.nullConnection == NULLCONNECTION.HEAD:
358359
method = HTTPMETHOD.HEAD
359-
elif kb.nullConnection == "Range":
360+
elif kb.nullConnection == NULLCONNECTION.RANGE:
360361
if not auxHeaders:
361362
auxHeaders = {}
362363

363364
auxHeaders["Range"] = "bytes=-1"
364365

365366
_, headers = Connect.getPage(url=uri, get=get, post=post, cookie=cookie, ua=ua, silent=silent, method=method, auxHeaders=auxHeaders, raise404=raise404)
366367

367-
if kb.nullConnection == "HEAD" and 'Content-Length' in headers:
368+
if kb.nullConnection == NULLCONNECTION.HEAD and 'Content-Length' in headers:
368369
pageLength = int(headers['Content-Length'])
369-
elif kb.nullConnection == "Range" and 'Content-Range' in headers:
370+
elif kb.nullConnection == NULLCONNECTION.RANGE and 'Content-Range' in headers:
370371
pageLength = int(headers['Content-Range'][headers['Content-Range'].find('/') + 1:])
371372

372373
if not pageLength:

0 commit comments

Comments
 (0)