@@ -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
15491560def checkConnection (suppressOutput = False ):
15501561 threadData = getCurrentThreadData ()
0 commit comments