Skip to content

Commit a587975

Browse files
author
Brent Cook
committed
be more robust and careful breaking from the accept thread
1 parent 91700f1 commit a587975

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/msf/core/handler/reverse_tcp.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,18 @@ def start_handler
9191
# Accept a client connection
9292
begin
9393
client = listener_sock.accept
94-
if !client
95-
wlog("#{handler_name}: No client received in call to accept, exiting...")
96-
else
94+
if client
9795
self.pending_connections += 1
9896
lqueue.push(client)
9997
end
100-
rescue StandardError
101-
wlog("#{handler_name}: Exception raised during listener accept: #{$ERROR_INFO}\n\n#{$ERROR_POSITION.join("\n")}")
102-
break
98+
rescue Errno::ENOTCONN
99+
nil
100+
rescue StandardError => e
101+
wlog [
102+
"#{handler_name}: Exception raised during listener accept: #{e.class}",
103+
"#{$ERROR_INFO}",
104+
"#{$ERROR_POSITION.join("\n")}"
105+
].join("\n")
103106
end
104107
end
105108
}

0 commit comments

Comments
 (0)