Skip to content

Commit 8fa666b

Browse files
author
HD Moore
committed
Verbose messages on why a connection is closed
1 parent 4966082 commit 8fa666b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lib/msf/core/exploit/smb.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -760,13 +760,15 @@ def smb_recv(c)
760760
# Handle any number of errors that a read can trigger depending on socket state
761761
rescue ::IOError, ::EOFError,
762762
::Errno::ECONNRESET, ::Errno::ENOTCONN, ::Errno::ECONNABORTED,
763-
::Errno::ETIMEDOUT, ::Errno::ENETRESET, ::Errno::ESHUTDOWN
763+
::Errno::ETIMEDOUT, ::Errno::ENETRESET, ::Errno::ESHUTDOWN
764+
vprint_status("Dropping connection from #{smb[:name]} due to exception: #{$!.class} #{$!}")
764765
smb_stop(c)
765766
return
766767
end
767768

768769
# The client said it had data, but lied, kill the session
769770
unless buff and buff.length > 0
771+
vprint_status("Dropping connection from #{smb[:name]} due to empty payload...")
770772
smb_stop(c)
771773
return
772774
end
@@ -776,6 +778,7 @@ def smb_recv(c)
776778

777779
# Prevent a simplistic DoS if the buffer is too big
778780
if smb[:data].length > (1024*1024*datastore['SMBServerMaximumBuffer'])
781+
vprint_status("Dropping connection from #{smb[:name]} due to oversized buffer of #{smb[:data].length} bytes...")
779782
smb_stop(c)
780783
return
781784
end
@@ -823,10 +826,11 @@ def smb_recv(c)
823826
pkt = CONST::SMB_BASE_PKT.make_struct
824827
pkt.from_s(buff)
825828

826-
# Only response to requests, ignore server replies
829+
# Only respond to requests, ignore server replies
827830
if (pkt['Payload']['SMB'].v['Flags1'] & 128 != 0)
828-
print_status("Ignoring server response from #{smb[:name]}")
829-
next
831+
vprint_status("Dropping connection from #{smb[:name]} due to missing client request flag")
832+
smb_stop(c)
833+
return
830834
end
831835

832836
cmd = pkt['Payload']['SMB'].v['Command']
@@ -895,7 +899,10 @@ def smb_pool_update(c)
895899
end
896900

897901
# Purge any idle connections to rescue file descriptors
898-
purge_list.each { |sc| smb_stop(sc) }
902+
purge_list.each do |sc|
903+
vprint_status("Dropping connection from #{@state[sc][:name]} due to idle timeout...")
904+
smb_stop(sc)
905+
end
899906
end
900907
end
901908

0 commit comments

Comments
 (0)