Skip to content

Commit bf54b58

Browse files
committed
Condense the decoder commands
1 parent 8b5a83c commit bf54b58

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/rex/exploitation/cmdstager/bourne.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,18 @@ def parts_to_commands(parts, opts)
6767
#
6868
def generate_cmds_decoder(opts)
6969
decoders = [
70-
"base64 --decode #{@tempdir}#{@var_encoded}.b64",
71-
"openssl enc -d -A -base64 -in #{@tempdir}#{@var_encoded}.b64",
72-
"python -c 'import sys; import base64; print base64.standard_b64decode(sys.stdin.read());' < #{@tempdir}#{@var_encoded}.b64",
73-
"perl -MIO -e 'use MIME::Base64; while (<>) { print decode_base64($_); }' < #{@tempdir}#{@var_encoded}.b64"
70+
"base64 --decode -",
71+
"openssl enc -d -A -base64 -in /dev/stdin",
72+
"python -c 'import sys, base64; print base64.standard_b64decode(sys.stdin.read());'",
73+
"perl -MMIME::Base64 -ne 'print decode_base64($_)'"
7474
]
7575
decoder_cmd = []
7676
decoders.each do |cmd|
7777
binary = cmd.split(' ')[0]
7878
decoder_cmd << "(which #{binary} >&2 && #{cmd})"
7979
end
8080
decoder_cmd = decoder_cmd.join(" || ")
81-
decoder_cmd = "(" << decoder_cmd << ") 2> /dev/null > #{@tempdir}#{@var_decoded}.bin"
81+
decoder_cmd = "(" << decoder_cmd << ") 2> /dev/null > #{@tempdir}#{@var_decoded}.bin < #{@tempdir}#{@var_encoded}.b64"
8282
[ decoder_cmd ]
8383
end
8484

0 commit comments

Comments
 (0)