diff --git a/lib/core/option.py b/lib/core/option.py index bd83149c6..1e7e0801f 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -35,6 +35,7 @@ import urlparse from ConfigParser import ConfigParser from lib.core.common import getFileType +from lib.core.common import normalizePath from lib.core.common import ntToPosixSlashes from lib.core.common import parseTargetUrl from lib.core.common import paths @@ -427,11 +428,11 @@ def __setMetasploit(): raise sqlmapMissingPrivileges, errMsg if conf.msfPath: - condition = os.path.exists(os.path.normpath(conf.msfPath)) - condition &= os.path.exists(os.path.normpath(os.path.join(conf.msfPath, "msfcli"))) - condition &= os.path.exists(os.path.normpath(os.path.join(conf.msfPath, "msfconsole"))) - condition &= os.path.exists(os.path.normpath(os.path.join(conf.msfPath, "msfencode"))) - condition &= os.path.exists(os.path.normpath(os.path.join(conf.msfPath, "msfpayload"))) + condition = os.path.exists(normalizePath(conf.msfPath)) + condition &= os.path.exists(normalizePath(os.path.join(conf.msfPath, "msfcli"))) + condition &= os.path.exists(normalizePath(os.path.join(conf.msfPath, "msfconsole"))) + condition &= os.path.exists(normalizePath(os.path.join(conf.msfPath, "msfencode"))) + condition &= os.path.exists(normalizePath(os.path.join(conf.msfPath, "msfpayload"))) if condition: debugMsg = "provided Metasploit Framework 3 path " @@ -466,11 +467,11 @@ def __setMetasploit(): for envPath in envPaths: envPath = envPath.replace(";", "") - condition = os.path.exists(os.path.normpath(envPath)) - condition &= os.path.exists(os.path.normpath(os.path.join(envPath, "msfcli"))) - condition &= os.path.exists(os.path.normpath(os.path.join(envPath, "msfconsole"))) - condition &= os.path.exists(os.path.normpath(os.path.join(envPath, "msfencode"))) - condition &= os.path.exists(os.path.normpath(os.path.join(envPath, "msfpayload"))) + condition = os.path.exists(normalizePath(envPath)) + condition &= os.path.exists(normalizePath(os.path.join(envPath, "msfcli"))) + condition &= os.path.exists(normalizePath(os.path.join(envPath, "msfconsole"))) + condition &= os.path.exists(normalizePath(os.path.join(envPath, "msfencode"))) + condition &= os.path.exists(normalizePath(os.path.join(envPath, "msfpayload"))) if condition: infoMsg = "Metasploit Framework 3 has been found " @@ -904,19 +905,19 @@ def __cleanupOptions(): conf.delay = float(conf.delay) if conf.rFile: - conf.rFile = os.path.normpath(ntToPosixSlashes(conf.rFile)) + conf.rFile = normalizePath(ntToPosixSlashes(conf.rFile)) if conf.wFile: - conf.wFile = os.path.normpath(ntToPosixSlashes(conf.wFile)) + conf.wFile = normalizePath(ntToPosixSlashes(conf.wFile)) if conf.dFile: - conf.dFile = os.path.normpath(ntToPosixSlashes(conf.dFile)) + conf.dFile = normalizePath(ntToPosixSlashes(conf.dFile)) if conf.msfPath: - conf.msfPath = os.path.normpath(ntToPosixSlashes(conf.msfPath)) + conf.msfPath = normalizePath(ntToPosixSlashes(conf.msfPath)) if conf.tmpPath: - conf.tmpPath = os.path.normpath(ntToPosixSlashes(conf.tmpPath)) + conf.tmpPath = normalizePath(ntToPosixSlashes(conf.tmpPath)) if conf.googleDork or conf.list: conf.multipleTargets = True diff --git a/lib/takeover/metasploit.py b/lib/takeover/metasploit.py index 0f65d51d3..a8997698f 100644 --- a/lib/takeover/metasploit.py +++ b/lib/takeover/metasploit.py @@ -72,10 +72,10 @@ class Metasploit: self.localIP = getLocalIP() self.remoteIP = getRemoteIP() - self.__msfCli = os.path.normpath(os.path.join(conf.msfPath, "msfcli")) - self.__msfConsole = os.path.normpath(os.path.join(conf.msfPath, "msfconsole")) - self.__msfEncode = os.path.normpath(os.path.join(conf.msfPath, "msfencode")) - self.__msfPayload = os.path.normpath(os.path.join(conf.msfPath, "msfpayload")) + self.__msfCli = normalizePath(os.path.join(conf.msfPath, "msfcli")) + self.__msfConsole = normalizePath(os.path.join(conf.msfPath, "msfconsole")) + self.__msfEncode = normalizePath(os.path.join(conf.msfPath, "msfencode")) + self.__msfPayload = normalizePath(os.path.join(conf.msfPath, "msfpayload")) self.__msfPayloadsList = { "windows": { diff --git a/plugins/dbms/mysql.py b/plugins/dbms/mysql.py index 98c46aaaa..b5e76a880 100644 --- a/plugins/dbms/mysql.py +++ b/plugins/dbms/mysql.py @@ -29,6 +29,7 @@ from lib.core.agent import agent from lib.core.common import formatDBMSfp from lib.core.common import formatFingerprint from lib.core.common import getHtmlErrorFp +from lib.core.common import normalizePath from lib.core.common import ntToPosixSlashes from lib.core.common import randomInt from lib.core.common import randomStr @@ -497,7 +498,7 @@ class MySQLMap(Fingerprint, Enumeration, Filesystem, Miscellaneous, Takeover): # Reference: http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_basedir self.__basedir = inject.getValue("SELECT @@basedir") - self.__basedir = os.path.normpath(ntToPosixSlashes(self.__basedir)) + self.__basedir = normalizePath(ntToPosixSlashes(self.__basedir)) if re.search("^[\w]\:[\/\\\\]+", self.__basedir, re.I): kb.os = "Windows" @@ -518,7 +519,7 @@ class MySQLMap(Fingerprint, Enumeration, Filesystem, Miscellaneous, Takeover): # NOTE: specifying the relative path as './udf.dll' # saves in @@datadir on both MySQL 4.1 and MySQL 5.0 self.__datadir = "." - self.__datadir = os.path.normpath(ntToPosixSlashes(self.__datadir)) + self.__datadir = normalizePath(ntToPosixSlashes(self.__datadir)) if re.search("[\w]\:\/", self.__datadir, re.I): kb.os = "Windows" diff --git a/plugins/generic/misc.py b/plugins/generic/misc.py index 154412848..88bcc7040 100644 --- a/plugins/generic/misc.py +++ b/plugins/generic/misc.py @@ -25,6 +25,7 @@ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import os import re +from lib.core.common import normalizePath from lib.core.common import ntToPosixSlashes from lib.core.common import posixToNtSlashes from lib.core.common import readInput @@ -68,7 +69,7 @@ class Miscellaneous: kb.os = "Windows" conf.tmpPath = ntToPosixSlashes(conf.tmpPath) - conf.tmpPath = os.path.normpath(conf.tmpPath) + conf.tmpPath = normalizePath(conf.tmpPath) setRemoteTempPath()