modules/illScrappy/metasploit-framework/lib/msf/core/payload_generator.rb
def generate_payload
      if platform == "java" or arch == "java" or payload.start_with? "java/"
        raw_payload = generate_java_payload
        cli_print "Payload size: #{raw_payload.length} bytes"
        gen_payload = raw_payload
      elsif payload.start_with? "android/" and not template.blank?
        cli_print "Using APK template: #{template}"
        apk_backdoor = ::Msf::Payload::Apk.new
        raw_payload = apk_backdoor.backdoor_apk(template, generate_raw_payload)
        cli_print "Payload size: #{raw_payload.length} bytes"
        gen_payload = raw_payload
      else
        raw_payload = generate_raw_payload
        raw_payload = add_shellcode(raw_payload)

        if encoder != nil and encoder.start_with?("@")
          encoded_payload = multiple_encode_payload(raw_payload)
        else
          encoded_payload = encode_payload(raw_payload)
        end
        encoded_payload = prepend_nops(encoded_payload)
        cli_print "Payload size: #{encoded_payload.length} bytes"
        gen_payload = format_payload(encoded_payload)
      end

      if gen_payload.nil?
        raise PayloadGeneratorError, 'The payload could not be generated, check options'
      elsif gen_payload.length > @space and not @smallest
        raise PayloadSpaceViolation, 'The payload exceeds the specified space'
      else
        if format.to_s != 'raw'
          cli_print "Final size of #{format} file: #{gen_payload.length} bytes"
        end

        gen_payload
      end
    end
# This method is a wrapper around all of the other methods. It calls the correct
# methods in order based on the supplied options and returns the finished payload.
# @return [String] A string containing the bytes of the payload in the format selected
This method is a wrapper around all of the other methods. It calls the correct
methods in order based on the supplied options and returns the finished payload.
This method is a wrapper around all of the other methods . It calls the correct methods in order based on the supplied options and returns the finished payload .
def generate_payload
      if platform == "java" or arch == "java" or payload.start_with? "java/"
        raw_payload = generate_java_payload
        cli_print "Payload size: #{raw_payload.length} bytes"
        gen_payload = raw_payload
      elsif payload.start_with? "android/" and not template.blank?
        cli_print "Using APK template: #{template}"
        apk_backdoor = ::Msf::Payload::Apk.new
        raw_payload = apk_backdoor.backdoor_apk(template, generate_raw_payload)
        cli_print "Payload size: #{raw_payload.length} bytes"
        gen_payload = raw_payload
      else
        raw_payload = generate_raw_payload
        raw_payload = add_shellcode(raw_payload)
        if encoder != nil and encoder.start_with?("@")
          encoded_payload = multiple_encode_payload(raw_payload)
        else
          encoded_payload = encode_payload(raw_payload)
        end
        encoded_payload = prepend_nops(encoded_payload)
        cli_print "Payload size: #{encoded_payload.length} bytes"
        gen_payload = format_payload(encoded_payload)
      end
      if gen_payload.nil?
        raise PayloadGeneratorError, 'The payload could not be generated, check options'
      elsif gen_payload.length > @space and not @smallest
        raise PayloadSpaceViolation, 'The payload exceeds the specified space'
      else
        if format.to_s != 'raw'
          cli_print "Final size of #{format} file: #{gen_payload.length} bytes"
        end
        gen_payload
      end
    end
def generate_payload if platform == "java" or arch == "java" or payload . start_with? "java/" raw_payload = generate_java_payload cli_print "Payload size: #{raw_payload.length} bytes" gen_payload = raw_payload elsif payload . start_with? "android/" and not template . blank? cli_print "Using APK template: #{template}" apk_backdoor = :: Msf :: Payload :: Apk . new raw_payload = apk_backdoor . backdoor_apk ( template , generate_raw_payload ) cli_print "Payload size: #{raw_payload.length} bytes" gen_payload = raw_payload else raw_payload = generate_raw_payload raw_payload = add_shellcode ( raw_payload ) if encoder != nil and encoder . start_with? ( "@" ) encoded_payload = multiple_encode_payload ( raw_payload ) else encoded_payload = encode_payload ( raw_payload ) end encoded_payload = prepend_nops ( encoded_payload ) cli_print "Payload size: #{encoded_payload.length} bytes" gen_payload = format_payload ( encoded_payload ) end if gen_payload . nil? raise PayloadGeneratorError , 'The payload could not be generated, check options' elsif gen_payload . length > @space and not @smallest raise PayloadSpaceViolation , 'The payload exceeds the specified space' else if format . to_s != 'raw' cli_print "Final size of #{format} file: #{gen_payload.length} bytes" end gen_payload end end
This method is a wrapper around all of the other methods.
This method is a wrapper around all of the other methods .
A string containing the bytes of the payload in the format selected
A string containing the bytes of the payload in the format selected
String