Skip to content

Commit

Permalink
Land #18992, Fix postgres version logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dwelch-r7 committed Mar 22, 2024
2 parents 11c24ec + acf9745 commit a674310
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions modules/auxiliary/scanner/postgres/postgres_version.rb
Expand Up @@ -40,12 +40,12 @@ def run_host(ip)

# Alias for RHOST
def rhost
datastore['RHOST']
postgres_conn&.peerhost || datastore['RHOST']
end

# Alias for RPORT
def rport
datastore['RPORT']
postgres_conn&.peerport || datastore['RPORT']
end

def report_cred(opts)
Expand Down Expand Up @@ -85,27 +85,27 @@ def do_fingerprint(user=nil,pass=nil,database=nil)
:password => password
)
if result[:auth]
vprint_good "#{postgres_conn.peerhost}:#{postgres_conn.peerport} Postgres - Logged in to '#{database}' with '#{user}':'#{password}'" unless session
print_status "#{postgres_conn.peerhost}:#{postgres_conn.peerport} Postgres - Version #{result[:auth]} (Post-Auth)"
vprint_good "#{rhost}:#{rport} Postgres - Logged in to '#{database}' with '#{user}':'#{password}'" unless session
print_status "#{rhost}:#{rport} Postgres - Version #{result[:auth]} (Post-Auth)"
elsif result[:preauth]
print_good "#{postgres_conn.peerhost}:#{postgres_conn.peerport} Postgres - Version #{result[:preauth]} (Pre-Auth)"
print_good "#{rhost}:#{rport} Postgres - Version #{result[:preauth]} (Pre-Auth)"
else # It's something we don't know yet
vprint_status "#{postgres_conn.peerhost}:#{postgres_conn.peerport} Postgres - Authentication Error Fingerprint: #{result[:unknown]}"
print_status "#{postgres_conn.peerhost}:#{postgres_conn.peerport} Postgres - Version Unknown (Pre-Auth)"
vprint_status "#{rhost}:#{rport} Postgres - Authentication Error Fingerprint: #{result[:unknown]}"
print_status "#{rhost}:#{rport} Postgres - Version Unknown (Pre-Auth)"
end

# Reporting
report_service(
:host => postgres_conn.peerhost,
:port => postgres_conn.peerport,
:host => rhost,
:port => rport,
:name => "postgres",
:info => result.values.first
)

if self.postgres_conn
report_cred(
ip: postgres_conn.peerhost,
port: postgres_conn.peerport,
ip: rhost,
port: rport,
service_name: 'postgres',
user: user,
password: password,
Expand All @@ -115,10 +115,10 @@ def do_fingerprint(user=nil,pass=nil,database=nil)

if result[:unknown]
report_note(
:host => postgres_conn.peerhost,
:host => rhost,
:proto => 'tcp',
:sname => 'postgres',
:port => postgres_conn.peerport,
:port => rport,
:ntype => 'postgresql.fingerprint',
:data => "Unknown Pre-Auth fingerprint: #{result[:unknown]}"
)
Expand Down

0 comments on commit a674310

Please sign in to comment.