@@ -55,31 +55,25 @@ def commands
5555 }
5656 end
5757
58- def start_pipe_server ( socket_path )
59- def pipe_server ( socket_path )
60- server = UNIXServer . new ( socket_path )
61- File . chmod ( 0600 , socket_path )
62- loop do
63- client = server . accept
64- begin
65- unless ( input_string = client . gets &.chomp ) . blank?
66- if ( mod = framework . modules . create ( input_string ) )
67- client . puts ( Serializer ::ReadableText . dump_module ( mod ) )
68- end
58+ def pipe_server ( socket_path )
59+ server = UNIXServer . new ( socket_path )
60+ File . chmod ( 0600 , socket_path )
61+ loop do
62+ client = server . accept
63+ begin
64+ unless ( input_string = client . gets &.chomp ) . blank?
65+ if ( mod = framework . modules . create ( input_string ) )
66+ client . puts ( Serializer ::ReadableText . dump_module ( mod ) )
6967 end
70- rescue StandardError
7168 end
72- client . close
69+ rescue StandardError
7370 end
74- rescue EOFError
75- ensure
76- server . close if server
77- File . delete ( socket_path ) if File . exist? ( socket_path )
78- end
79-
80- Thread . new do
81- pipe_server ( socket_path )
71+ client . close
8272 end
73+ rescue EOFError
74+ ensure
75+ server . close if server
76+ File . delete ( socket_path ) if File . exist? ( socket_path )
8377 end
8478
8579 #
@@ -90,7 +84,7 @@ def cmd_fzuse(*args)
9084
9185 Dir . mktmpdir ( 'msf-fzuse-' ) do |dir |
9286 socket_path = File . join ( dir , "msf-fzuse.sock" )
93- server_thread = start_pipe_server ( socket_path )
87+ server_thread = Thread . new { pipe_server ( socket_path ) }
9488
9589 query = args . empty? ? '' : args . first
9690 ruby = RbConfig ::CONFIG [ 'bindir' ] + '/' + RbConfig ::CONFIG [ 'ruby_install_name' ] + RbConfig ::CONFIG [ 'EXEEXT' ]
@@ -120,6 +114,12 @@ def cmd_fzuse(*args)
120114 def initialize ( framework , opts )
121115 super
122116
117+ unless defined? ( UNIXSocket )
118+ # This isn't a requirement that can be fixed by installing something
119+ print_error ( "The FuzzyUse plugin has loaded but the Ruby environment does not support UNIX sockets." )
120+ return
121+ end
122+
123123 missing_requirements = [ ]
124124 missing_requirements << 'fzf' unless Msf ::Util ::Helper . which ( 'fzf' )
125125
0 commit comments