@@ -40,12 +40,12 @@ def run_host(ip)
40
40
41
41
# Alias for RHOST
42
42
def rhost
43
- datastore [ 'RHOST' ]
43
+ postgres_conn &. peerhost || datastore [ 'RHOST' ]
44
44
end
45
45
46
46
# Alias for RPORT
47
47
def rport
48
- datastore [ 'RPORT' ]
48
+ postgres_conn &. peerport || datastore [ 'RPORT' ]
49
49
end
50
50
51
51
def report_cred ( opts )
@@ -85,27 +85,27 @@ def do_fingerprint(user=nil,pass=nil,database=nil)
85
85
:password => password
86
86
)
87
87
if result [ :auth ]
88
- vprint_good "#{ postgres_conn . peerhost } :#{ postgres_conn . peerport } Postgres - Logged in to '#{ database } ' with '#{ user } ':'#{ password } '" unless session
89
- print_status "#{ postgres_conn . peerhost } :#{ postgres_conn . peerport } Postgres - Version #{ result [ :auth ] } (Post-Auth)"
88
+ vprint_good "#{ rhost } :#{ rport } Postgres - Logged in to '#{ database } ' with '#{ user } ':'#{ password } '" unless session
89
+ print_status "#{ rhost } :#{ rport } Postgres - Version #{ result [ :auth ] } (Post-Auth)"
90
90
elsif result [ :preauth ]
91
- print_good "#{ postgres_conn . peerhost } :#{ postgres_conn . peerport } Postgres - Version #{ result [ :preauth ] } (Pre-Auth)"
91
+ print_good "#{ rhost } :#{ rport } Postgres - Version #{ result [ :preauth ] } (Pre-Auth)"
92
92
else # It's something we don't know yet
93
- vprint_status "#{ postgres_conn . peerhost } :#{ postgres_conn . peerport } Postgres - Authentication Error Fingerprint: #{ result [ :unknown ] } "
94
- print_status "#{ postgres_conn . peerhost } :#{ postgres_conn . peerport } Postgres - Version Unknown (Pre-Auth)"
93
+ vprint_status "#{ rhost } :#{ rport } Postgres - Authentication Error Fingerprint: #{ result [ :unknown ] } "
94
+ print_status "#{ rhost } :#{ rport } Postgres - Version Unknown (Pre-Auth)"
95
95
end
96
96
97
97
# Reporting
98
98
report_service (
99
- :host => postgres_conn . peerhost ,
100
- :port => postgres_conn . peerport ,
99
+ :host => rhost ,
100
+ :port => rport ,
101
101
:name => "postgres" ,
102
102
:info => result . values . first
103
103
)
104
104
105
105
if self . postgres_conn
106
106
report_cred (
107
- ip : postgres_conn . peerhost ,
108
- port : postgres_conn . peerport ,
107
+ ip : rhost ,
108
+ port : rport ,
109
109
service_name : 'postgres' ,
110
110
user : user ,
111
111
password : password ,
@@ -115,10 +115,10 @@ def do_fingerprint(user=nil,pass=nil,database=nil)
115
115
116
116
if result [ :unknown ]
117
117
report_note (
118
- :host => postgres_conn . peerhost ,
118
+ :host => rhost ,
119
119
:proto => 'tcp' ,
120
120
:sname => 'postgres' ,
121
- :port => postgres_conn . peerport ,
121
+ :port => rport ,
122
122
:ntype => 'postgresql.fingerprint' ,
123
123
:data => "Unknown Pre-Auth fingerprint: #{ result [ :unknown ] } "
124
124
)
0 commit comments