Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
liberize committed Feb 3, 2024
1 parent 708350e commit dc48037
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 20 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ Usage: ./ssc [-4] [-u] [-s] [-r] [-e|-E file] [-0] <script> <binary>
the interpreter will be used no matter what shebang is
-E, --embed-archive embed specified tar.gz archive into binary, require libarchive-dev
set relative path in shebang to use an interpreter in the archive
-0, --fix-argv0 try to fix \$0, may not work
if it doesn't work or causes problems, use \$SSC_ARGV0 instead
-0, --fix-argv0 try to fix $0, may not work
if it doesn't work or causes problems, use $SSC_ARGV0 instead
-v, --verbose show debug messages
-h, --help display this help and exit
```
Expand All @@ -46,10 +46,10 @@ Usage: ./ssc [-4] [-u] [-s] [-r] [-e|-E file] [-0] <script> <binary>
* support Linux/macOS/Cygwin
* **support Shell/Python/Perl/NodeJS/Ruby/PHP/R/Lua** and other scripts with custom shebang
* support relative path, environment variable and variable expanding in shebang
* simple code protection with **compile time obfuscation or rc4 encryption**
* code protection with **compile time obfuscation or rc4 encryption**
* pipes script code to interpreter to **avoid command line exposure**
* support large script, up to 8MB with compile time obfuscation and unlimited with rc4 encryption
* **anti-debugging** with simple ptrace detection
* **anti-debugging** with ptrace detection
* support embeding an interpreter or archive into output binary

# Limitations
Expand Down
6 changes: 3 additions & 3 deletions examples/1_without_shebang/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The script must have a supported file extension.

```bash
ssc test.sh binary
ssc test.bash binary
ssc test.py binary
../../ssc test.sh binary
../../ssc test.bash binary
../../ssc test.py binary
```
1 change: 1 addition & 0 deletions examples/1_without_shebang/test.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@

echo "\$@ is $@"
echo "command line: $0 $*"
echo "\$BASH is $BASH"
echo "hello world"
3 changes: 3 additions & 0 deletions examples/1_without_shebang/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@

echo "\$@ is $@"
echo "command line: $0 $*"
echo "\$SSC_INTERPRETER_PATH is $SSC_INTERPRETER_PATH"
echo "\$SSC_EXECUTABLE_PATH is $SSC_EXECUTABLE_PATH"
echo "\$SSC_ARGV0 is $SSC_ARGV0"
echo "hello world"
6 changes: 3 additions & 3 deletions examples/2_with_shebang/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Free to use any commands in shebang.

```bash
# shebang is required if no file extension
ssc test binary
../../ssc test binary
# it's ok to use /usr/bin/env
ssc test.py binary
../../ssc test.py binary
# free to use any shebang, even not listed as supported
ssc test.expect binary
../../ssc test.expect binary
```
4 changes: 2 additions & 2 deletions examples/3_bundle_interpreter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mv ./bin/bash-static ./
rm -rf ./bin data.tar.xz bash-static_5.2.15-2+b2_amd64.deb

# use -s flag to make our binary static too
ssc ./test_bash_static.sh binary -s
../../ssc ./test_bash_static.sh binary -s

# create tarball (or AppImage if you like)
chmod +x binary bash-static
Expand All @@ -37,7 +37,7 @@ mv ./bin/busybox ./
rm -rf ./bin data.tar.xz busybox-static_1.35.0-4+b3_amd64.deb data.tar.xz

# use -s flag to make our binary static too
ssc ./test_busybox.sh binary -s
../../ssc ./test_busybox.sh binary -s

# create tarball (or AppImage if you like)
chmod +x binary busybox
Expand Down
2 changes: 1 addition & 1 deletion examples/3_bundle_interpreter/test_busybox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

echo "\$@ is $@"

# debian busybox calls it's own applet by default
# debian busybox calls it's own applet by default, so this will call busybox version of ls
# see https://unix.stackexchange.com/questions/274273/are-busybox-commands-truly-built-in
ls --help
4 changes: 2 additions & 2 deletions examples/4_embed_interpreter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mv ./bin/bash-static ./
rm -rf ./bin data.tar.xz bash-static_5.2.15-2+b2_amd64.deb

# use -s flag to make our binary static too
ssc ./test_bash_static.sh binary -s -e bash-static
../../ssc ./test_bash_static.sh binary -s -e bash-static

# test it
rm -f bash-static
Expand All @@ -45,7 +45,7 @@ mv ./bin/busybox ./
rm -rf ./bin data.tar.xz busybox-static_1.35.0-4+b3_amd64.deb data.tar.xz

# use -s flag to make our binary static too
ssc ./test_busybox.sh binary -s -e busybox
../../ssc ./test_busybox.sh binary -s -e busybox

# test it
rm -f busybox
Expand Down
9 changes: 5 additions & 4 deletions examples/4_embed_interpreter/test_busybox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
#!sh
# both works

# remove extract dir /tmp/ssc/XXXXXX, this will delete all extracted files
# in this case, it's ok to remove it at the beginning of the script to avoid exposure of the interpreter
rm -rf "$SSC_EXTRACT_DIR"

echo "\$@ is $@"

# debian busybox calls it's own applet by default
# debian busybox calls it's own applet by default, so this will call busybox version of ls
# see https://unix.stackexchange.com/questions/274273/are-busybox-commands-truly-built-in
ls --help

# remove extract dir /tmp/ssc/XXXXXX, this will delete all extracted files
rm -rf "$SSC_EXTRACT_DIR"
7 changes: 6 additions & 1 deletion examples/5_embed_archive/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ We can embed a whole python package to our binary.
wget https://github.com/indygreg/python-build-standalone/releases/download/20240107/cpython-3.10.13+20240107-x86_64-unknown-linux-gnu-install_only.tar.gz -O cpython.tar.gz

# delete redundant files in the archive to make extraction faster
tar -zxvf cpython.tar.gz
rm -rf python/include python/share python/lib/pkgconfig python/bin/{2to3*,idle*,pip*,pydoc*,*-config}
# rm -rf python/lib/{*tcl*,thread*,Tix*,tk*}
tar -zcvf cpython.tar.gz python
rm -rf python

# use -s flag to make our binary static too
ssc ./test_python.sh binary -s -E cpython.tar.gz
../../ssc ./test_python.sh binary -s -E cpython.tar.gz

# test it
./binary
Expand Down

0 comments on commit dc48037

Please sign in to comment.