Skip to content

Commit 3227e2e

Browse files
committed
Catch exceptions on client connections
1 parent caf79d8 commit 3227e2e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

plugins/fzuse.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,13 @@ def pipe_server(socket_path)
7878
File.chmod(0600, socket_path)
7979
loop do
8080
client = server.accept
81-
unless (input_string = client.gets&.chomp).blank?
82-
if (mod = framework.modules.create(input_string))
83-
client.puts(Serializer::ReadableText.dump_module(mod))
81+
begin
82+
unless (input_string = client.gets&.chomp).blank?
83+
if (mod = framework.modules.create(input_string))
84+
client.puts(Serializer::ReadableText.dump_module(mod))
85+
end
8486
end
87+
rescue StandardError
8588
end
8689
client.close
8790
end
@@ -103,7 +106,6 @@ def cmd_fzuse(*args)
103106
selection = nil
104107

105108
Dir.mktmpdir('msf-fzuse-') do |dir|
106-
File.chmod(0700, dir)
107109
socket_path = File.join(dir, "msf-fzuse.sock")
108110
server_thread = start_pipe_server(socket_path)
109111

@@ -122,6 +124,7 @@ def cmd_fzuse(*args)
122124
end
123125

124126
server_thread.kill
127+
server_thread.join
125128
end
126129

127130
return if selection.blank?

0 commit comments

Comments
 (0)