Skip to content

iamlooper/SHX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SHX - Shell Script Compiler

Compile shell scripts into encrypted static binaries.

Features

  • VM-based execution - Scripts compiled to bytecode, executed by built-in VM runtime
  • Encryption - AES-256-GCM with micro-chunking
  • Self-verifying binaries - Tamper detection via binary hash binding
  • Portable execution - Bundled BusyBox for cross-platform compatibility
  • Memory execution - BusyBox runs from memory (memfd), no disk artifacts
  • Expiration dates - Optional time-limited script execution
  • No dependencies - Static musl binaries, runs on any Linux

Requirements

  • Linux kernel 3.17+ (for memfd_create syscall)
  • Rust 1.85+ (edition 2024)

Installation

From GitHub Releases (Recommended)

curl -fsSL https://raw.githubusercontent.com/iamlooper/SHX/main/scripts/install.sh | sh

Or manually download from Releases.

From Source

git clone https://github.com/iamlooper/SHX.git
cd SHX
./build.sh
sudo cp target/release/shx /usr/local/bin/

Build Options

./build.sh          # Build for host architecture
./build.sh x86_64   # Build for x86_64-unknown-linux-musl
./build.sh i686     # Build for i686-unknown-linux-musl
./build.sh aarch64  # Build for aarch64-unknown-linux-musl
./build.sh armv7    # Build for armv7-unknown-linux-musleabihf
./build.sh all      # Build for all architectures

Usage

Basic Usage

# Compile script for x86_64
shx -f script.sh -a x86_64 -o script.x

# Run the compiled binary
./script.x

Notes:

  • shx is the compiler CLI. The output is the compiled script binary (for example script.x).
  • Some shell behaviors are implemented natively by the VM, while others are delegated to BusyBox ash at runtime for compatibility. See the documentation links below.

With Expiration

# Script expires on 2025-12-31
shx -f script.sh -a x86_64 -e 2025-12-31 -m "License expired"

Options

OPTIONS:
    -f, --file <SCRIPT>       Shell script to compile (required)
    -a, --arch <ARCH>         Target architecture (required)
    -o, --output <NAME>       Output binary name [default: <script>.x]
    -e, --expire <DATE>       Expiration date (YYYY-MM-DD)
    -m, --expire-msg <MSG>    Message on expiration
    -v, --verbose             Verbose output
        --list                List supported architectures
    -h, --help                Print help
    -V, --version             Print version

Supported Architectures

Architecture Rust Target
x86_64 x86_64-unknown-linux-musl
x86 i686-unknown-linux-musl
aarch64 aarch64-unknown-linux-musl
armv7 armv7-unknown-linux-musleabihf

Cross-Compilation

For non-x86 targets, install the appropriate Rust target:

# ARM64 (aarch64)
rustup target add aarch64-unknown-linux-musl

# ARM32 (armv7)
rustup target add armv7-unknown-linux-musleabihf

Documentation

  • Architecture - System design and component overview
  • Features - Supported shell syntax and built-ins
  • Security - Security model and considerations

License

MIT License - see LICENSE