mirror of
https://github.com/rapid7/metasploit-framework
synced 2024-11-12 11:52:01 +01:00
58708378d1
git-svn-id: file:///home/svn/framework3/trunk@4462 4d416f70-5f16-0410-b530-b9f4589650da
84 lines
1.9 KiB
Ruby
Executable File
84 lines
1.9 KiB
Ruby
Executable File
#!/usr/bin/env ruby
|
|
#
|
|
# This user interface provides users with a command console interface to the
|
|
# framework.
|
|
#
|
|
|
|
msfbase = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
|
|
$:.unshift(File.join(File.dirname(msfbase), 'lib'))
|
|
|
|
require 'rex'
|
|
require 'msf/ui'
|
|
require 'optparse'
|
|
|
|
if(RUBY_PLATFORM =~ /mswin32/)
|
|
$stderr.puts "[*] The msfconsole interface is not supported on the native Windows Ruby\n"
|
|
$stderr.puts " interpreter. Things will break, exploits will fail, payloads will not\n"
|
|
$stderr.puts " be handled correctly. Please use the msfweb 'console' or install \n"
|
|
$stderr.puts " Cygwin or Linux in VMWare.\n\n"
|
|
end
|
|
|
|
class OptsConsole
|
|
#
|
|
# Return a hash describing the options.
|
|
#
|
|
def self.parse(args)
|
|
options = {}
|
|
|
|
opts = OptionParser.new do |opts|
|
|
opts.banner = "Usage: msfconsole [options]"
|
|
|
|
opts.separator ""
|
|
opts.separator "Specific options:"
|
|
|
|
opts.on("-d", "-d", "Execute the console as defanged") do
|
|
options['Defanged'] = true
|
|
end
|
|
|
|
opts.on("-r", "-r <filename>", "Execute the specified resource file") do |r|
|
|
options['Resource'] = r
|
|
end
|
|
|
|
opts.on("-c", "-c <filename>", "Load the specified configuration file") do |c|
|
|
options['Config'] = c
|
|
end
|
|
|
|
opts.on("-m", "-m <directory>", "Specifies an additional module search path") do |m|
|
|
options['ModulePath'] = m
|
|
end
|
|
|
|
# Boolean switch.
|
|
opts.on("-v", "--version", "Show version") do |v|
|
|
options['Version'] = true
|
|
end
|
|
|
|
opts.separator ""
|
|
opts.separator "Common options:"
|
|
|
|
opts.on_tail("-h", "--help", "Show this message") do
|
|
puts opts
|
|
exit
|
|
end
|
|
end
|
|
|
|
opts.parse!(args)
|
|
|
|
options
|
|
end
|
|
end
|
|
|
|
options = OptsConsole.parse(ARGV)
|
|
if (options['Version'])
|
|
$stderr.puts 'Framework Version: ' + Msf::Framework::Version
|
|
exit
|
|
end
|
|
|
|
begin
|
|
Msf::Ui::Console::Driver.new(
|
|
Msf::Ui::Console::Driver::DefaultPrompt,
|
|
Msf::Ui::Console::Driver::DefaultPromptChar,
|
|
options
|
|
).run
|
|
rescue Interrupt
|
|
end
|