diff --git a/modules/exploits/multi/postgres/postgres_createlang.rb b/modules/exploits/multi/postgres/postgres_createlang.rb index f403cf14d1..aac5818226 100644 --- a/modules/exploits/multi/postgres/postgres_createlang.rb +++ b/modules/exploits/multi/postgres/postgres_createlang.rb @@ -57,26 +57,24 @@ class MetasploitModule < Msf::Exploit::Remote deregister_options('SQL', 'RETURN_ROWSET', 'VERBOSE') end - def postgres_major_version(version) - version_match = version.match(/(?\w{10})\s(?\d{1,2})\.(?\d{1,2})\.(?\d{1,2})/) - version_match['major_version'] - end - def check - if vuln_version? - Exploit::CheckCode::Appears - else - Exploit::CheckCode::Safe - end + vuln_version? ? CheckCode::Appears : CheckCode::Safe end def vuln_version? version = postgres_fingerprint - if version[:auth] - major_version = postgres_major_version(version[:auth]) - return true if major_version && major_version.to_i >= 8 + + return unless version[:auth] + + vprint_status version[:auth].to_s + + version_full = version[:auth].to_s.scan(/^PostgreSQL ([\d\.]+)/i).flatten.first + + if Gem::Version.new(version_full) >= Gem::Version.new('8.0') + return true + else + return false end - false end def login_success?