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

Skip to content

Commit 3c4aadf

Browse files
committed
Fixes #3823
1 parent 34ed2c5 commit 3c4aadf

3 files changed

Lines changed: 10 additions & 40 deletions

File tree

lib/core/option.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -526,22 +526,10 @@ def _setMetasploit():
526526
raise SqlmapMissingDependence(errMsg)
527527

528528
if not conf.msfPath:
529-
def _(key, value):
530-
retVal = None
531-
532-
try:
533-
from six.moves.winreg import ConnectRegistry, OpenKey, QueryValueEx, HKEY_LOCAL_MACHINE
534-
_ = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
535-
_ = OpenKey(_, key)
536-
retVal = QueryValueEx(_, value)[0]
537-
except:
538-
logger.debug("unable to identify Metasploit installation path via registry key")
539-
540-
return retVal
541-
542-
conf.msfPath = _(r"SOFTWARE\Rapid7\Metasploit", "Location")
543-
if conf.msfPath:
544-
conf.msfPath = os.path.join(conf.msfPath, "msf3")
529+
for candidate in os.environ.get("PATH", "").split(';'):
530+
if all(_ in candidate for _ in ("metasploit", "bin")):
531+
conf.msfPath = os.path.dirname(candidate.rstrip('\\'))
532+
break
545533

546534
if conf.osSmb:
547535
isAdmin = runningAsAdmin()

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.3.7.22"
21+
VERSION = "1.3.7.23"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/takeover/metasploit.py

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,29 +68,11 @@ def _initVars(self):
6868
self.payloadConnStr = None
6969
self.localIP = getLocalIP()
7070
self.remoteIP = getRemoteIP() or conf.hostname
71-
self._msfCli = normalizePath(os.path.join(conf.msfPath, "msfcli"))
72-
self._msfConsole = normalizePath(os.path.join(conf.msfPath, "msfconsole"))
73-
self._msfEncode = normalizePath(os.path.join(conf.msfPath, "msfencode"))
74-
self._msfPayload = normalizePath(os.path.join(conf.msfPath, "msfpayload"))
75-
self._msfVenom = normalizePath(os.path.join(conf.msfPath, "msfvenom"))
76-
77-
if IS_WIN:
78-
_ = conf.msfPath
79-
while _:
80-
if os.path.exists(os.path.join(_, "scripts")):
81-
_ = os.path.join(_, "scripts", "setenv.bat")
82-
break
83-
else:
84-
old = _
85-
_ = normalizePath(os.path.join(_, ".."))
86-
if _ == old:
87-
break
88-
89-
self._msfCli = "%s & ruby %s" % (_, self._msfCli)
90-
self._msfConsole = "%s & ruby %s" % (_, self._msfConsole)
91-
self._msfEncode = "ruby %s" % self._msfEncode
92-
self._msfPayload = "%s & ruby %s" % (_, self._msfPayload)
93-
self._msfVenom = "%s & ruby %s" % (_, self._msfVenom)
71+
self._msfCli = normalizePath(os.path.join(conf.msfPath, "msfcli%s" % (".bat" if IS_WIN else "")))
72+
self._msfConsole = normalizePath(os.path.join(conf.msfPath, "msfconsole%s" % (".bat" if IS_WIN else "")))
73+
self._msfEncode = normalizePath(os.path.join(conf.msfPath, "msfencode%s" % (".bat" if IS_WIN else "")))
74+
self._msfPayload = normalizePath(os.path.join(conf.msfPath, "msfpayload%s" % (".bat" if IS_WIN else "")))
75+
self._msfVenom = normalizePath(os.path.join(conf.msfPath, "msfvenom%s" % (".bat" if IS_WIN else "")))
9476

9577
self._msfPayloadsList = {
9678
"windows": {

0 commit comments

Comments
 (0)