LinuxCommandLibrary

shc

Compile shell scripts to binary executables

TLDR

Compile shell script
$ shc -f [script.sh]
copy
Set expiration date
$ shc -e [31/12/2026] -f [script.sh]
copy
Set expiration message
$ shc -m "[Script expired]" -f [script.sh]
copy
Custom output name
$ shc -o [binary] -f [script.sh]
copy
Relaxed security
$ shc -r -f [script.sh]
copy
Hardened untraceable binary
$ shc -U -H -f [script.sh]
copy
Verbose output
$ shc -v -f [script.sh]
copy

SYNOPSIS

shc [-f script] [-o output] [-e date] [-m message] [-r] [-U] [-H] [-v]

DESCRIPTION

shc converts shell scripts into compiled binary executables by encrypting the script content and wrapping it in auto-generated C code. The resulting C source is compiled with the system's C compiler to produce a standalone binary that decrypts and executes the original script at runtime.
The tool provides basic source code obfuscation rather than true security, since the script can be recovered from the binary with sufficient effort. Optional features include expiration dates that make the binary refuse to run after a specified date, and strict mode that binds the binary to the current host to prevent redistribution. Relaxed mode (-r) allows the binary to run on different systems.
An intermediate .x.c file containing the generated C source is produced alongside the binary and can be inspected, modified, or compiled manually with different options.

PARAMETERS

-f SCRIPT

Input shell script to compile
-o FILE
Output binary filename
-e DATE
Expiration date in dd/mm/yyyy format
-m MESSAGE
Message to display upon expiration (default: "Please contact your provider")
-r
Relaxed security, allow redistributable binary across systems
-v
Verbose compilation output
-U
Make binary untraceable (blocks truss, strace, ltrace, etc.)
-H
Hardening: extra protection against dumping, code injection, and ptrace
-S
Switch on setuid for root callable programs
-B
Compile for BusyBox
-D
Switch on debug exec calls
-i inlineoption_
Inline option for the shell interpreter
-x command
Exec command, as a printf format

CAVEATS

Not true compilation - script is recoverable. Security is obfuscation, not encryption. Requires C compiler.

HISTORY

shc (Shell Compiler) was created by Francisco Javier Rosales Garcia. It's used for basic shell script protection and distribution.

SEE ALSO

bash(1), gcc(1)

Copied to clipboard