Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to minify/obfuscate a bash script [closed]

Tags:

Of course a bash file cannot be truly obfuscated and will always be readable. And I don't want to wrap them in some binary package. And renaming local variables wouldn't be worth the trouble.

But is there a reliable simple bash obfuscator or minifier which at least removes all the indentation, all the empty lines and all whitespace without breaking anything? And especially the comments and commented out portions of the script which might contain sensitive documents or information?

I would be afraid of simple grep/sed-lines to do this because "HEREDOCs" must not be modified of course, so a little bit of real parsing is necessary.

Maybe there's a tool to do this, that would be great!

like image 994
Christian Avatar asked Mar 28 '12 12:03

Christian


People also ask

How do I obfuscate a bash script?

For simple usage, just pass the command you want to obfuscate with -c , or the script you want to obfuscate with -f . You can copy the obfuscated payload to your clipboard with --clip , or write it to a file with -o .

What is obfuscated script?

Obfuscation means to make something difficult to understand. Programming code is often obfuscated to protect intellectual property or trade secrets, and to prevent an attacker from reverse engineering a proprietary software program. Encrypting some or all of a program's code is one obfuscation method.


1 Answers

:P here is something funny.

say your script is named origin and the obfuscated one is named obsf.

here is origin:

#!/bin/sh echo "fooo" 

here is obsf

$ echo "echo $(base64 origin)" > obsf $ cat obsf echo IyEvYmluL3NoCmVjaG8gImZvb28iCg== $ chmod +x obsf 

now rm origin and run obsf like this:

$ sh obsf | base64 -d | sh fooo 

heh :3

like image 51
c00kiemon5ter Avatar answered Sep 28 '22 12:09

c00kiemon5ter