msfpayload

git-svn-id: file:///home/svn/incoming/trunk@2931 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Matt Miller 2005-10-01 09:10:41 +00:00
parent d2be5981a1
commit 6674153e4e
5 changed files with 102 additions and 10 deletions

View File

@ -44,7 +44,7 @@ X - make payload prepend target specific
- add concept of EVASION option (high, normal, low)
- logging improvements
- provide log file setting interface
- log by default in the LogDir
X - log by default in the LogDir
- msfcli
- msfweb
- msfpayload

View File

@ -26,6 +26,7 @@ class Config < Hash
{
'ConfigDirectory' => File.expand_path("~#{FileSep}.msf3"),
'ConfigFile' => "config",
'ModuleDirectory' => "modules",
'LogDirectory' => "logs",
'SessionLogDirectory' => "logs/sessions",
}
@ -44,6 +45,10 @@ class Config < Hash
self.new.config_directory
end
def self.module_directory
self.new.module_directory
end
def self.log_directory
self.new.log_directory
end
@ -100,6 +105,13 @@ class Config < Hash
config_directory + FileSep + self['ConfigFile']
end
#
# Returns the global module directory.
#
def module_directory
install_root + FileSep + self['ModuleDirectory']
end
#
# Returns the directory that log files should be stored in.
#

View File

@ -47,6 +47,15 @@ module Framework
# Load the configuration
framework.load_config
# Initialize the default module search paths
if (Msf::Config.module_directory)
framework.modules.add_module_path(Msf::Config.module_directory)
end
if (Msf::Config.user_module_directory)
framework.modules.add_module_path(Msf::Config.user_module_directory)
end
# Set the on_module_created procedure to simplify any module
# instance that is created
framework.on_module_created_proc = Proc.new { |instance|

View File

@ -118,15 +118,6 @@ class Driver < Msf::Ui::Driver
# displayed, scripts can be processed, and other fun can be had.
#
def on_startup
# Prevent output from being displayed for now
self.disable_output = true
# Run a few commands to start things off
run_single("search #{File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'modules')}")
# Re-enable output
self.disable_output = false
# Build the banner message
run_single("banner")
end

80
msfpayload Executable file
View File

@ -0,0 +1,80 @@
#!/usr/bin/ruby
$:.unshift(File.join(File.dirname(__FILE__), '../lib'))
require 'rex'
require 'msf/ui'
require 'msf/base'
#
# Dump the list of payloads
#
def dump_payloads
tbl = Rex::Ui::Text::Table.new(
'Indent' => 4,
'Header' => "Framework Payloads",
'Columns' =>
[
"Name",
"Description"
])
$framework.payloads.each_module { |name, mod|
tbl << [ name, mod.new.description ]
}
"\n" + tbl.to_s + "\n"
end
#
# Initialize logging and other things, including the framework instance we'll
# use.
#
def initialize_environment
# Initialize configuration and logging
Msf::Config.init
Msf::Logging.init
$framework = Msf::Simple::Framework.create
end
initialize_environment
if (ARGV.length <= 1)
puts "\n" + " Usage: #{$0} <payload> [var=val] <S[ummary]|C|P[erl]|R[aw]>\n"
puts dump_payloads
exit
end
# Get the payload name we'll be using
payload_name = ARGV.shift
payload = $framework.payloads.create(payload_name)
if (payload == nil)
puts "Invalid payload: #{payload_name}"
exit
end
# Evalulate the command
cmd = ARGV.pop.downcase
# Populate the framework datastore
options = ARGV.join(',')
if (cmd =~ /^(p|r|c)/)
cmd = 'perl' if (cmd =~ /^p/)
cmd = 'raw' if (cmd =~ /^r/)
begin
buf = payload.generate_simple(
'Format' => cmd,
'OptionStr' => options)
rescue
puts "Error generating payload: #{$!}"
exit
end
puts buf
elsif (cmd =~ /^s/)
puts Msf::Serializer::ReadableText.dump_module(payload)
end