@@ -55,31 +55,25 @@ def commands
55
55
}
56
56
end
57
57
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 ) )
69
67
end
70
- rescue StandardError
71
68
end
72
- client . close
69
+ rescue StandardError
73
70
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
82
72
end
73
+ rescue EOFError
74
+ ensure
75
+ server . close if server
76
+ File . delete ( socket_path ) if File . exist? ( socket_path )
83
77
end
84
78
85
79
#
@@ -90,7 +84,7 @@ def cmd_fzuse(*args)
90
84
91
85
Dir . mktmpdir ( 'msf-fzuse-' ) do |dir |
92
86
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 ) }
94
88
95
89
query = args . empty? ? '' : args . first
96
90
ruby = RbConfig ::CONFIG [ 'bindir' ] + '/' + RbConfig ::CONFIG [ 'ruby_install_name' ] + RbConfig ::CONFIG [ 'EXEEXT' ]
@@ -120,6 +114,12 @@ def cmd_fzuse(*args)
120
114
def initialize ( framework , opts )
121
115
super
122
116
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
+
123
123
missing_requirements = [ ]
124
124
missing_requirements << 'fzf' unless Msf ::Util ::Helper . which ( 'fzf' )
125
125
0 commit comments