szaydel
10/17/2014 - 5:08 PM

Obscuring commands that a shell script execs

Obscuring commands that a shell script execs

# uuencode -m - < <(echo "touch /tmp/testfile; ls -l /tmp; rm /tmp/testfile; ls -l /tmp") > encoded
#
# eval `uudecode ./encoded`
total 4
drwx------ 2 root root 183 Oct 17 09:54 ssh-XXXXRqaOFb
-rw-r--r-- 1 root root   0 Oct 17 09:56 testfile
total 4
drwx------ 2 root root 183 Oct 17 09:54 ssh-XXXXRqaOFb


Contents of encoded:

# cat encoded
begin-base64 644 -
dG91Y2ggL3RtcC90ZXN0ZmlsZTsgbHMgLWwgL3RtcDsgcm0gL3RtcC90ZXN0ZmlsZTsg
bHMgLWwgL3RtcAo=
====


Alternatively:

1) Store encoded string in a variable inside the shell script which needs to obsure these commands
# echo "$E"
begin-base64 644 -
dG91Y2ggL3RtcC90ZXN0ZmlsZTsgbHMgLWwgL3RtcDsgcm0gL3RtcC90ZXN0ZmlsZTsg
bHMgLWwgL3RtcAo=

2) Eval contents of the variable with uudecode
eval `uudecode < <(echo "$E")`