add help for several meterp commands and allow the channel command to do everything the associated with channels (list, interact, read, write, close)

git-svn-id: file:///home/svn/framework3/trunk@12341 4d416f70-5f16-0410-b530-b9f4589650da
unstable
James Lee 2011-04-17 00:34:45 +00:00
parent 86ef20a6c2
commit c14580adf3
1 changed files with 76 additions and 25 deletions

View File

@ -72,6 +72,13 @@ class Console::CommandDispatcher::Core
"Core" "Core"
end end
def cmd_background_help
print_line "Usage: background"
print_line
print_line "Stop interacting with this session and return to the parent prompt"
print_line
end
def cmd_background def cmd_background
client.interacting = false client.interacting = false
end end
@ -80,37 +87,61 @@ class Console::CommandDispatcher::Core
# Displays information about active channels # Displays information about active channels
# #
@@channel_opts = Rex::Parser::Arguments.new( @@channel_opts = Rex::Parser::Arguments.new(
"-c" => [ true, "Close the given channel." ],
"-i" => [ true, "Interact with the given channel." ],
"-l" => [ false, "List active channels." ], "-l" => [ false, "List active channels." ],
"-h" => [ false, "Help menu." ]) "-r" => [ true, "Read from the given channel." ],
"-w" => [ true, "Write to the given channel." ],
"-h" => [ false, "Help menu." ])
def cmd_channel_help
print_line "Usage: channel [options]"
print_line
print_line "Displays information about active channels."
print_line @@channel_opts.usage
end
# #
# Performs operations on the supplied channel. # Performs operations on the supplied channel.
# #
def cmd_channel(*args) def cmd_channel(*args)
if (args.length == 0) if args.include?("-h") or args.include?("--help"))
args.unshift("-h") cmd_channel_help
return
end end
mode = nil mode = nil
chan = nil
data = []
# Parse options # Parse options
@@channel_opts.parse(args) { |opt, idx, val| @@channel_opts.parse(args) { |opt, idx, val|
case opt case opt
when "-h" when "-l"
print( mode = :list
"Usage: channel [options]\n\n" + when "-c"
"Displays information about active channels.\n" + mode = :close
@@channel_opts.usage) chan = val
return true when "-i"
when "-l" mode = :interact
mode = 'list' chan = val
when "-r"
mode = :read
chan = val
when "-w"
mode = :write
chan = val
end
if @@channel_opts.arg_required?(opt)
unless chan
print_error("Channel ID required")
return
end
end end
} }
# No mode, no service. case mode
if (mode == nil) when :list
return true
elsif (mode == 'list')
tbl = Rex::Ui::Text::Table.new( tbl = Rex::Ui::Text::Table.new(
'Indent' => 4, 'Indent' => 4,
'Columns' => 'Columns' =>
@ -131,6 +162,17 @@ class Console::CommandDispatcher::Core
else else
print("\n" + tbl.to_s + "\n") print("\n" + tbl.to_s + "\n")
end end
when :close
cmd_close(chan)
when :interact
cmd_interact(chan)
when :read
cmd_read(chan)
when :write
cmd_write(chan)
else
# No mode, no service.
return true
end end
end end
@ -485,6 +527,13 @@ class Console::CommandDispatcher::Core
end end
end end
def cmd_info_help
print_line 'Usage: info <module>'
print_line
print_line 'Prints information about a post-exploitation module'
print_line
end
# #
# Show info for a given Post module. # Show info for a given Post module.
# #
@ -493,8 +542,8 @@ class Console::CommandDispatcher::Core
def cmd_info(*args) def cmd_info(*args)
return unless msf_loaded? return unless msf_loaded?
if args.length != 1 if args.length != 1 or args.include?("-h")
print_error 'Usage: info <module>' cmd_info_help
return return
end end
@ -522,9 +571,17 @@ class Console::CommandDispatcher::Core
"-f" => [ true, "Write the contents of a file on disk" ], "-f" => [ true, "Write the contents of a file on disk" ],
"-h" => [ false, "Help menu." ]) "-h" => [ false, "Help menu." ])
def cmd_write_help
print_line "Usage: write [options] channel_id"
print_line
print_line "Writes data to the supplied channel."
print_line @@write_opts.usage
end
def cmd_write(*args) def cmd_write(*args)
if (args.length == 0) if (args.length == 0 or args.include?("-h"))
args.unshift("-h") cmd_write_help
return
end end
src_file = nil src_file = nil
@ -532,12 +589,6 @@ class Console::CommandDispatcher::Core
@@write_opts.parse(args) { |opt, idx, val| @@write_opts.parse(args) { |opt, idx, val|
case opt case opt
when "-h"
print(
"Usage: write [options] channel_id\n\n" +
"Writes data to the supplied channel.\n" +
@@write_opts.usage)
return true
when "-f" when "-f"
src_file = val src_file = val
else else