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