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.

msfconsole 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/usr/bin/env ruby
  2. #
  3. # This user interface provides users with a command console interface to the
  4. # framework.
  5. #
  6. msfbase = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
  7. $:.unshift(File.join(File.dirname(msfbase), 'lib'))
  8. require 'rex'
  9. require 'msf/ui'
  10. require 'optparse'
  11. if(RUBY_PLATFORM =~ /mswin32/)
  12. $stderr.puts "[*] The msfconsole interface is not supported on the native Windows Ruby\n"
  13. $stderr.puts " interpreter. Things will break, exploits will fail, payloads will not\n"
  14. $stderr.puts " be handled correctly. Please use the msfweb 'console' or install \n"
  15. $stderr.puts " Cygwin or Linux in VMWare.\n\n"
  16. end
  17. class OptsConsole
  18. #
  19. # Return a hash describing the options.
  20. #
  21. def self.parse(args)
  22. options = {}
  23. opts = OptionParser.new do |opts|
  24. opts.banner = "Usage: msfconsole [options]"
  25. opts.separator ""
  26. opts.separator "Specific options:"
  27. opts.on("-d", "-d", "Execute the console as defanged") do
  28. options['Defanged'] = true
  29. end
  30. opts.on("-r", "-r <filename>", "Execute the specified resource file") do |r|
  31. options['Resource'] = r
  32. end
  33. opts.on("-c", "-c <filename>", "Load the specified configuration file") do |c|
  34. options['Config'] = c
  35. end
  36. # Boolean switch.
  37. opts.on("-v", "--version", "Show version") do |v|
  38. options['Version'] = true
  39. end
  40. opts.separator ""
  41. opts.separator "Common options:"
  42. opts.on_tail("-h", "--help", "Show this message") do
  43. puts opts
  44. exit
  45. end
  46. end
  47. opts.parse!(args)
  48. options
  49. end
  50. end
  51. options = OptsConsole.parse(ARGV)
  52. if (options['Version'])
  53. $stderr.puts 'Framework Version: ' + Msf::Framework::Version
  54. exit
  55. end
  56. begin
  57. Msf::Ui::Console::Driver.new(
  58. Msf::Ui::Console::Driver::DefaultPrompt,
  59. Msf::Ui::Console::Driver::DefaultPromptChar,
  60. options
  61. ).run
  62. rescue Interrupt
  63. end