Is there any way I can obfuscate ".sh" shell script?

This really depends on who you are trying to prevent from reading the script and what resources you are expecting the system to have.

One option is to simply use many different programs to do different parts of your script: shell, awk, sed, perl, etc. as well as lots of obscure parameters of tools, forcing the reader to constantly refer to man pages.

Even within a shell, you can create unnecessary functions and variables, making them interdependent in confusing ways. And, of course, give them misleading names.

More complicated, you can append binary data to the end of your shell and have your shell extract and execute the binary. I believe nVidia's Linux drivers, and Sun's JDK are installed this way (the binary data is an RPM, which the shell extracts and installs). Another example I just downloaded the other day is the soapUI program.

In that vein, it is possible to have a text file that can be compiled or interpreted in multiple languages, so it could start as a shell, compile itself as a C program and execute the result. The IOCCC has some examples.

Tags:

Shell Script