Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 45dff4a

Browse files
committed
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
1 parent b463205 commit 45dff4a

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

lib/core/common.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
from lib.core.data import queries
4444
from lib.core.data import temp
4545
from lib.core.exception import sqlmapFilePathException
46+
from lib.core.settings import PLATFORM
4647
from lib.core.settings import SQL_STATEMENTS
4748
from lib.core.settings import VERSION_STRING
4849

@@ -825,3 +826,22 @@ def getCharset(charsetType=None):
825826
asciiTbl.extend(range(96, 123))
826827

827828
return asciiTbl
829+
830+
831+
def searchEnvPath(fileName):
832+
envPaths = os.environ["PATH"]
833+
result = None
834+
835+
if "darwin" not in PLATFORM and "win" in PLATFORM:
836+
envPaths = envPaths.split(";")
837+
else:
838+
envPaths = envPaths.split(":")
839+
840+
for envPath in envPaths:
841+
envPath = envPath.replace(";", "")
842+
result = os.path.exists(os.path.normpath("%s/%s" % (envPath, fileName)))
843+
844+
if result == True:
845+
break
846+
847+
return result

0 commit comments

Comments
 (0)