shc

๐Ÿ›ก๏ธ SHC - Shell Script Compiler ๐Ÿš€

Generic Shell Script Compiler with Enhanced Security & Auditing

Latest Version Build Status ShellCheck Bash Maintenance Status License

GitHub Issues GitHub Pull Requests GitHub Stars GitHub Forks GitHub Contributors

Donate with PayPal Sponsor with GitHub Open Source Love

Empowering Developers โ€ข Securing Shell Scripts โ€ข Open Source Passion


๐Ÿ“– Overview

Shc takes a script, which is specified on the command line, and produces C source code. The generated source code is then compiled and linked to produce a stripped binary executable.

Insight: shc itself is not a compiler such as cc. It rather encodes and encrypts a shell script and generates C source code with an added expiration capability. It then uses the system compiler to compile a stripped binary which behaves exactly like the original script. Upon execution, the compiled binary will decrypt and execute the code with the shell -c option.

Note: The compiled binary will still be dependent on the shell specified in the first line of the shell code (i.e. shebang #!/bin/sh), thus shc does not create completely independent binaries.


โšก Installation

๐Ÿ› ๏ธ Building & Installing Locally

First, clone the repository and ensure you have the necessary packages for compiling:

# Clone the repository
git clone https://github.com/alsyundawy/shc.git
cd shc

# Install dependencies
sudo apt-get update
sudo apt-get install build-essential automake autoconf libtool

Then, compile and install from the source:

./autogen.sh
./configure
make
sudo make install

(Note: If make fails due to automakeโ€™s version, ensure you have run ./autogen.sh before running the commands.)

๐Ÿง Debian GNU/Linux and Ubuntu Systems

sudo apt-get install shc

๐Ÿ“ฆ Ubuntu Systems (via PPA Repository)

sudo add-apt-repository ppa:alsyundawy/ppa
sudo apt-get update
sudo apt-get install shc

Prefer Pre-compiled Binaries? Download a compiled binary package from the Releases Page and copy the shc binary to /usr/bin and shc.1 to /usr/share/man/man1.


๐Ÿ’ป Usage

# General Usage
shc [options]

# Compile a script into a binary
shc -f script.sh -o binary

# Untraceable binary (prevents strace, ptrace, etc.)
shc -U -f script.sh -o binary  

# Untraceable binary, no root required (only sh scripts, no parameters)
shc -H -f script.sh -o binary  

๐Ÿ›ก๏ธ The Hardening Flag -H

This flag is currently in an experimental state and may not work on all systems. This flag only works for the default shell. For example, if you compile a bash script with the -H flag, the resulting executable will only work on systems where the default shell is bash. You may change the default shell, which generally is /bin/sh (often a symlink to bash or dash).

โš ๏ธ Notice: -H does not work with positional parameters (yet).


๐Ÿงช Testing

To run the test suite, simply use:

./configure
make
make test

Temporary directories are generated in ${TMPDIR:-/tmp}/shc.SHELL.OPT.XXXXXX (caps are replaced according to the test). When a test succeeds, the directory is removed; if it fails, it is kept to help with debugging.

Clean up test outputs manually with:

rm -rf ${TMPDIR:-/tmp}/shc.*

โš ๏ธ Known Limitations

โ— CHECK YOUR RESULTS CAREFULLY BEFORE USING โ—


๐Ÿ”’ CHANGES - Audit & Hardening

By HARRY DS ALSYUNDAWY - ALSYUNDAWY IT SOLUTION

๐ŸŒŸ LATEST: MON Jun 15 23:59:23 WIB 2026 - HARRY DS ALSYUNDAWY - ALSYUNDAWY IT SOLUTION

Original Credit to @alsyundawy

๐ŸŒŸ LATEST: MON Jun 15 22:47:41 WIB 2026 - HARRY DS ALSYUNDAWY - ALSYUNDAWY IT SOLUTION

Original Credit to @alsyundawy

๐ŸŒŸ LATEST: MON Jun 15 22:16:33 WIB 2026 - HARRY DS ALSYUNDAWY - ALSYUNDAWY IT SOLUTION

Original Credit to @alsyundawy

๐ŸŒŸ LATEST: MON Jun 15 19:52:11 WIB 2026 - HARRY DS ALSYUNDAWY - ALSYUNDAWY IT SOLUTION

Original Credit to @alsyundawy

๐Ÿ•’ LATEST: Aug 19 2024

Original Credit to @mdeweerd


๐Ÿค Contributing

We welcome your open-source passion! If you want to make pull requests, please target the master branch. The default branch is release, which should contain clean package files ready to be used.

๐Ÿ“ Documentation & Manuals

If you want to edit the manual, please edit the man.md file. The CI flow will automatically generate the other manual files from it. You can also generate these locally with the following commands (requires pandoc):

pandoc -s man.md -t man -o shc.1
# Also run this command to generate the HTML manual
pandoc -s man.md -t html -o man.html

โš™๏ธ Autotools

If you change anything related to autotools, ./autogen.sh should be run to regenerate the derived files. Again, the CI flow will generate these automatically. (You may need to pull after a push because of the changes committed by CI.)


๐Ÿ† Credits & Acknowledgements

This project is a hardened and heavily audited iteration built upon the incredible foundational work of neurobin. Huge thanks to the original author and the contributors of the neurobin/shc repository.


  1. Man Page
  2. Web Page

Developed with โค๏ธ & Passion by Open Source Community