2005-12-17 06:46:23 +00:00
|
|
|
#!/usr/bin/env ruby
|
2005-11-28 21:38:48 +00:00
|
|
|
#
|
|
|
|
# This user interface provides users with a command console interface to the
|
|
|
|
# framework.
|
|
|
|
#
|
2005-07-13 21:09:07 +00:00
|
|
|
|
2006-07-31 15:36:08 +00:00
|
|
|
msfbase = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
|
|
|
|
$:.unshift(File.join(File.dirname(msfbase), 'lib'))
|
2005-05-22 19:39:21 +00:00
|
|
|
|
2005-07-09 21:22:32 +00:00
|
|
|
require 'rex'
|
|
|
|
require 'msf/ui'
|
2006-04-02 16:28:02 +00:00
|
|
|
require 'optparse'
|
|
|
|
|
|
|
|
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:"
|
|
|
|
|
2007-01-30 04:48:35 +00:00
|
|
|
opts.on("-d", "-d", "Execute the console as defanged") do
|
|
|
|
options['Defanged'] = true
|
|
|
|
end
|
2006-04-02 16:28:02 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
# 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
|
2005-05-22 19:39:21 +00:00
|
|
|
|
2005-12-13 06:27:34 +00:00
|
|
|
begin
|
2006-04-02 16:28:02 +00:00
|
|
|
Msf::Ui::Console::Driver.new(
|
|
|
|
Msf::Ui::Console::Driver::DefaultPrompt,
|
|
|
|
Msf::Ui::Console::Driver::DefaultPromptChar,
|
|
|
|
options
|
|
|
|
).run
|
2005-12-13 06:27:34 +00:00
|
|
|
rescue Interrupt
|
|
|
|
end
|