” # absolutized and normalized
if [ -z “$MY_PATH” ] ; then
# error; for some reason, the path is not accessible
# to the script (e.g. permissions re-evaled after suid)
exit 1 # fail
Use -r, this will relax security to create a redistributable binary that executes on other systems that runs the same operating system as the one on which it was compiled.
3rd (optional): Specifying Expiration Date for Your Shell Script
This makes it so the compiled bash script will not run after the set date and will display a message instead.
shc-r-e01/01/2015-m"Expired on New Years Day."-fnewfile_script.sh
If you get the following error messages upon give the shc command:
# shc -f cleanlog.sh
cleanlog.sh.x.c:108:22:error:sys/stat.h:No such file ordirectory
cleanlog.sh.x.c:109:23:error:sys/types.h:No such file ordirectory
cleanlog.sh.x.c:111:19:error:errno.h:No such file ordirectory
cleanlog.sh.x.c:112:19:error:stdio.h:No such file ordirectory
cleanlog.sh.x.c:113:20:error:stdlib.h:No such file ordirectory
cleanlog.sh.x.c:114:20:error:string.h:No such file ordirectory
cleanlog.sh.x.c:115:18:error:time.h:No such file ordirectory
cleanlog.sh.x.c:116:20:error:unistd.h:No such file ordirectory
cleanlog.sh.x.c:178:error:arraytype has incomplete element type
cleanlog.sh.x.c:179:error:arraytype has incomplete element type
cleanlog.sh.x.c:185:warning:incompatible implicit declaration of built-infunction'memset'
then install the following packages:
# apt-get install gcc libc6-dev
Last but not the least. There is no guarantee that this utility will provide you a very strong security protection. Experienced users or hackers who have sufficient knowledge about “gdb” or other debugger tools can decrypt your shell script(when using shc alone). Although it does provide a good starting point to encrypt (hide) shell scripts from “regular” users if you are a system administrator.
You can connect to a socket using Bash by using exec and redirecting to and from the pseudo-path /dev/tcp/<hostname>/<port> or /dev/udp/<hostname>/<port>. For instance, to connect to your localhost SSH port using TCP:
Then, use cat and echo to read or write to the socket. Here is an example read:
Notice that there is no such file as /dev/tcp or /dev/udp. Bash interprets the pseudo-path.
ls:cannot access/dev/tcp:No such file ordirectory
ls:cannot access/dev/udp:No such file ordirectory
As another example, maybe you want to download a webpage:
Finally, let’s say you wanted to connect to an IRC server. Here is an example: