Skip to content

Commit 7dc6aa3

Browse files
committed
Rescue when the service is crashed
Failed exploit attempts leave the service in a state where the port is still open but login attmempts reset the connection. Rescue that and give the user an indication of what's going on.
1 parent 469f04d commit 7dc6aa3

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

modules/exploits/windows/smb/ms08_067_netapi.rb

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,8 +807,18 @@ def initialize(info = {})
807807

808808
def exploit
809809

810-
connect()
811-
smb_login()
810+
begin
811+
connect()
812+
smb_login()
813+
rescue Rex::Proto::SMB::Exceptions::LoginError => e
814+
if (e.message =~ /Connection reset/)
815+
print_error("Connection reset during login")
816+
print_error("This most likely means a previous exploit attempt caused the service to crash")
817+
return
818+
else
819+
raise e
820+
end
821+
end
812822

813823
# Use a copy of the target
814824
mytarget = target
@@ -1052,6 +1062,14 @@ def check
10521062
rescue Rex::ConnectionError => e
10531063
print_error("Connection failed: #{e.class}: #{e}")
10541064
return
1065+
rescue Rex::Proto::SMB::Exceptions::LoginError => e
1066+
if (e.message =~ /Connection reset/)
1067+
print_error("Connection reset during login")
1068+
print_error("This most likely means a previous exploit attempt caused the service to crash")
1069+
return Msf::Exploit::CheckCode::Unknown
1070+
else
1071+
raise e
1072+
end
10551073
end
10561074

10571075
#

0 commit comments

Comments
 (0)