From 4b23d2dc58fa95cd3fe0be6ac8fef03499514dcd Mon Sep 17 00:00:00 2001 From: Nicholas Starke Date: Wed, 11 May 2016 17:18:51 -0500 Subject: [PATCH] Adjusting exception handling This commit adjusts the error handling to close the socket before calling fail_with and adds specific exceptions to catch --- .../http/tp_link_sc2020n_authenticated_telnet_injection.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/exploits/linux/http/tp_link_sc2020n_authenticated_telnet_injection.rb b/modules/exploits/linux/http/tp_link_sc2020n_authenticated_telnet_injection.rb index 12c236376c..78c464ca15 100644 --- a/modules/exploits/linux/http/tp_link_sc2020n_authenticated_telnet_injection.rb +++ b/modules/exploits/linux/http/tp_link_sc2020n_authenticated_telnet_injection.rb @@ -128,9 +128,9 @@ class MetasploitModule < Msf::Exploit::Remote end handler(sock) - rescue - fail_with(Failure::Unknown, "Unknown error") - sock.close + rescue Rex::AddressInUse, ::Errno::ETIMEDOUT, Rex::HostUnreachable, Rex::ConnectionTimeout, Rex::ConnectionRefused, ::Timeout::Error, ::EOFError => e + sock.close if sock + fail_with(Failure::Unknown, e.message) end end