Moved little precaution from checks.py to common.py.

Initial refactoring of kb.os* get/set.
This commit is contained in:
Bernardo Damele 2011-01-20 21:56:10 +00:00
parent 9770db597e
commit 7d1c704575

View File

@ -2065,13 +2065,43 @@ class backend:
# Set methods # Set methods
@staticmethod @staticmethod
def setDbms(dbms): def setDbms(dbms):
kb.dbms = aliasToDbmsEnum(dbms) dbms = aliasToDbmsEnum(dbms)
if dbms is None:
return None
# Little precaution, in theory this condition should always be false
elif kb.dbms is not None and kb.dbms != dbms:
msg = "sqlmap previously fingerprinted back-end DBMS "
msg += "%s. However now it has been fingerprinted " % kb.dbms
msg += "to be %s. " % dbms
msg += "Please, specify which DBMS is "
msg += "correct [%s (default)/%s] " % (kb.dbms, dbms)
while True:
inp = readInput(msg, default=kb.dbms)
if aliasToDbmsEnum(inp) == kb.dbms:
break
elif aliasToDbmsEnum(inp) == dbms:
kb.dbms = aliasToDbmsEnum(inp)
break
else:
warnMsg = "invalid value"
logger.warn(warnMsg)
elif kb.dbms is None:
kb.dbms = aliasToDbmsEnum(dbms)
return kb.dbms
@staticmethod @staticmethod
def setVersion(version): def setVersion(version):
if isinstance(version, basestring): if isinstance(version, basestring):
kb.dbmsVersion = [ version ] kb.dbmsVersion = [ version ]
return kb.dbmsVersion
@staticmethod @staticmethod
def setVersionList(versionsList): def setVersionList(versionsList):
if isinstance(versionsList, list): if isinstance(versionsList, list):
@ -2089,6 +2119,36 @@ class backend:
def flushForcedDbms(): def flushForcedDbms():
kb.misc.forcedDbms = None kb.misc.forcedDbms = None
@staticmethod
def setOs(os):
if os is None:
return None
# Little precaution, in theory this condition should always be false
elif kb.os is not None and kb.os != os:
msg = "sqlmap previously fingerprinted back-end DBMS "
msg += "operating system %s. However now it has " % kb.os
msg += "been fingerprinted to be %s. " % os
msg += "Please, specify which OS is "
msg += "correct [%s (default)/%s] " % (kb.os, os)
while True:
inp = readInput(msg, default=kb.os)
if inp == kb.os:
break
elif inp == os:
kb.os = inp
break
else:
warnMsg = "invalid value"
logger.warn(warnMsg)
elif kb.os is None:
kb.os = os
return kb.os
# Get methods # Get methods
@staticmethod @staticmethod
def getForcedDbms(): def getForcedDbms():