Proper fix for IPv6 postgresql connections
parent
a74cf1ee10
commit
77c986948c
|
@ -160,7 +160,13 @@ module Exploit::Remote::Postgres
|
|||
password = args[:password] || datastore['PASSWORD']
|
||||
rhost = args[:server] || datastore['RHOST']
|
||||
rport = args[:port] || datastore['RPORT']
|
||||
|
||||
uri = "tcp://#{rhost}:#{rport}"
|
||||
if Rex::Socket.is_ipv6?(rhost)
|
||||
uri = "tcp://[#{rhost}]:#{rport}"
|
||||
end
|
||||
|
||||
|
||||
verbose = args[:verbose] || datastore['VERBOSE']
|
||||
begin
|
||||
self.postgres_conn = Connection.new(db,username,password,uri)
|
||||
|
|
|
@ -171,7 +171,7 @@ class Connection
|
|||
case u.scheme
|
||||
when 'tcp'
|
||||
@conn = Rex::Socket.create(
|
||||
'PeerHost' => (u.host || DEFAULT_HOST),
|
||||
'PeerHost' => (u.host || DEFAULT_HOST).gsub(/[\[\]]/, ''), # Strip any brackets off (IPv6)
|
||||
'PeerPort' => (u.port || DEFAULT_PORT),
|
||||
'proto' => 'tcp'
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue