Bug fix (wrong handler used in case of DBMS resolution)

This commit is contained in:
Miroslav Stampar 2016-05-30 10:32:49 +02:00
parent 0b1efc0759
commit 83b82a5e98
5 changed files with 15 additions and 4 deletions

View File

@ -7,6 +7,7 @@ See the file 'doc/COPYING' for copying permission
from lib.core.common import Backend from lib.core.common import Backend
from lib.core.data import conf from lib.core.data import conf
from lib.core.data import kb
from lib.core.data import logger from lib.core.data import logger
from lib.core.dicts import DBMS_DICT from lib.core.dicts import DBMS_DICT
from lib.core.enums import DBMS from lib.core.enums import DBMS
@ -101,7 +102,10 @@ def setHandler():
conf.dbmsConnector.connect() conf.dbmsConnector.connect()
if handler.checkDbms(): if handler.checkDbms():
conf.dbmsHandler = handler if kb.resolutionDbms:
conf.dbmsHandler = max(_ for _ in items if _[0] == kb.resolutionDbms)[2]()
else:
conf.dbmsHandler = handler
break break
else: else:
conf.dbmsConnector = None conf.dbmsConnector = None

View File

@ -319,6 +319,8 @@ class Backend:
_ = readInput(msg, default=kb.dbms) _ = readInput(msg, default=kb.dbms)
if aliasToDbmsEnum(_) == kb.dbms: if aliasToDbmsEnum(_) == kb.dbms:
kb.dbmsVersion = []
kb.resolutionDbms = kb.dbms
break break
elif aliasToDbmsEnum(_) == dbms: elif aliasToDbmsEnum(_) == dbms:
kb.dbms = aliasToDbmsEnum(_) kb.dbms = aliasToDbmsEnum(_)
@ -1968,8 +1970,8 @@ def readCachedFileContent(filename, mode='rb'):
if filename not in kb.cache.content: if filename not in kb.cache.content:
checkFile(filename) checkFile(filename)
try: try:
with openFile(filename, mode) as f: with openFile(filename, mode) as f:
kb.cache.content[filename] = f.read() kb.cache.content[filename] = f.read()
except (IOError, OSError, MemoryError), ex: except (IOError, OSError, MemoryError), ex:
errMsg = "something went wrong while trying " errMsg = "something went wrong while trying "
errMsg += "to read the content of file '%s' ('%s')" % (filename, getSafeExString(ex)) errMsg += "to read the content of file '%s' ('%s')" % (filename, getSafeExString(ex))

View File

@ -1913,6 +1913,7 @@ def _setKnowledgeBaseAttributes(flushAll=True):
kb.reflectiveCounters = {REFLECTIVE_COUNTER.MISS: 0, REFLECTIVE_COUNTER.HIT: 0} kb.reflectiveCounters = {REFLECTIVE_COUNTER.MISS: 0, REFLECTIVE_COUNTER.HIT: 0}
kb.requestCounter = 0 kb.requestCounter = 0
kb.resendPostOnRedirect = None kb.resendPostOnRedirect = None
kb.resolutionDbms = None
kb.responseTimes = {} kb.responseTimes = {}
kb.responseTimeMode = None kb.responseTimeMode = None
kb.responseTimePayload = None kb.responseTimePayload = None

View File

@ -7,6 +7,7 @@ See the file 'doc/COPYING' for copying permission
import re import re
from lib.core.common import aliasToDbmsEnum
from lib.core.common import Backend from lib.core.common import Backend
from lib.core.common import Format from lib.core.common import Format
from lib.core.common import hashDBWrite from lib.core.common import hashDBWrite
@ -32,6 +33,9 @@ def setDbms(dbms):
dbms = _.group(1) dbms = _.group(1)
Backend.setDbms(dbms) Backend.setDbms(dbms)
if kb.resolutionDbms:
hashDBWrite(HASHDB_KEYS.DBMS, kb.resolutionDbms)
logger.info("the back-end DBMS is %s" % Backend.getDbms()) logger.info("the back-end DBMS is %s" % Backend.getDbms())
def setOs(): def setOs():

View File

@ -19,7 +19,7 @@ from lib.core.enums import OS
from lib.core.revision import getRevisionNumber from lib.core.revision import getRevisionNumber
# sqlmap version (<major>.<minor>.<month>.<monthly commit>) # sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.0.5.97" VERSION = "1.0.5.99"
REVISION = getRevisionNumber() REVISION = getRevisionNumber()
STABLE = VERSION.count('.') <= 2 STABLE = VERSION.count('.') <= 2
VERSION_STRING = "sqlmap/%s#%s" % (VERSION, "stable" if STABLE else "dev") VERSION_STRING = "sqlmap/%s#%s" % (VERSION, "stable" if STABLE else "dev")