Skip to content

Commit ac03b7c

Browse files
committed
Use sorted sets extension lists
1 parent 117cd8b commit ac03b7c

File tree

1 file changed

+7
-6
lines changed
  • lib/rex/post/meterpreter/ui/console/command_dispatcher

1 file changed

+7
-6
lines changed

lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: binary -*-
2+
require 'set'
23
require 'rex/post/meterpreter'
34
require 'rex/parser/arguments'
45

@@ -416,17 +417,17 @@ def cmd_load(*args)
416417
@@load_opts.parse(args) { |opt, idx, val|
417418
case opt
418419
when "-l"
419-
exts = []
420+
exts = SortedSet.new
420421
msf_path = MeterpreterBinaries.metasploit_data_dir
421422
gem_path = MeterpreterBinaries.local_dir
422423
[msf_path, gem_path].each do |path|
423424
::Dir.entries(path).each { |f|
424425
if (::File.file?(::File.join(path, f)) && f =~ /ext_server_(.*)\.#{client.binary_suffix}/ )
425-
exts.push($1) unless exts.include?($1)
426+
exts.add($1)
426427
end
427428
}
428429
end
429-
print(exts.sort.join("\n") + "\n")
430+
print(exts.to_a.join("\n") + "\n")
430431

431432
return true
432433
when "-h"
@@ -464,19 +465,19 @@ def cmd_load(*args)
464465
end
465466

466467
def cmd_load_tabs(str, words)
467-
tabs = []
468+
tabs = SortedSet.new
468469
msf_path = MeterpreterBinaries.metasploit_data_dir
469470
gem_path = MeterpreterBinaries.local_dir
470471
[msf_path, gem_path].each do |path|
471472
::Dir.entries(path).each { |f|
472473
if (::File.file?(::File.join(path, f)) && f =~ /ext_server_(.*)\.#{client.binary_suffix}/ )
473474
if (not extensions.include?($1))
474-
tabs.push($1) unless tabs.include?($1)
475+
tabs.add($1)
475476
end
476477
end
477478
}
478479
end
479-
return tabs
480+
return tabs.to_a
480481
end
481482

482483
def cmd_use(*args)

0 commit comments

Comments
 (0)