Skip to content

Commit

Permalink
Land #19376, Fix php/base64 encoder
Browse files Browse the repository at this point in the history
This fixes the php/base64 encoder which was previously generating php
payloads that were failing when being being run
  • Loading branch information
jheysel-r7 committed Aug 26, 2024
2 parents e7dccc0 + d28fb4c commit e0037fb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/encoders/php/base64.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ def encode_block(state, buf)
# Plus characters ('+') in a uri are converted to spaces, so replace
# them with something that PHP will turn into a plus. Slashes cause
# parse errors on the server side, so do the same for them.
b64.gsub!('+', '.chr(43).')
b64.gsub!('/', '.chr(47).')
b64.gsub!('+', "#{quote}.chr(43).#{quote}")
b64.gsub!('/', "#{quote}.chr(47).#{quote}")

state.badchars.each_byte do |byte|
# Last ditch effort, if any of the normal characters used by base64
# are badchars, try to replace them with something that will become
# the appropriate thing on the other side.
if b64.include?(byte.chr)
b64.gsub!(byte.chr, ".chr(#{byte}).")
b64.gsub!(byte.chr, "#{quote}.chr(#{byte}).#{quote}")
end
end

Expand Down

0 comments on commit e0037fb

Please sign in to comment.