mirror of
https://github.com/rapid7/metasploit-framework
synced 2024-10-29 18:07:27 +01:00
88658064df
git-svn-id: file:///home/svn/incoming/trunk@3242 4d416f70-5f16-0410-b530-b9f4589650da
70 lines
1.3 KiB
Ruby
Executable File
70 lines
1.3 KiB
Ruby
Executable File
#!/usr/bin/env 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 (#{$framework.stats.num_payloads} total)",
|
|
'Columns' =>
|
|
[
|
|
"Name",
|
|
"Description"
|
|
])
|
|
|
|
$framework.payloads.each_module { |name, mod|
|
|
tbl << [ name, mod.new.description ]
|
|
}
|
|
|
|
"\n" + tbl.to_s + "\n"
|
|
end
|
|
|
|
# Initialize the simplified framework instance.
|
|
$framework = Msf::Simple::Framework.create
|
|
|
|
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
|
|
|
|
print buf
|
|
elsif (cmd =~ /^s/)
|
|
puts Msf::Serializer::ReadableText.dump_module(payload)
|
|
end
|