GithubHelp home page GithubHelp logo

liberize / ssc Goto Github PK

View Code? Open in Web Editor NEW
51.0 4.0 16.0 80 KB

Convert shell script to binary

License: GNU General Public License v3.0

C++ 69.15% Shell 13.52% C 17.34%
bash compiler converter perl python script sh shc shell shellscript

ssc's People

Contributors

liberize avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ssc's Issues

脚本内执行source命令

原脚本是source了一个脚本,以加载一些函数,现在这两个脚本都被加密了,由于它们都是二进制文件,所以无法正常source

/dev/fd symlink creation

When running the binary in the embedded environment I need to create the symlink manually after mounting devtmpfs:
ln -s /proc/self/fd /dev/fd

Perhaps SSC could create this link by itself if its missing?
Once symlink is in place then binary works as expected.

Hardening the '-u' flag

Unless I'm missing something here is a simple way to bypass the '-u' flag:

#!/bin/sh

strace -vf -p $$ -s 256 -o strace.log &
exec ./ssc-script

ssc-script is the real script compiled by the SSC utility.

Can we make that SSC will abort execution if strace is attached already to its process?

Thank you.

“parse shebang failed: Success”

Compiling in Termux, it runs normally when execute the encrypted file directly, but when placed in /data/local/tmp on the same phone to run, it prompts: "parse shebang failed: Success." The shell script is as follows:

#!/system/bin/sh
echo "hello world"

image

rc.4 has no CXXFLAGS set

Please add CXXFLAGS for rc4 otherwise cross compilation fails when '-s' (static) and '-4' flags are used.

Please change:
[ -f ./rc4 ] || $CXX -std=$CXX_STANDARD "$DIR/rc4.cpp" -o rc4 || exit 1

to:
[ -f ./rc4 ] || $CXX $CXXFLAGS -std=$CXX_STANDARD "$DIR/rc4.cpp" -o rc4 || exit 1

Thank you

error basename

ho uno script shell dove all'interno mi serve recuperare il nome dello script, esempio:

#!/bin/bash
script_name=$(basename "$0")
echo "$script_name"
./test.sh
test.sh

ssc -u test.sh test
./test
3

once the script has been compiled with ssc, it seems that it no longer retrieves basename... how can this be remedied?

Thanks

A bug or feature?

There are two scripts:

  • scriptA
  • scriptB, scriptB is called within scriptA with full path.

Use ssc to compile scriptA, got scriptA.x, and compile scriptB, got scriptB.x.

Run the cmd, ./scriptA, and I got the following message,

/bin/bash: --: invalid option
Usage:	/bin/bash [GNU long option] [option] ...
	/bin/bash [GNU long option] [option] script-file ...
GNU long options:
	--debug
	--debugger
	--dump-po-strings
	--dump-strings
	--help
	--init-file
	--login
	--noediting
	--noprofile
	--norc
	--posix
	--pretty-print
	--rcfile
	--rpm-requires
	--restricted
	--verbose
	--version
Shell options:
	-ilrsD or -c command or -O shopt_option		(invocation only)
	-abefhkmnptuvxBCHP or -o option

While the same script works fine with shc.

hide process name from ps / top?

Hi, love the project, thank you so much for it!

I am trying to use this to hide a process from myself such that I cannot kill it. Using this project I was able to get rid of the script name being listed (and greppable) in ps output. However, all processes spawned that were compiled using ssc are now called /bin/zsh /dev/fd/3. Is there any way I can change this? Ideally I would set it to a random string that mimic or closely resemble existing processes on my PC.

image

Thanks!

Is it possible to run bin file generated as non root or sudoer user?

When I launch the bin file generated by ssc, I need to be at least sudoer, that I would like to avoid as non root or sudoer user should launch the bin file. How I can do that ? Do I have any parameters that I need to set when I launch ssc ?
For information, I compile bash scripts.
Thank you for your reply.

Error when the target script is not in the same directory

When I was trying to convert a file in another directory, It threw an error in Perl Regex:

Used command:

 ./ssc -u -s ~/exec.sh mains -v

Result:

+ CXXFLAGS=' -DUNTRACEABLE -static -static-libgcc -static-libstdc++ -v'
+ shift
+ '[' -n '' ']'
+ eval set -- '"/home/oem/exec.sh"' '"mains"'
++ set -- /home/oem/exec.sh mains
+ '[' -n '' -o 2 '!=' 2 ']'
++ dirname ./ssc
+ DIR=.
+ perl -pe 's/SCRIPT_FILE_NAME//home/oem/exec.sh/g; s/SCRIPT_CONTENT/`cat '\''/home/oem/exec.sh'\''`/ge' ./main.cpp
Unknown regexp modifier "/h" at -e line 1, at end of line
Unknown regexp modifier "/h" at -e line 1, near "; "
Can't find string terminator "`" anywhere before EOF at -e line 1.
+ exit 1

Maybe need to escape \ character?

Enhancement: mount proc automatically

Hi Paul,

Can we mount proc filesystem automatically in case:

a) its not mounted already
b) ssc script was run as root

Right now I need to use another utility to mkdir /proc and mount 'proc' filesystem before I can use SSC compiled script.

Thank you.

Building dependencies

what packages are necessary to successfully build the binary pls?

UTSL, I saw perl, g++, and clang++?

I.e., clang is "C, C++ and Objective-C compiler", if I have clang do I still need g++, or vice versa?

I.e., what are the minimum packages necessary for building under Debian and MacOS (homebrew & macport) please?

Thanks

stdin from pipe

The design of ssc is significantly secure than shc, but one major question --

can the script read from pipe as input, to act as a filter?
I.e., can the compiled binary "behaves exactly like the original script"?

How to find the real path of the interpreter

Hello,

I'm compiling my script with following options:
ssc -0 -4 -u -s -r -i /bin/bash -e ./bash script.src script

I know the interpreter gets unpacked to a subfolder in /tmp upon execution.
Is there a way to find a real path to the unpacked interpreter from the script?

I want to run MD5 sum check on it before executing the main part of the script.

Or maybe to force a path where the interpreter should be unpacked?
(must overwrite the existing file)

Thanks

Header 'wordexp.h' not found using Termux

This happen while using Termux for compile a shell script, as my attempts to make a working binary on Android environment since binary that compiled on linux won't work in Android, throwing error env: exec mtkfest: No such file or directory.

$ bash ssc -u mtkfest mtkfest.x
mtkfest.cpp:10:10: fatal error: 'wordexp.h' file not found
   10 | #include <wordexp.h>
      |          ^~~~~~~~~~~
1 error generated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.