mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-07-06 12:53:21 +03:00
Some more refactoring
This commit is contained in:
parent
e948e4d45b
commit
6bc0b34031
|
@ -570,15 +570,15 @@ def __setDBMSAuthentication():
|
||||||
debugMsg = "setting the DBMS authentication credentials"
|
debugMsg = "setting the DBMS authentication credentials"
|
||||||
logger.debug(debugMsg)
|
logger.debug(debugMsg)
|
||||||
|
|
||||||
dCredRegExp = re.search("^(.+?):(.*?)$", conf.dCred)
|
match = re.search("^(.+?):(.*?)$", conf.dCred)
|
||||||
|
|
||||||
if not dCredRegExp:
|
if not match:
|
||||||
errMsg = "DBMS authentication credentials value must be in format "
|
errMsg = "DBMS authentication credentials value must be in format "
|
||||||
errMsg += "username:password"
|
errMsg += "username:password"
|
||||||
raise sqlmapSyntaxException, errMsg
|
raise sqlmapSyntaxException, errMsg
|
||||||
|
|
||||||
conf.dbmsUsername = dCredRegExp.group(1)
|
conf.dbmsUsername = match.group(1)
|
||||||
conf.dbmsPassword = dCredRegExp.group(2)
|
conf.dbmsPassword = match.group(2)
|
||||||
|
|
||||||
def __setMetasploit():
|
def __setMetasploit():
|
||||||
if not conf.osPwn and not conf.osSmb and not conf.osBof:
|
if not conf.osPwn and not conf.osSmb and not conf.osBof:
|
||||||
|
@ -609,20 +609,15 @@ def __setMetasploit():
|
||||||
raise sqlmapMissingPrivileges, errMsg
|
raise sqlmapMissingPrivileges, errMsg
|
||||||
|
|
||||||
if conf.msfPath:
|
if conf.msfPath:
|
||||||
condition = False
|
found = False
|
||||||
|
|
||||||
for path in (conf.msfPath, os.path.join(conf.msfPath, 'bin')):
|
for path in (conf.msfPath, os.path.join(conf.msfPath, 'bin')):
|
||||||
condition = os.path.exists(normalizePath(path))
|
if all(os.path.exists(normalizePath(os.path.join(path, _))) for _ in ("", "msfcli", "msfconsole", "msfencode", "msfpayload")):
|
||||||
condition &= os.path.exists(normalizePath(os.path.join(path, "msfcli")))
|
found = True
|
||||||
condition &= os.path.exists(normalizePath(os.path.join(path, "msfconsole")))
|
|
||||||
condition &= os.path.exists(normalizePath(os.path.join(path, "msfencode")))
|
|
||||||
condition &= os.path.exists(normalizePath(os.path.join(path, "msfpayload")))
|
|
||||||
|
|
||||||
if condition:
|
|
||||||
conf.msfPath = path
|
conf.msfPath = path
|
||||||
break
|
break
|
||||||
|
|
||||||
if condition:
|
if found:
|
||||||
debugMsg = "provided Metasploit Framework path "
|
debugMsg = "provided Metasploit Framework path "
|
||||||
debugMsg += "'%s' is valid" % conf.msfPath
|
debugMsg += "'%s' is valid" % conf.msfPath
|
||||||
logger.debug(debugMsg)
|
logger.debug(debugMsg)
|
||||||
|
@ -646,22 +641,12 @@ def __setMetasploit():
|
||||||
warnMsg += "installation into the environment paths"
|
warnMsg += "installation into the environment paths"
|
||||||
logger.warn(warnMsg)
|
logger.warn(warnMsg)
|
||||||
|
|
||||||
envPaths = os.environ["PATH"]
|
envPaths = os.environ.get("PATH", "").split(";" if IS_WIN else ":")
|
||||||
|
|
||||||
if IS_WIN:
|
|
||||||
envPaths = envPaths.split(";")
|
|
||||||
else:
|
|
||||||
envPaths = envPaths.split(":")
|
|
||||||
|
|
||||||
for envPath in envPaths:
|
for envPath in envPaths:
|
||||||
envPath = envPath.replace(";", "")
|
envPath = envPath.replace(";", "")
|
||||||
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:
|
if all(os.path.exists(normalizePath(os.path.join(envPath, _))) for _ in ("", "msfcli", "msfconsole", "msfencode", "msfpayload")):
|
||||||
infoMsg = "Metasploit Framework has been found "
|
infoMsg = "Metasploit Framework has been found "
|
||||||
infoMsg += "installed in the '%s' path" % envPath
|
infoMsg += "installed in the '%s' path" % envPath
|
||||||
logger.info(infoMsg)
|
logger.info(infoMsg)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user