Skip to content

Commit ba51617

Browse files
committed
Allow multiple encoding syntax in Encoder variable
From msfconsole using set Encoder or set StageEncoder it is possible to set multiple encoders with this syntax : <encoder>:<iteration>, <encoder2>:<iteration This should not break compatibility
1 parent 1f4d62a commit ba51617

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

lib/msf/core/encoded_payload.rb

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ def generate(raw = nil)
4848
self.nop_sled = nil
4949
self.encoder = nil
5050
self.nop = nil
51-
self.iterations = reqs['Iterations'].to_i
52-
self.iterations = 1 if self.iterations < 1
5351

5452
# Increase thread priority as necessary. This is done
5553
# to ensure that the encoding and sled generation get
@@ -67,8 +65,24 @@ def generate(raw = nil)
6765
# Generate the raw version of the payload first
6866
generate_raw() if self.raw.nil?
6967

70-
# Encode the payload
71-
encode()
68+
69+
# If encoder is set, it could be an encoders list
70+
# The form is "<encoder>:<iteration>, <encoder2>:<iteration>"...
71+
if reqs['Encoder']
72+
encoder_str = reqs['Encoder']
73+
encoder_str.scan(/([^:, ]+):?([^,]+)?/).map do |encoder_opt|
74+
reqs['Encoder'] = encoder_opt[0]
75+
76+
self.iterations = (encoder_opt[1] || reqs['Iterations']).to_i
77+
self.iterations = 1 if self.iterations < 1
78+
79+
# Encode the payload with every encoders in the list
80+
encode()
81+
end
82+
else
83+
# No specified encoder, let BadChars or ForceEncode do their job
84+
encode()
85+
end
7286

7387
# Build the NOP sled
7488
generate_sled()

0 commit comments

Comments
 (0)