Files
metasploit-gs/modules/payloads/singles/generic/custom.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
1.4 KiB
Ruby
Raw Normal View History

2011-06-29 01:26:24 +00:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
2011-06-29 01:26:24 +00:00
##
2016-03-08 14:02:44 +01:00
module MetasploitModule
2011-06-29 01:26:24 +00:00
CachedSize = 0
2011-06-29 01:26:24 +00:00
include Msf::Payload::Single
include Msf::Payload::Generic
2013-08-30 16:28:54 -05:00
2011-06-29 01:26:24 +00:00
def initialize(info = {})
super(merge_info(info,
'Name' => 'Custom Payload',
'Description' => 'Use custom string or file as payload. Set either PAYLOADFILE or
PAYLOADSTR.',
2012-03-05 13:28:23 -07:00
'Author' => 'scriptjunkie <scriptjunkie[at]scriptjunkie.us>',
2011-06-29 01:26:24 +00:00
'License' => MSF_LICENSE,
'Payload' =>
{
'Payload' => "" # not really
}
))
2013-08-30 16:28:54 -05:00
2011-06-29 01:26:24 +00:00
# Register options
register_options(
[
OptString.new('PAYLOADFILE', [ false, "The file to read the payload from" ] ),
OptString.new('PAYLOADSTR', [ false, "The string to use as a payload" ] )
])
2011-06-29 01:26:24 +00:00
end
2013-08-30 16:28:54 -05:00
2011-06-29 01:26:24 +00:00
#
# Construct the payload
#
2022-11-04 00:33:03 +00:00
def generate(_opts = {})
if datastore['ARCH']
self.arch = actual_arch
end
2013-08-30 16:28:54 -05:00
if datastore['PAYLOADSTR']
2011-06-29 01:26:24 +00:00
datastore['PAYLOADSTR']
elsif datastore['PAYLOADFILE']
2022-03-10 18:03:35 +00:00
File.binread(datastore['PAYLOADFILE'])
else
''
2011-06-29 01:26:24 +00:00
end
end
2013-08-30 16:28:54 -05:00
2011-06-29 01:26:24 +00:00
# Only accept the "none" encoder
def compatible_encoders
encoders = super()
encoders2 = []
encoders.each do |encname, encmod|
encoders2 << [encname, encmod] if encname.include? 'none'
end
2013-08-30 16:28:54 -05:00
2011-06-29 01:26:24 +00:00
return encoders2
end
end