@@ -64,6 +64,9 @@ class PayloadGenerator
64
64
# @!attribute space
65
65
# @return [Fixnum] The maximum size in bytes of the payload
66
66
attr_accessor :space
67
+ # @!attribute encoder_space
68
+ # @return [Fixnum] The maximum size in bytes of the encoded payload
69
+ attr_accessor :encoder_space
67
70
# @!attribute stdin
68
71
# @return [String] The raw bytes of a payload taken from STDIN
69
72
attr_accessor :stdin
@@ -85,6 +88,7 @@ class PayloadGenerator
85
88
# @option opts [String] :badchars (see #badchars)
86
89
# @option opts [String] :template (see #template)
87
90
# @option opts [Fixnum] :space (see #space)
91
+ # @option opts [Fixnum] :encoder_space (see #encoder_space)
88
92
# @option opts [Fixnum] :nops (see #nops)
89
93
# @option opts [String] :add_code (see #add_code)
90
94
# @option opts [Boolean] :keep (see #keep)
@@ -109,6 +113,7 @@ def initialize(opts={})
109
113
@stdin = opts . fetch ( :stdin , nil )
110
114
@template = opts . fetch ( :template , '' )
111
115
@var_name = opts . fetch ( :var_name , 'buf' )
116
+ @encoder_space = opts . fetch ( :encoder_space , @space )
112
117
113
118
@framework = opts . fetch ( :framework )
114
119
@@ -200,7 +205,7 @@ def encode_payload(shellcode)
200
205
encoder_list . each do |encoder_mod |
201
206
cli_print "Attempting to encode payload with #{ iterations } iterations of #{ encoder_mod . refname } "
202
207
begin
203
- encoder_mod . available_space = @space
208
+ encoder_mod . available_space = @encoder_space
204
209
return run_encoder ( encoder_mod , shellcode . dup )
205
210
rescue ::Msf ::EncoderSpaceViolation => e
206
211
cli_print "#{ encoder_mod . refname } failed with #{ e . message } "
@@ -395,7 +400,7 @@ def run_encoder(encoder_module, shellcode)
395
400
iterations . times do |x |
396
401
shellcode = encoder_module . encode ( shellcode . dup , badchars , nil , platform_list )
397
402
cli_print "#{ encoder_module . refname } succeeded with size #{ shellcode . length } (iteration=#{ x } )"
398
- if shellcode . length > space
403
+ if shellcode . length > encoder_space
399
404
raise EncoderSpaceViolation , "encoder has made a buffer that is too big"
400
405
end
401
406
end
0 commit comments