Path: blob/master/modules/payloads/singles/generic/custom.rb
19593 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45module MetasploitModule6CachedSize = 078include Msf::Payload::Single9include Msf::Payload::Generic1011def initialize(info = {})12super(13merge_info(14info,15'Name' => 'Custom Payload',16'Description' => %q{17Use custom string or file as payload. Set either PAYLOADFILE or18PAYLOADSTR.19},20'Author' => 'scriptjunkie <scriptjunkie[at]scriptjunkie.us>',21'License' => MSF_LICENSE,22'Payload' => {23'Payload' => '' # not really24}25)26)2728# Register options29register_options(30[31OptString.new('PAYLOADFILE', [ false, 'The file to read the payload from' ]),32OptString.new('PAYLOADSTR', [ false, 'The string to use as a payload' ])33]34)35end3637#38# Construct the payload39#40def generate(_opts = {})41if datastore['ARCH']42self.arch = actual_arch43end4445if datastore['PAYLOADSTR']46datastore['PAYLOADSTR']47elsif datastore['PAYLOADFILE']48File.binread(datastore['PAYLOADFILE'])49else50''51end52end5354# Only accept the "none" encoder55def compatible_encoders56encoders = super()57encoders2 = []58encoders.each do |encname, encmod|59encoders2 << [encname, encmod] if encname.include? 'none'60end6162return encoders263end64end656667