Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/payloads/singles/generic/custom.rb
19593 views
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
module MetasploitModule
7
CachedSize = 0
8
9
include Msf::Payload::Single
10
include Msf::Payload::Generic
11
12
def initialize(info = {})
13
super(
14
merge_info(
15
info,
16
'Name' => 'Custom Payload',
17
'Description' => %q{
18
Use custom string or file as payload. Set either PAYLOADFILE or
19
PAYLOADSTR.
20
},
21
'Author' => 'scriptjunkie <scriptjunkie[at]scriptjunkie.us>',
22
'License' => MSF_LICENSE,
23
'Payload' => {
24
'Payload' => '' # not really
25
}
26
)
27
)
28
29
# Register options
30
register_options(
31
[
32
OptString.new('PAYLOADFILE', [ false, 'The file to read the payload from' ]),
33
OptString.new('PAYLOADSTR', [ false, 'The string to use as a payload' ])
34
]
35
)
36
end
37
38
#
39
# Construct the payload
40
#
41
def generate(_opts = {})
42
if datastore['ARCH']
43
self.arch = actual_arch
44
end
45
46
if datastore['PAYLOADSTR']
47
datastore['PAYLOADSTR']
48
elsif datastore['PAYLOADFILE']
49
File.binread(datastore['PAYLOADFILE'])
50
else
51
''
52
end
53
end
54
55
# Only accept the "none" encoder
56
def compatible_encoders
57
encoders = super()
58
encoders2 = []
59
encoders.each do |encname, encmod|
60
encoders2 << [encname, encmod] if encname.include? 'none'
61
end
62
63
return encoders2
64
end
65
end
66
67