Skip to content

Commit 9fbda3e

Browse files
committed
Land rapid7#3183, tab completion improvements
2 parents fdbfaac + aecd13d commit 9fbda3e

File tree

1 file changed

+32
-2
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+32
-2
lines changed

lib/msf/ui/console/command_dispatcher/core.rb

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,6 +2022,19 @@ def cmd_set_tabs(str, words)
20222022
end
20232023
end
20242024

2025+
unless str.blank?
2026+
res = res.select { |term| term.upcase.start_with?(str.upcase) }
2027+
res = res.map { |term|
2028+
if str == str.upcase
2029+
str + term[str.length..-1].upcase
2030+
elsif str == str.downcase
2031+
str + term[str.length..-1].downcase
2032+
else
2033+
str + term[str.length..-1]
2034+
end
2035+
}
2036+
end
2037+
20252038
return res
20262039
end
20272040

@@ -2719,13 +2732,17 @@ def tab_complete_option(str, words)
27192732
# Is this option used by the active module?
27202733
if (mod.options.include?(opt))
27212734
res.concat(option_values_dispatch(mod.options[opt], str, words))
2735+
elsif (mod.options.include?(opt.upcase))
2736+
res.concat(option_values_dispatch(mod.options[opt.upcase], str, words))
27222737
end
27232738

27242739
# How about the selected payload?
27252740
if (mod.exploit? and mod.datastore['PAYLOAD'])
27262741
p = framework.payloads.create(mod.datastore['PAYLOAD'])
27272742
if (p and p.options.include?(opt))
27282743
res.concat(option_values_dispatch(p.options[opt], str, words))
2744+
elsif (p and p.options.include?(opt.upcase))
2745+
res.concat(option_values_dispatch(p.options[opt.upcase], str, words))
27292746
end
27302747
end
27312748

@@ -2759,8 +2776,10 @@ def option_values_dispatch(o, str, words)
27592776
end
27602777

27612778
when 'Msf::OptAddressRange'
2762-
27632779
case str
2780+
when /^file:(.*)/
2781+
files = tab_complete_filenames($1, words)
2782+
res += files.map { |f| "file:" + f } if files
27642783
when /\/$/
27652784
res << str+'32'
27662785
res << str+'24'
@@ -2791,9 +2810,20 @@ def option_values_dispatch(o, str, words)
27912810
o.enums.each do |val|
27922811
res << val
27932812
end
2813+
27942814
when 'Msf::OptPath'
2795-
files = tab_complete_filenames(str,words)
2815+
files = tab_complete_filenames(str, words)
27962816
res += files if files
2817+
2818+
when 'Msf::OptBool'
2819+
res << 'true'
2820+
res << 'false'
2821+
2822+
when 'Msf::OptString'
2823+
if (str =~ /^file:(.*)/)
2824+
files = tab_complete_filenames($1, words)
2825+
res += files.map { |f| "file:" + f } if files
2826+
end
27972827
end
27982828

27992829
return res

0 commit comments

Comments
 (0)