CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

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