From bb61010a452e44a07a6a73aea36807503d135866 Mon Sep 17 00:00:00 2001 From: Bernardo Damele Date: Mon, 4 Jan 2010 15:02:56 +0000 Subject: [PATCH] Avoid useless checks for --os-bof (no need to check for DBA or for xp_cmdshell). Minor code restyling. --- lib/takeover/abstraction.py | 11 +++++++---- lib/takeover/xp_cmdshell.py | 13 ++----------- plugins/dbms/mysql.py | 1 - plugins/dbms/postgresql.py | 1 - 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/lib/takeover/abstraction.py b/lib/takeover/abstraction.py index 7b9c599ac..9500d10cb 100644 --- a/lib/takeover/abstraction.py +++ b/lib/takeover/abstraction.py @@ -95,7 +95,7 @@ class Abstraction(UDF, xp_cmdshell): else: self.execCmd(cmd, forgeCmd=True) - if not conf.osShell and not conf.cleanup: + if not conf.osShell and not conf.osPwn and not conf.cleanup: self.__cmdShellCleanup() def absOsShell(self): @@ -151,7 +151,7 @@ class Abstraction(UDF, xp_cmdshell): self.checkDbmsOs(detailed) - if not self.isDba(): + if mandatory and not self.isDba(): warnMsg = "the functionality requested might not work because " warnMsg += "the session user is not a database administrator" logger.warn(warnMsg) @@ -160,8 +160,11 @@ class Abstraction(UDF, xp_cmdshell): self.udfInjectCmd() elif kb.dbms == "Microsoft SQL Server": - self.xpCmdshellInit(mandatory) + if mandatory: + self.xpCmdshellInit() else: errMsg = "feature not yet implemented for the back-end DBMS" - raise sqlmapUnsupportedFeatureException, errMsg + raise sqlmapUnsupportedFeatureException(errMsg) + + self.envInitialized = True diff --git a/lib/takeover/xp_cmdshell.py b/lib/takeover/xp_cmdshell.py index f9bb7be1c..c1bce580c 100644 --- a/lib/takeover/xp_cmdshell.py +++ b/lib/takeover/xp_cmdshell.py @@ -145,7 +145,7 @@ class xp_cmdshell: return output - def xpCmdshellInit(self, mandatory=True): + def xpCmdshellInit(self): self.__xpCmdshellAvailable = False infoMsg = "checking if xp_cmdshell extended procedure is " @@ -187,19 +187,10 @@ class xp_cmdshell: warnMsg += "because sp_OACreate is disabled" logger.warn(warnMsg) - if not self.__xpCmdshellAvailable and not mandatory: - warnMsg = "unable to get xp_cmdshell working, sqlmap will " - warnMsg += "try to proceed without it" - logger.warn(warnMsg) - - self.envInitialized = True - - elif not self.__xpCmdshellAvailable: + if not self.__xpCmdshellAvailable: errMsg = "unable to proceed without xp_cmdshell" raise sqlmapUnsupportedFeatureException, errMsg - self.envInitialized = True - debugMsg = "creating a support table to write commands standard " debugMsg += "output to" logger.debug(debugMsg) diff --git a/plugins/dbms/mysql.py b/plugins/dbms/mysql.py index a5d4caeb6..ea8f540aa 100644 --- a/plugins/dbms/mysql.py +++ b/plugins/dbms/mysql.py @@ -550,7 +550,6 @@ class MySQLMap(Fingerprint, Enumeration, Filesystem, Miscellaneous, Takeover): self.udfSharedLibExt = "so" self.udfInjectCore(self.sysUdfs) - self.envInitialized = True def uncPathRequest(self): if not kb.stackedTest: diff --git a/plugins/dbms/postgresql.py b/plugins/dbms/postgresql.py index 977aa088e..5dec1b547 100644 --- a/plugins/dbms/postgresql.py +++ b/plugins/dbms/postgresql.py @@ -464,7 +464,6 @@ class PostgreSQLMap(Fingerprint, Enumeration, Filesystem, Miscellaneous, Takeove self.udfSharedLibExt = "so" self.udfInjectCore(self.sysUdfs) - self.envInitialized = True def uncPathRequest(self): self.createSupportTbl(self.fileTblName, self.tblField, "text")