Skip to content

Commit 8da6e0b

Browse files
committed
Fix bugs
1 parent 5b8d9e1 commit 8da6e0b

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

tools/module_reference.rb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,12 @@ def types
5757
"-f" => [ true, "Filter based on Module Type [All,Exploit,Payload,Post,NOP,Encoder,Auxiliary] (Default = ALL)."],
5858
"-t" => [ true, "Type of Reference to sort by #{types.keys}"],
5959
"-x" => [ true, "String or RegEx to try and match against the Reference Field"],
60-
"-o" => [ false, "Save the results to a file"]
60+
"-o" => [ true, "Save the results to a file"]
6161
)
6262

6363
flags = []
6464

6565
opts.parse(ARGV) { |opt, idx, val|
66-
val = (val || '').upcase
6766
case opt
6867
when "-h"
6968
puts "\nMetasploit Script for Displaying Module Reference information."
@@ -88,6 +87,7 @@ def types
8887
flags << "Module Filter: #{val}"
8988
filter = val
9089
when "-t"
90+
val = (val || '').upcase
9191
unless types.has_key(val)
9292
puts "Invalid Type Supplied: #{val}"
9393
puts "Please use one of these: #{types.keys.inspect}"
@@ -153,12 +153,12 @@ def is_url_alive?(uri)
153153

154154
def save_results(path, results)
155155
begin
156-
File.new(path, 'wb') do |f|
156+
File.open(path, 'wb') do |f|
157157
f.write(results)
158158
end
159159
puts "Results saved to: #{path}"
160-
rescue
161-
puts "Failed to save the file"
160+
rescue Exception => e
161+
puts "Failed to save the file: #{e.message}"
162162
end
163163
end
164164

@@ -234,10 +234,7 @@ def save_results(path, results)
234234

235235
puts
236236
puts tbl.to_s
237+
puts
237238

238-
if check
239-
puts
240-
puts "Number of bad references found: #{bad_refs_count}"
241-
end
242-
239+
puts "Number of bad references found: #{bad_refs_count}" if check
243240
save_results(save, tbl.to_s) if save

0 commit comments

Comments
 (0)