• Stars
    star
    1,901
  • Rank 23,551 (Top 0.5 %)
  • Language
    C
  • License
    GNU General Publi...
  • Created about 9 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Shell script compiler

build status image GitHub stars GitHub forks GitHub 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

./configure
make
sudo make install

Note If make fails due to automake version, run ./autogen.sh before running the above commands.

Ubuntu-specific

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

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

Usage

shc [options]
shc -f script.sh -o binary
shc -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 for default shell. For example, if you compile a bash script with -H flag then the resultant executable will only work in systems where the default shell is bash. 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

./configure
make
make 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 the master branch. The default branch is release which should contain clean package files ready to be used.

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

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

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

More Repositories

1

MT7630E

Modified easy installation package
C
232
star
2

JLIVECD

Live cd/dvd customization tool
Shell
87
star
3

rnm

Unix tool: Bulk Rename Utility
C++
73
star
4

mdx_include

Python Markdown extension to include local or remote files
Python
50
star
5

php2html

PHP to HTML converter
Python
46
star
6

oraji

Oracle java installler script for linux
Shell
35
star
7

tartos

TAR archive to shell script converter
Shell
19
star
8

phantomjspy

Python wrapper for phantomjs
Python
15
star
9

mdx_wikilink_plus

A wikilink extension for Python Markdown
Python
14
star
10

lampi

LAMP installer for Ubuntu
Shell
13
star
11

lcget

Wrapper script for letsencrypt
Shell
11
star
12

sslic

SSL certificate installer for Cpanel
PHP
11
star
13

gencsr

Simple CSR generator
Shell
9
star
14

grubfix

Fix a broken grub and get back the grub menu
Shell
8
star
15

JSiteCopier

Shell script to copy an entire website
Shell
8
star
16

audio-analyzer-for-android

Automatically exported from code.google.com/p/audio-analyzer-for-android
Java
8
star
17

pacget

A wrapper around pacaur to mimic yaourt's search feature
Shell
7
star
18

chibu

Create Hybrid ISO Bootable USB
Python
6
star
19

jinarch

Arch Linux installer
Shell
6
star
20

musicg

Automatically exported from code.google.com/p/musicg
Java
5
star
21

jssh

Wrapper script for ssh
Shell
4
star
22

GCMPushNotificationServer

Server side code for GCM push notification in PHP
PHP
4
star
23

python-morm

Database Object Relational Mapping
Python
3
star
24

uedit

Universal Text Editor
JavaScript
3
star
25

gccInstaller

Latest gcc and g++ compiler installer from official source code
Shell
3
star
26

jlutils

Shell
3
star
27

ubiquity

Modified ubiquity package of the official ubiquity from ubuntu for personal use
Python
3
star
28

acme-tiny

A tiny script to issue and renew TLS certs from Let's Encrypt
Python
2
star
29

Launcher

Linux Desktop launchers
2
star
30

rcslice

Provides Python module to slice a list of sliceables (1 indexed)
Python
2
star
31

homebrew-pkg

Neurobin's Homebrew/Linuxbrew formulae
Ruby
1
star
32

deblive

Debian live cd customization
Scheme
1
star
33

neurobin.github.io

Neurobin Website
HTML
1
star
34

djhost

Serve multiple domain/subdomain from single django project with different urlconf
Python
1
star
35

MARRIAGE29

A popular card game written in C++
1
star
36

DemoCode

Codes emerged from practice
JavaScript
1
star
37

StackScripts

My StackScripts for Linode
Shell
1
star
38

cyclic

Handle cyclic relation
Python
1
star
39

Neurobin

Neurobin website
CSS
1
star
40

djsonld

Get jsonld for a webpage
Python
1
star