Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm running Ubuntu. I need to know any way to obfuscate .sh shell script file contents in order to make it very difficult to read.

Any suggestion are welcome, including using online obfuscator.

share|improve this question
1  
I won't downvote just because I don't like the idea, but EEEWWW!. This goes against everything FOSS. –  Caleb Aug 24 '11 at 21:56
add comment

2 Answers

up vote 2 down vote accepted

This really depends on who you are trying to prevent from reading the script and what resources you are expeting 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 misguided names.

More complicated, you can append binary data to the end of your shell and have your shell extract and execute the binary. I beleive 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.

On thet 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 executie the result. The IOCCC has some examples.

share|improve this answer
    
The .sh files will be copied to many computer. It contains password and some more sensitive information. Just in case if it fall to the wrong hand, they don't know what is that obfuscated codes means. –  Najib-botak Chin Aug 24 '11 at 3:33
9  
Obfuscation is not encryption, which is what you really need for things like a password. –  phunehehe Aug 24 '11 at 3:43
    
Then I would recommend a either the binary data approach I mentioned or consider some way of transmuting the password, using math or a translation table (like ROT13, but more complicated). Separate from obfuscation, can't you just change the permissions so the script can be executed without being read? You could use chmod 4711 myscript.sh. –  Klox Aug 24 '11 at 3:50
    
You can't execute something you can't read. –  jw013 Sep 18 '12 at 16:54
    
@jw, yeah you're right. I don't remember what I was thinking when I wrote that. On that vein, he could store the password in a separate file with restricted permissions and still use privilege escalation (chmod 4755) on the script. –  Klox Sep 24 '12 at 22:44
add comment

Yes, there are a number of scripts out there than do a reasonable job of obfuscating bourne, bash or korn shell scripts.

Here such script: obfuscate_shell_script-20011012.html

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.