diff --git a/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb b/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb index 88762dc605..09a63403e9 100644 --- a/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb +++ b/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb @@ -1,4 +1,5 @@ # -*- coding: binary -*- +require 'set' require 'rex/post/meterpreter' require 'rex/parser/arguments' @@ -416,17 +417,17 @@ class Console::CommandDispatcher::Core @@load_opts.parse(args) { |opt, idx, val| case opt when "-l" - exts = [] + exts = SortedSet.new msf_path = MeterpreterBinaries.metasploit_data_dir gem_path = MeterpreterBinaries.local_dir [msf_path, gem_path].each do |path| ::Dir.entries(path).each { |f| if (::File.file?(::File.join(path, f)) && f =~ /ext_server_(.*)\.#{client.binary_suffix}/ ) - exts.push($1) unless exts.include?($1) + exts.add($1) end } end - print(exts.sort.join("\n") + "\n") + print(exts.to_a.join("\n") + "\n") return true when "-h" @@ -464,19 +465,19 @@ class Console::CommandDispatcher::Core end def cmd_load_tabs(str, words) - tabs = [] + tabs = SortedSet.new msf_path = MeterpreterBinaries.metasploit_data_dir gem_path = MeterpreterBinaries.local_dir [msf_path, gem_path].each do |path| ::Dir.entries(path).each { |f| if (::File.file?(::File.join(path, f)) && f =~ /ext_server_(.*)\.#{client.binary_suffix}/ ) if (not extensions.include?($1)) - tabs.push($1) unless tabs.include?($1) + tabs.add($1) end end } end - return tabs + return tabs.to_a end def cmd_use(*args)