From 45dff4a00aa2f6c1f96a21fa863a4a57f888a474 Mon Sep 17 00:00:00 2001 From: Bernardo Damele Date: Tue, 12 May 2009 20:24:47 +0000 Subject: [PATCH] Added new function to search a file within the PATH environment variable paths: it will be used when sqlmap will be packaged as DEB and RPM --- lib/core/common.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/core/common.py b/lib/core/common.py index 16b1c8b04..d7567ef05 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -43,6 +43,7 @@ from lib.core.data import paths from lib.core.data import queries from lib.core.data import temp from lib.core.exception import sqlmapFilePathException +from lib.core.settings import PLATFORM from lib.core.settings import SQL_STATEMENTS from lib.core.settings import VERSION_STRING @@ -825,3 +826,22 @@ def getCharset(charsetType=None): asciiTbl.extend(range(96, 123)) return asciiTbl + + +def searchEnvPath(fileName): + envPaths = os.environ["PATH"] + result = None + + if "darwin" not in PLATFORM and "win" in PLATFORM: + envPaths = envPaths.split(";") + else: + envPaths = envPaths.split(":") + + for envPath in envPaths: + envPath = envPath.replace(";", "") + result = os.path.exists(os.path.normpath("%s/%s" % (envPath, fileName))) + + if result == True: + break + + return result