Files
metasploit-gs/modules/payloads/singles/generic/custom.rb
T
William Vu 29d6cf4480 Fix nil bug in generic/custom and change opt order
I think PAYLOADSTR should take precedence over PAYLOADFILE. Usually,
you'll use PAYLOADFILE but might want to override with PAYLOADSTR. I
doubt this change will hurt anyone, since few people set both at once.
The payload description even says "either," so there's that.
2016-12-28 05:15:25 -06:00

66 lines
1.5 KiB
Ruby

##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
require 'msf/core/payload/generic'
module MetasploitModule
CachedSize = 0
include Msf::Payload::Single
include Msf::Payload::Generic
def initialize(info = {})
super(merge_info(info,
'Name' => 'Custom Payload',
'Description' => 'Use custom string or file as payload. Set either PAYLOADFILE or
PAYLOADSTR.',
'Author' => 'scriptjunkie <scriptjunkie[at]scriptjunkie.us>',
'License' => MSF_LICENSE,
'Payload' =>
{
'Payload' => "" # not really
}
))
# 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" ] )
], self.class)
end
#
# Construct the payload
#
def generate
if datastore['ARCH']
self.arch = actual_arch
end
if datastore['PAYLOADSTR']
datastore['PAYLOADSTR']
elsif datastore['PAYLOADFILE']
IO.read(datastore['PAYLOADFILE'])
else
''
end
end
# Only accept the "none" encoder
def compatible_encoders
encoders = super()
encoders2 = []
encoders.each do |encname, encmod|
encoders2 << [encname, encmod] if encname.include? 'none'
end
return encoders2
end
end