From 6c1a28d2d6ef67eb577ebb515c243330831a1e5d Mon Sep 17 00:00:00 2001 From: Green-m Date: Thu, 26 Jul 2018 05:25:38 -0400 Subject: [PATCH] Add multiple commands' tabs and help --- .../ui/console/command_dispatcher/core.rb | 70 +++++++++++++++++-- 1 file changed, 63 insertions(+), 7 deletions(-) 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 6b813f0daa..a2e2d5709e 100644 --- a/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb +++ b/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb @@ -157,6 +157,27 @@ class Console::CommandDispatcher::Core print_line end + def cmd_pivot_tabs(str, words) + return ['list','add','remove'] + @@pivot_opts.fmt.keys if words.length == 1 + + case words[-1] + when '-a' + return @@pivot_supported_archs + when '-i' + matches = [] + client.pivot_listeners.each_value{|v|matches << v.id.unpack('H*')[0]} + return matches + when '-p' + return @@pivot_supported_platforms + when '-t' + return ['pipe'] + when 'add', 'remove' + return @@pivot_opts.fmt.keys + end + + [] + end + def cmd_pivot(*args) if args.length == 0 || args.include?('-h') cmd_pivot_help @@ -422,7 +443,7 @@ class Console::CommandDispatcher::Core # Closes a supplied channel. # def cmd_close(*args) - if args.length == 0 + if args.length == 0 || args.include?("-h") cmd_close_help return true end @@ -488,7 +509,7 @@ class Console::CommandDispatcher::Core # Interacts with a channel. # def cmd_interact(*args) - if args.length == 0 + if args.length == 0 || args.include?("-h") cmd_info_help return true end @@ -514,6 +535,11 @@ class Console::CommandDispatcher::Core print @@irb_opts.usage end + def cmd_irb_tabs(str, words) + return [] if words.length > 1 + @@irb_opts.fmt.keys + end + # # Runs the IRB scripting shell # @@ -559,6 +585,11 @@ class Console::CommandDispatcher::Core print_line(@@set_timeouts_opts.usage) end + def cmd_set_timeouts_tabs(str, words) + return [] if words.length > 1 + @@set_timeouts_opts.fmt.keys + end + def cmd_set_timeouts(*args) if args.length == 0 || args.include?('-h') cmd_set_timeouts_help @@ -732,7 +763,7 @@ class Console::CommandDispatcher::Core # Handle the sleep command. # def cmd_sleep(*args) - if args.length == 0 + if args.length == 0 || args.include?("-h") cmd_sleep_help return end @@ -792,6 +823,25 @@ class Console::CommandDispatcher::Core print_line(@@transport_opts.usage) end + def cmd_transport_tabs(str, words) + return ['list','change','add','next','prev','remove'] + @@transport_opts.fmt.keys if words.length == 1 + + case words[-1] + when '-c' + return tab_complete_filenames(str, words) + when '-i' + return (1..client.core.transport_list[:transports].length).to_a.map!(&:to_s) + when '-l' + return tab_complete_source_address + when '-t' + return ['reverse_tcp', 'reverse_http','reverse_https','bind_tcp'] + when 'add', 'remove', 'change' + return @@transport_opts.fmt.keys + end + + [] + end + def update_transport_map result = client.core.transport_list @transport_map.clear @@ -1270,7 +1320,7 @@ class Console::CommandDispatcher::Core # Reads data from a channel. # def cmd_read(*args) - if args.length == 0 + if args.length == 0 || args.include?("-h") cmd_read_help return true end @@ -1310,7 +1360,7 @@ class Console::CommandDispatcher::Core # Executes a script in the context of the meterpreter session. # def cmd_run(*args) - if args.length == 0 + if args.length == 0 || args.include?("-h") cmd_run_help return true end @@ -1380,7 +1430,7 @@ class Console::CommandDispatcher::Core # Executes a script in the context of the meterpreter session in the background # def cmd_bgrun(*args) - if args.length == 0 + if args.length == 0 || args.include?("-h") print_line('Usage: bgrun