@@ -33,6 +33,9 @@ def initialize
33
33
34
34
#
35
35
# Encodes the payload
36
+ # All unnecessary spaces from your payload inside the () are removed to avoid shell POSIX command lauguage conflicts
37
+ # The only things allowed after compound commands are redirections, shell keywords, and the various command separators
38
+ # such as (;, &, |, &&, ||)
36
39
#
37
40
def encode_block ( state , buf )
38
41
return buf if ( buf . bytes & state . badchars . bytes ) . empty?
@@ -48,7 +51,7 @@ def encode_block(state, buf)
48
51
when 'base64'
49
52
raise EncodingError if ( state . badchars . bytes & '(|)' . bytes ) . any?
50
53
51
- base64_decoder = '(base64 --decode || base64 -d)'
54
+ base64_decoder = '(base64 --decode|| base64 -d)'
52
55
when 'base64-long'
53
56
base64_decoder = 'base64 --decode'
54
57
when 'base64-short'
@@ -58,9 +61,9 @@ def encode_block(state, buf)
58
61
else
59
62
# find a decoder at runtime if we can use the necessary characters
60
63
if ( state . badchars . bytes & '(|)>/&' . bytes ) . empty?
61
- base64_decoder = '((command -v base64 >/dev/null && (base64 --decode || base64 -d)) || (command -v openssl >/dev/null && openssl enc -base64 -d))'
64
+ base64_decoder = '((command -v base64>/dev/null&& (base64 --decode|| base64 -d))|| (command -v openssl>/dev/null&& openssl enc -base64 -d))'
62
65
elsif ( state . badchars . bytes & '(|)' . bytes ) . empty?
63
- base64_decoder = '(base64 --decode || base64 -d)'
66
+ base64_decoder = '(base64 --decode|| base64 -d)'
64
67
else
65
68
base64_decoder = 'openssl enc -base64 -d'
66
69
end
0 commit comments