better handling of LHOST vs 0.0.0.0; fixes #262 again

git-svn-id: file:///home/svn/framework3/trunk@5971 4d416f70-5f16-0410-b530-b9f4589650da
unstable
James Lee 2008-11-21 05:12:31 +00:00
parent fec1533b50
commit b76d3e1560
1 changed files with 22 additions and 12 deletions

View File

@ -57,12 +57,14 @@ module ReverseTcp
raise 'tcp connectback can not be used with proxies'
end
ex = false
# Switch to IPv6 ANY address if the LHOST is also IPv6
addr = Rex::Socket.resolv_nbo(datastore['LHOST'])
lsnr = (addr.length == 4) ? "0.0.0.0" : "::0"
[ Rex::Socket.addr_ntoa(addr), "0.0.0.0" ].each { |ip|
begin
print_status("Handler binding to LHOST #{ip}")
self.listener_sock = Rex::Socket::TcpServer.create(
'LocalHost' => lsnr,
'LocalHost' => ip,
'LocalPort' => datastore['LPORT'].to_i,
'Comm' => comm,
'Context' =>
@ -71,6 +73,14 @@ module ReverseTcp
'MsfPayload' => self,
'MsfExploit' => assoc_exploit
})
ex = false
break
rescue
ex = $!
print_error("Bind failed on #{ip}")
end
}
raise ex if (ex)
end
#