forked from rapid7/metasploit-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmsfpayload
executable file
·69 lines (55 loc) · 1.31 KB
/
msfpayload
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/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 (#{$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