Proper fix for IPv6 postgresql connections

unstable
HD Moore 2012-01-31 02:08:02 -06:00
parent a74cf1ee10
commit 77c986948c
2 changed files with 7 additions and 1 deletions

View File

@ -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)

View File

@ -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'
)