Update for Issue #28

This commit is contained in:
Miroslav Stampar 2012-07-27 16:29:33 +02:00
parent 07738004cc
commit 6ffc5665d0
2 changed files with 24 additions and 1 deletions

View File

@ -588,6 +588,22 @@ def __setMetasploit():
msfEnvPathExists = False msfEnvPathExists = False
if IS_WIN: if IS_WIN:
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
return retVal
conf.msfPath = _(r"SOFTWARE\Rapid7\Metasploit", "Location")
warnMsg = "some sqlmap takeover functionalities are not yet " warnMsg = "some sqlmap takeover functionalities are not yet "
warnMsg += "supported on Windows. Please use Linux in a virtual " warnMsg += "supported on Windows. Please use Linux in a virtual "
warnMsg += "machine for out-of-band features." warnMsg += "machine for out-of-band features."
@ -607,7 +623,7 @@ def __setMetasploit():
raise sqlmapMissingPrivileges, errMsg raise sqlmapMissingPrivileges, errMsg
if conf.msfPath: if conf.msfPath:
for path in (conf.msfPath, os.path.join(conf.msfPath, 'bin')): for path in (conf.msfPath, os.path.join(conf.msfPath, "bin")):
if all(os.path.exists(normalizePath(os.path.join(path, _))) for _ in ("", "msfcli", "msfconsole", "msfencode", "msfpayload")): if all(os.path.exists(normalizePath(os.path.join(path, _))) for _ in ("", "msfcli", "msfconsole", "msfencode", "msfpayload")):
msfEnvPathExists = True msfEnvPathExists = True
conf.msfPath = path conf.msfPath = path

View File

@ -32,6 +32,7 @@ from lib.core.enums import DBMS
from lib.core.enums import OS from lib.core.enums import OS
from lib.core.exception import sqlmapDataException from lib.core.exception import sqlmapDataException
from lib.core.exception import sqlmapFilePathException from lib.core.exception import sqlmapFilePathException
from lib.core.settings import IS_WIN
from lib.core.settings import UNICODE_ENCODING from lib.core.settings import UNICODE_ENCODING
from lib.core.subprocessng import blockingReadFromFD from lib.core.subprocessng import blockingReadFromFD
from lib.core.subprocessng import blockingWriteToFD from lib.core.subprocessng import blockingWriteToFD
@ -58,6 +59,12 @@ class Metasploit:
self.__msfEncode = normalizePath(os.path.join(conf.msfPath, "msfencode")) self.__msfEncode = normalizePath(os.path.join(conf.msfPath, "msfencode"))
self.__msfPayload = normalizePath(os.path.join(conf.msfPath, "msfpayload")) self.__msfPayload = normalizePath(os.path.join(conf.msfPath, "msfpayload"))
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.__msfPayloadsList = { self.__msfPayloadsList = {
"windows": { "windows": {
1: ( "Meterpreter (default)", "windows/meterpreter" ), 1: ( "Meterpreter (default)", "windows/meterpreter" ),