Add multiple commands' tabs and help

GSoC/Meterpreter_Web_Console
Green-m 2018-07-26 05:25:38 -04:00
parent 6a0534de14
commit 6c1a28d2d6
1 changed files with 63 additions and 7 deletions

View File

@ -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 <script> [arguments]')
print_line
print_line('Executes a ruby script in the context of the meterpreter session.')
@ -1420,7 +1470,7 @@ class Console::CommandDispatcher::Core
# Kill a background job
#
def cmd_bgkill(*args)
if args.length == 0
if args.length == 0 || args.include?("-h")
print_line('Usage: bgkill [id]')
return
end
@ -1501,6 +1551,12 @@ class Console::CommandDispatcher::Core
print_line(@@write_opts.usage)
end
def cmd_write_tabs(str, words)
return tab_complete_filenames(str, words) if words[-1] == '-f'
return tab_complete_channels
end
def cmd_write(*args)
if args.length == 0 || args.include?("-h")
cmd_write_help