# shellc **Repository Path**: chukk8/shellc ## Basic Information - **Project Name**: shellc - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-02-05 - **Last Updated**: 2024-07-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # shellc **Tool for converting scripts into C code** ### Install ```bash cc shellc.c -O2 -o shellc ``` ### Compile shell scripts and generate executable programs ```bash shellc sh example.sh cc example.sh.c -O2 -o example ``` The generated C code is ```example.sh.c```, which is the original file name followed by ```.c```. For programs used in production environments, it is recommended to add the parameter ```-s``` or use the ```strip``` command after compilation to remove the symbol table in the executable program, increasing the difficulty of disassembly and reverse engineering. I have tried the tools ```shc```, which can compile shell scripts into executable programs. The main problems are: The ```shc``` command actually calls the ```sh -c``` command. The source code can be seen through the ```ps -ef``` command. The length of the shell script cannot exceed ARG_MAX . Shellc not only solves the problems that exist in ```shc```, ```shellc``` also adds code obfuscation, randomly generating effective character position calculation functions, random character encryption, and debugging to increase the complexity of disassembly and reverse engineering.If further difficulty is required, professional tools such as ```obfuscator-llvm``` can be used to further obfuscate the generated C code. Version 1.0 or above not only support shell, but also other scripting languages, which can completely replace ```shc```. At present, the program has practical applications in ```AIX```, ```UNIX```, ```Linux``` environments. It is recommended to conduct comprehensive testing on the compiled program to prevent production failures. ### User manual - Generate C code command ```shellc command inputfile [-t] [-s] [-f fix-format] [-e fix-file] [-p parameter] [-b 8|16|32|64]``` command: Execute script commands, such ```sh```,```perl```,```python```,```node```,```ruby```,```Rscript```,```php```, etc. inputfile: Script file name -t option: For systems that do not support anti debugging functionality, this option is required for generated code. -s option: Generate C code mode, the -s option uses safe mode, and defaults to normal mode. -f option: Fix parameter 0 value or safe mode external parameter. -e option: Fix parameter 0 value by custom external file. -p option: Command parameter, such as ```busybox shell``` using by ```shellc busybox example.sh -p sh```. -b option: Operating system bits setting. - Code pattern differences The normal mode shell script has some code visibility issues in most Linux operating systems, and the code after the ```read``` command can be obtained through ```/proc/[pid]/fd/[pipe]```. The safe mode does not have this issue. The normal mode supports semaphore processing in scripts, while the safe mode does not support it. The normal mode supports human-machine interaction in all scripting languages, while some languages in safe mode do not support it, such as ```csh```,```tcsh```. The safe mode human-machine interaction needs to be modified to read from the device ```/dev/tty```. such as shell script ```read input``` needs to be changed to ```read input