store/resume info on xp_cmd available in session file

This commit is contained in:
Bernardo Damele 2011-04-21 14:25:04 +00:00
parent 930872cf3b
commit b667c50588
3 changed files with 53 additions and 36 deletions

View File

@ -1329,6 +1329,7 @@ def __setKnowledgeBaseAttributes(flushAll=True):
kb.threadContinue = True kb.threadContinue = True
kb.threadException = False kb.threadException = False
kb.threadData = {} kb.threadData = {}
kb.xpCmdshellAvailable = False
kb.misc = advancedDict() kb.misc = advancedDict()
kb.misc.delimiter = randomStr(length=6, lowercase=True) kb.misc.delimiter = randomStr(length=6, lowercase=True)

View File

@ -154,6 +154,15 @@ def setRemoteTempPath():
if condition: if condition:
dataToSessionFile("[%s][%s][%s][Remote temp path][%s]\n" % (conf.url, kb.injection.place, safeFormatString(conf.parameters[kb.injection.place]), safeFormatString(conf.tmpPath))) dataToSessionFile("[%s][%s][%s][Remote temp path][%s]\n" % (conf.url, kb.injection.place, safeFormatString(conf.parameters[kb.injection.place]), safeFormatString(conf.tmpPath)))
def setXpCmdshellAvailability(available):
condition = (
not kb.resumedQueries or ( kb.resumedQueries.has_key(conf.url) and
not kb.resumedQueries[conf.url].has_key("xp_cmdshell availability") )
)
if condition:
dataToSessionFile("[%s][%s][%s][xp_cmdshell availability][%s]\n" % (conf.url, kb.injection.place, safeFormatString(conf.parameters[kb.injection.place]), str(available).lower()))
def resumeConfKb(expression, url, value): def resumeConfKb(expression, url, value):
if expression == "Injection data" and url == conf.url: if expression == "Injection data" and url == conf.url:
injection = base64unpickle(value[:-1]) injection = base64unpickle(value[:-1])
@ -270,3 +279,8 @@ def resumeConfKb(expression, url, value):
logger.info(logMsg) logger.info(logMsg)
kb.brute.columns.append((db, table, colName, colType)) kb.brute.columns.append((db, table, colName, colType))
elif expression == "xp_cmdshell availability" and url == conf.url:
kb.xpCmdshellAvailable = True if unSafeFormatString(value[:-1]).lower() == "true" else False
logMsg = "resuming xp_cmdshell availability"
logger.info(logMsg)

View File

@ -15,6 +15,7 @@ from lib.core.data import conf
from lib.core.data import kb from lib.core.data import kb
from lib.core.data import logger from lib.core.data import logger
from lib.core.exception import sqlmapUnsupportedFeatureException from lib.core.exception import sqlmapUnsupportedFeatureException
from lib.core.session import setXpCmdshellAvailability
from lib.core.unescaper import unescaper from lib.core.unescaper import unescaper
from lib.request import inject from lib.request import inject
@ -132,8 +133,7 @@ class xp_cmdshell:
return output return output
def xpCmdshellInit(self): def xpCmdshellInit(self):
self.__xpCmdshellAvailable = False if kb.xpCmdshellAvailable is False:
infoMsg = "checking if xp_cmdshell extended procedure is " infoMsg = "checking if xp_cmdshell extended procedure is "
infoMsg += "available, please wait.." infoMsg += "available, please wait.."
logger.info(infoMsg) logger.info(infoMsg)
@ -142,7 +142,7 @@ class xp_cmdshell:
if result: if result:
logger.info("xp_cmdshell extended procedure is available") logger.info("xp_cmdshell extended procedure is available")
self.__xpCmdshellAvailable = True kb.xpCmdshellAvailable = True
else: else:
message = "xp_cmdshell extended procedure does not seem to " message = "xp_cmdshell extended procedure does not seem to "
@ -155,7 +155,7 @@ class xp_cmdshell:
if self.__xpCmdshellCheck(): if self.__xpCmdshellCheck():
logger.info("xp_cmdshell re-enabled successfully") logger.info("xp_cmdshell re-enabled successfully")
self.__xpCmdshellAvailable = True kb.xpCmdshellAvailable = True
else: else:
logger.warn("xp_cmdshell re-enabling failed") logger.warn("xp_cmdshell re-enabling failed")
@ -166,14 +166,16 @@ class xp_cmdshell:
if self.__xpCmdshellCheck(): if self.__xpCmdshellCheck():
logger.info("xp_cmdshell created successfully") logger.info("xp_cmdshell created successfully")
self.__xpCmdshellAvailable = True kb.xpCmdshellAvailable = True
else: else:
warnMsg = "xp_cmdshell creation failed, probably " warnMsg = "xp_cmdshell creation failed, probably "
warnMsg += "because sp_OACreate is disabled" warnMsg += "because sp_OACreate is disabled"
logger.warn(warnMsg) logger.warn(warnMsg)
if not self.__xpCmdshellAvailable: setXpCmdshellAvailability(kb.xpCmdshellAvailable)
if not kb.xpCmdshellAvailable:
errMsg = "unable to proceed without xp_cmdshell" errMsg = "unable to proceed without xp_cmdshell"
raise sqlmapUnsupportedFeatureException, errMsg raise sqlmapUnsupportedFeatureException, errMsg