Mirror of metasploit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

console.rb 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Parsed options for {Metasploit::Framework::Command::Console}
  2. class Metasploit::Framework::ParsedOptions::Console < Metasploit::Framework::ParsedOptions::Base
  3. # Options parsed from msfconsole command-line.
  4. #
  5. # @return [ActiveSupport::OrderedOptions]
  6. def options
  7. unless @options
  8. super.tap { |options|
  9. options.console = ActiveSupport::OrderedOptions.new
  10. options.console.commands = []
  11. options.console.confirm_exit = false
  12. options.console.histfile = nil
  13. options.console.local_output = nil
  14. options.console.plugins = []
  15. options.console.quiet = false
  16. options.console.real_readline = false
  17. options.console.resources = []
  18. options.console.subcommand = :run
  19. }
  20. end
  21. @options
  22. end
  23. private
  24. # Parses msfconsole arguments into {#options}.
  25. #
  26. # @return [OptionParser]
  27. def option_parser
  28. unless @option_parser
  29. super.tap { |option_parser|
  30. option_parser.banner = "Usage: #{option_parser.program_name} [options]"
  31. option_parser.separator 'Console options:'
  32. option_parser.on('-a', '--ask', "Ask before exiting Metasploit or accept 'exit -y'") do
  33. options.console.confirm_exit = true
  34. end
  35. option_parser.on('-H', '--history-file FILE', 'Save command history to the specified file') do |file|
  36. options.console.histfile = file
  37. end
  38. option_parser.on('-L', '--real-readline', 'Use the system Readline library instead of RbReadline') do
  39. options.console.real_readline = true
  40. end
  41. option_parser.on('-o', '--output FILE', 'Output to the specified file') do |file|
  42. options.console.local_output = file
  43. end
  44. option_parser.on('-p', '--plugin PLUGIN', 'Load a plugin on startup') do |plugin|
  45. options.console.plugins << plugin
  46. end
  47. option_parser.on('-q', '--quiet', 'Do not print the banner on startup') do
  48. options.console.quiet = true
  49. end
  50. option_parser.on('-r', '--resource FILE', 'Execute the specified resource file (- for stdin)') do |file|
  51. options.console.resources << file
  52. end
  53. option_parser.on(
  54. '-x',
  55. '--execute-command COMMAND',
  56. 'Execute the specified console commands (use ; for multiples)'
  57. ) do |commands|
  58. options.console.commands += commands.split(/\s*;\s*/)
  59. end
  60. }
  61. end
  62. @option_parser
  63. end
  64. end