Skip to content

Commit 1462330

Browse files
committed
Add tab completion to the payload generate command
1 parent c361846 commit 1462330

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Payload
1313
include Msf::Ui::Console::ModuleCommandDispatcher
1414

1515
# Load supported formats
16-
supported_formats = \
16+
@@supported_formats = \
1717
Msf::Simple::Buffer.transform_formats + \
1818
Msf::Util::EXE.to_executable_fmt_formats
1919

@@ -25,7 +25,7 @@ class Payload
2525
"-o" => [ true, "A comma separated list of options in VAR=VAL format." ],
2626
"-s" => [ true, "NOP sled length." ],
2727
"-f" => [ true, "The output file name (otherwise stdout)" ],
28-
"-t" => [ true, "The output format: #{supported_formats.join(',')}" ],
28+
"-t" => [ true, "The output format: #{@@supported_formats.join(',')}" ],
2929
"-p" => [ true, "The Platform for output." ],
3030
"-k" => [ false, "Keep the template executable functional" ],
3131
"-x" => [ true, "The executable template to use" ],
@@ -151,6 +151,25 @@ def cmd_generate(*args)
151151
end
152152
true
153153
end
154+
155+
def cmd_generate_tabs(str, words)
156+
last_word = words[-1]
157+
fmt = @@generate_opts.fmt
158+
fmt = fmt.select { |key, value| last_word == key || !words.include?(key) }
159+
160+
option = fmt[last_word]
161+
return fmt.keys if !option || !option[0]
162+
163+
tabs = []
164+
case last_word
165+
when '-e'
166+
tabs = framework.encoders.map { |refname, mod| refname }
167+
when '-f'
168+
tabs = tab_complete_filenames(str, words)
169+
when '-t'
170+
tabs = @@supported_formats
171+
end
172+
end
154173
end
155174
end
156175
end

0 commit comments

Comments
 (0)