Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Shell script compiler

License

NotificationsYou must be signed in to change notification settings

neurobin/shc

Repository files navigation

build status imageGitHub starsGitHub forksGitHub issues

Shell Script Compiler

A generic shell script compiler. 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.

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

shc itself is not a compiler such as cc, it rather encodes and encrypts a shell script and generates C source code with the 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.

Install

./configuremakesudo make install

Note Ifmake fails due toautomake version, run./autogen.sh before running the above commands.

Ubuntu-specific

sudo add-apt-repository ppa:neurobin/ppasudo apt-get updatesudo apt-get install shc

If the above installation method seems like too much work, then just download a compiled binary package fromrelease page and copy theshc binary to/usr/bin andshc.1 file to/usr/share/man/man1.

Usage

shc [options]shc -f script.sh -o binaryshc -U -f script.sh -o binary # Untraceable binary (prevent strace, ptrace etc..)shc -H -f script.sh -o binary # Untraceable binary, does not require root (only bourne shell (sh) scripts with no parameter)

The hardening flag -H

This flag is currently in an experimental state and may not work in all systems. This flag only works fordefault shell. For example, if you compile abash script with-H flag then the resultant executable will only work in systems where the default shell isbash. You may change the default shell which generally is/bin/sh which further is just a link to another shell like bash or dash etc.

Also-H does not work with positional parameters (yet)

Testing

./configuremakemake check

Known limitations

The one (and I hope the only) limitation using shc is the _SC_ARG_MAX system configuration parameter.It limits the maximum length of the arguments to the exec function, limiting the maximum length of the runnable script of shc.

!! - CHECK YOUR RESULTS CAREFULLY BEFORE USING - !!

Links

  1. Man Page
  2. Web Page

Contributing

If you want to make pull requests, please do so against themaster branch. The default branch isrelease which should contain clean package files ready to be used.

If you want to edit the manual, please edit theman.md file (available in the master branch) instead and then generate the manual file from it with the command (requirespandoc to be installed):

pandoc -s man.md -t man -o shc.1#also run this command to generate the html manualpandoc -s man.md -t html -o man.html

If you change anything related to autotools, please run./autogen.sh afterwards.


[8]ページ先頭

©2009-2025 Movatter.jp