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

Skip to content

Commit e64cc86

Browse files
committed
Patch related to the #3524
1 parent 9387a00 commit e64cc86

3 files changed

Lines changed: 37 additions & 25 deletions

File tree

lib/controller/checks.py

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,44 +1507,55 @@ def checkNullConnection():
15071507
if conf.data:
15081508
return False
15091509

1510-
infoMsg = "testing NULL connection to the target URL"
1511-
logger.info(infoMsg)
1510+
_ = hashDBRetrieve(HASHDB_KEYS.CHECK_NULL_CONNECTION_RESULT, True)
1511+
if _ is not None:
1512+
kb.nullConnection = _
15121513

1513-
pushValue(kb.pageCompress)
1514-
kb.pageCompress = False
1514+
if _:
1515+
dbgMsg = "resuming NULL connection method '%s'" % _
1516+
logger.debug(dbgMsg)
15151517

1516-
try:
1517-
page, headers, _ = Request.getPage(method=HTTPMETHOD.HEAD, raise404=False)
1518+
else:
1519+
infoMsg = "testing NULL connection to the target URL"
1520+
logger.info(infoMsg)
15181521

1519-
if not page and HTTP_HEADER.CONTENT_LENGTH in (headers or {}):
1520-
kb.nullConnection = NULLCONNECTION.HEAD
1522+
pushValue(kb.pageCompress)
1523+
kb.pageCompress = False
15211524

1522-
infoMsg = "NULL connection is supported with HEAD method ('Content-Length')"
1523-
logger.info(infoMsg)
1524-
else:
1525-
page, headers, _ = Request.getPage(auxHeaders={HTTP_HEADER.RANGE: "bytes=-1"})
1525+
try:
1526+
page, headers, _ = Request.getPage(method=HTTPMETHOD.HEAD, raise404=False)
15261527

1527-
if page and len(page) == 1 and HTTP_HEADER.CONTENT_RANGE in (headers or {}):
1528-
kb.nullConnection = NULLCONNECTION.RANGE
1528+
if not page and HTTP_HEADER.CONTENT_LENGTH in (headers or {}):
1529+
kb.nullConnection = NULLCONNECTION.HEAD
15291530

1530-
infoMsg = "NULL connection is supported with GET method ('Range')"
1531+
infoMsg = "NULL connection is supported with HEAD method ('Content-Length')"
15311532
logger.info(infoMsg)
15321533
else:
1533-
_, headers, _ = Request.getPage(skipRead=True)
1534+
page, headers, _ = Request.getPage(auxHeaders={HTTP_HEADER.RANGE: "bytes=-1"})
15341535

1535-
if HTTP_HEADER.CONTENT_LENGTH in (headers or {}):
1536-
kb.nullConnection = NULLCONNECTION.SKIP_READ
1536+
if page and len(page) == 1 and HTTP_HEADER.CONTENT_RANGE in (headers or {}):
1537+
kb.nullConnection = NULLCONNECTION.RANGE
15371538

1538-
infoMsg = "NULL connection is supported with 'skip-read' method"
1539+
infoMsg = "NULL connection is supported with GET method ('Range')"
15391540
logger.info(infoMsg)
1541+
else:
1542+
_, headers, _ = Request.getPage(skipRead=True)
15401543

1541-
except SqlmapConnectionException:
1542-
pass
1544+
if HTTP_HEADER.CONTENT_LENGTH in (headers or {}):
1545+
kb.nullConnection = NULLCONNECTION.SKIP_READ
15431546

1544-
finally:
1545-
kb.pageCompress = popValue()
1547+
infoMsg = "NULL connection is supported with 'skip-read' method"
1548+
logger.info(infoMsg)
1549+
1550+
except SqlmapConnectionException:
1551+
pass
1552+
1553+
finally:
1554+
kb.pageCompress = popValue()
1555+
kb.nullConnection = False if kb.nullConnection is None else kb.nullConnection
1556+
hashDBWrite(HASHDB_KEYS.CHECK_NULL_CONNECTION_RESULT, kb.nullConnection, True)
15461557

1547-
return kb.nullConnection is not None
1558+
return kb.nullConnection in getPublicTypeMembers(NULLCONNECTION, True)
15481559

15491560
def checkConnection(suppressOutput=False):
15501561
threadData = getCurrentThreadData()

lib/core/enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ class HASHDB_KEYS:
231231
DBMS = "DBMS"
232232
DBMS_FORK = "DBMS_FORK"
233233
CHECK_WAF_RESULT = "CHECK_WAF_RESULT"
234+
CHECK_NULL_CONNECTION_RESULT = "CHECK_NULL_CONNECTION_RESULT"
234235
CONF_TMP_PATH = "CONF_TMP_PATH"
235236
KB_ABS_FILE_PATHS = "KB_ABS_FILE_PATHS"
236237
KB_BRUTE_COLUMNS = "KB_BRUTE_COLUMNS"

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.3.3.46"
22+
VERSION = "1.3.3.47"
2323
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2424
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2525
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

0 commit comments

Comments
 (0)