Having the payload generator check the payload size

Payload generator will raise an error if the payload is larger then the size option
bug/bundler_fix
darkbushido 2016-05-23 15:17:41 -05:00
parent 7e34d1e1cf
commit d3cdcd5f99
No known key found for this signature in database
GPG Key ID: 3922EB70FB80E8DD
1 changed files with 11 additions and 3 deletions

View File

@ -9,6 +9,9 @@ module Msf
class EncoderSpaceViolation < PayloadGeneratorError
end
class SpaceViolation < PayloadGeneratorError
end
class IncompatibleArch < PayloadGeneratorError
end
@ -314,20 +317,25 @@ module Msf
if platform == "java" or arch == "java" or payload.start_with? "java/"
raw_payload = generate_java_payload
cli_print "Payload size: #{raw_payload.length} bytes"
raw_payload
gen_payload = raw_payload
elsif payload.start_with? "android/" and not template.blank?
cli_print "Using APK template: #{template}"
apk_backdoor = ::Msf::Payload::Apk::ApkBackdoor::new()
raw_payload = apk_backdoor.backdoor_apk(template, generate_raw_payload)
cli_print "Payload size: #{raw_payload.length} bytes"
raw_payload
gen_payload = raw_payload
else
raw_payload = generate_raw_payload
raw_payload = add_shellcode(raw_payload)
encoded_payload = encode_payload(raw_payload)
encoded_payload = prepend_nops(encoded_payload)
cli_print "Payload size: #{encoded_payload.length} bytes"
format_payload(encoded_payload)
gen_payload = format_payload(encoded_payload)
end
if gen_payload.length > @space and not @smallest
raise SpaceViolation, 'The payload exceeds the allocated space'
else
gen_payload
end
end