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

Skip to content

Commit 9b26235

Browse files
committed
one bug fix for Host header (value should be without port number); one improvement for --tables - when no tables ask user if he wants to brute force them; one tweak - adding kb.ignoreTimeout for --tables
1 parent 2ea613b commit 9b26235

3 files changed

Lines changed: 34 additions & 4 deletions

File tree

lib/core/common.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2573,3 +2573,19 @@ def isBinaryData(value):
25732573
if isinstance(value, basestring):
25742574
retVal = reduce(lambda x, y: x or not (y in string.printable or ord(y) > 255), value, False)
25752575
return retVal
2576+
2577+
def isNoneValue(value):
2578+
"""
2579+
Returns whether the value contains implicit 'None' value
2580+
"""
2581+
2582+
if isinstance(value, basestring):
2583+
return value == "None"
2584+
elif isinstance(value, list):
2585+
return value == [None]
2586+
elif isinstance(value, tuple):
2587+
return value == (None)
2588+
elif isinstance(value, dict):
2589+
return len(value) == 1 and any(map(lambda x: x in value, [None, "None"]))
2590+
else:
2591+
return value is None

lib/request/connect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def getPage(**kwargs):
187187
if kb.proxyAuthHeader:
188188
headers[HTTPHEADER.PROXY_AUTHORIZATION] = kb.proxyAuthHeader
189189

190-
headers[HTTPHEADER.HOST] = host or urlparse.urlparse(url).netloc
190+
headers[HTTPHEADER.HOST] = host or urlparse.urlparse(url).netloc.split(':')[0]
191191

192192
if auxHeaders:
193193
for key, item in auxHeaders.items():

plugins/generic/enumeration.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from lib.core.common import getFileItems
2020
from lib.core.common import Backend
2121
from lib.core.common import getUnicode
22+
from lib.core.common import isNoneValue
2223
from lib.core.common import isNumPosStrValue
2324
from lib.core.common import isTechniqueAvailable
2425
from lib.core.common import parsePasswordHash
@@ -803,6 +804,10 @@ def getTables(self, bruteForce=None):
803804
infoMsg += "%s: %s" % ("s" if len(dbs) > 1 else "", ", ".join(db for db in dbs))
804805
logger.info(infoMsg)
805806

807+
pushValue(kb.ignoreTimeout)
808+
# some DBMSes (like MySQL) have (permission related) timeout issues when retrieving table names
809+
kb.ignoreTimeout = True
810+
806811
rootQuery = queries[Backend.getIdentifiedDbms()].tables
807812

808813
if isTechniqueAvailable(PAYLOAD.TECHNIQUE.UNION) or isTechniqueAvailable(PAYLOAD.TECHNIQUE.ERROR) or conf.direct:
@@ -896,13 +901,22 @@ def getTables(self, bruteForce=None):
896901
if tables:
897902
kb.data.cachedTables[db] = tables
898903
else:
899-
warnMsg = "unable to retrieve the tables "
904+
warnMsg = "unable to retrieve the table names "
900905
warnMsg += "for database '%s'" % db
901906
logger.warn(warnMsg)
902907

908+
kb.ignoreTimeout = popValue()
909+
910+
if isNoneValue(kb.data.cachedTables):
911+
kb.data.cachedTables.clear()
912+
903913
if not kb.data.cachedTables:
904-
errMsg = "unable to retrieve the tables for any database"
905-
raise sqlmapNoneDataException, errMsg
914+
errMsg = "unable to retrieve the table names for any database"
915+
if bruteForce is None:
916+
logger.error(errMsg)
917+
return self.getTables(bruteForce=True)
918+
else:
919+
raise sqlmapNoneDataException, errMsg
906920

907921
return kb.data.cachedTables
908922

0 commit comments

Comments
 (0)