diff --git a/lib/core/option.py b/lib/core/option.py index ace52e04d..28ae820c6 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -591,26 +591,18 @@ def __setMetasploit(): if not conf.msfPath: def _(key, value): retVal = None - try: from _winreg import ConnectRegistry, OpenKey, QueryValueEx, HKEY_LOCAL_MACHINE _ = ConnectRegistry(None, HKEY_LOCAL_MACHINE) _ = OpenKey(_, key) - retval = QueryValueEx(_, value)[0] - except: - pass - + retVal = QueryValueEx(_, value)[0] + except Exception, ex: + print ex return retVal conf.msfPath = _(r"SOFTWARE\Rapid7\Metasploit", "Location") - - warnMsg = "some sqlmap takeover functionalities are not yet " - warnMsg += "supported on Windows. Please use Linux in a virtual " - warnMsg += "machine for out-of-band features." - - logger.critical(warnMsg) - - raise sqlmapSilentQuitException + if conf.msfPath: + conf.msfPath = os.path.join(conf.msfPath, "msf3") if conf.osSmb: isAdmin = runningAsAdmin() diff --git a/lib/takeover/metasploit.py b/lib/takeover/metasploit.py index a8c302aad..66fc60cd9 100644 --- a/lib/takeover/metasploit.py +++ b/lib/takeover/metasploit.py @@ -61,9 +61,9 @@ class Metasploit: if IS_WIN: _ = normalizePath(os.path.join(conf.msfPath, "..", "scripts", "setenv.bat")) - for attr in dir(self): - if "__msf" in attr: - setattr(self, attr, "%s & %s" % (_, getattr(self, attr))) + self.__msfCli = "%s & ruby %s" % (_, self.__msfCli) + self.__msfEncode = "ruby %s" % self.__msfEncode + self.__msfPayload = "%s & ruby %s" % (_, self.__msfPayload) self.__msfPayloadsList = { "windows": { @@ -360,12 +360,12 @@ class Metasploit: self.__payloadCmd += " PrependChrootBreak=true PrependSetuid=true" if extra == "BufferRegister=EAX": - self.__payloadCmd += " R | %s -a x86 -e %s -o %s -t %s" % (self.__msfEncode, self.encoderStr, outFile, format) + self.__payloadCmd += " R | %s -a x86 -e %s -o \"%s\" -t %s" % (self.__msfEncode, self.encoderStr, outFile, format) if extra is not None: self.__payloadCmd += " %s" % extra else: - self.__payloadCmd += " X > %s" % outFile + self.__payloadCmd += " X > \"%s\"" % outFile def __runMsfCliSmbrelay(self): self.__forgeMsfCliCmdForSmbrelay() @@ -528,7 +528,7 @@ class Metasploit: debugMsg = "the shellcode size is %d bytes" % payloadSize logger.debug(debugMsg) else: - errMsg = "failed to create the shellcode (%s)" % payloadStderr.replace("\n", "") + errMsg = "failed to create the shellcode (%s)" % payloadStderr.replace("\n", " ").replace("\r", "") raise sqlmapFilePathException, errMsg self.__shellcodeFP = codecs.open(self.__shellcodeFilePath, "rb")