Link to home
Start Free TrialLog in
Avatar of linuxpig
linuxpig

asked on

Encrypting a shell script

Im looking for a FREE way to encrypt a shell script so that it cant be read but will still be able to be executed. Ive tried shc but i get an error:
 shc -f scriptname.sh
./scriptname.sh.x

./scriptname.sh.x has expired
Please contact your provider
Avatar of unSpawn
unSpawn
Flag of Sweden image

The "has expired. Please contact your provider." informational message just means an an expiration date was set and says nothing about the License of Shc, the generic shell script compiler (http://www.datsi.fi.upm.es/~frosal/). (Please note obfuscating a shell script does not keep users with sufficient access rights from retrieving the password/passphrase anyway.)
Binary is more protected - it does not need read access for execution, but anyway - trust models serve better than storing passwords.
Avatar of linuxpig
linuxpig

ASKER

Well, its not passwords in the script im looking to protect at this time, although for furture reference i may need that. But Unspawn, i received that message on a script i wrote, right after i downloaded the shc gz file, untarred it, ran make, make install and then ran shc -f script.sh. I also tried shc -r -f script.sh and shc -r -T -f script.sh.
So i wondered if there was something wrong with the gz file i downloaded, but it did this after re-downloading the gz file. So i ask if there is another way to do this, encrypting shell scripts, or if there is something im doing wrong with shc.
Thanks you!
Avatar of ai_ja_nai
>encrypt a shell script so that it cant be read but will still be able to be executed
Why don't you just get rid of read and write permissions for everybody?

chmod go-rw shellscript.sh
read permission is essential for executing shell script. also it cannot have suid bit.

have a look at sudo option - a protected user dir containing unsafe scripts, and users allowed only to call scripts, not read.
Permission and sudo wont work here as this script will be used in other servers in the future, so an actual encryption will have to work. As i have said, shc look like it may be the solution but im having issues with it.
 
So if someone know how to resolve it or knows of another way, please let me know.
Trust scheme like Kerberos.
"encrypted" which decrypts in memory image is piece of cake to snoop.
>So i wondered if there was something wrong with the gz file i downloaded
Probably something wrong with how you executed it. It works as advertised: 'echo -en '#!/bin/sh\necho hello world!\nexit 0\n' > match && ./shc -v -f match -e 01/12/2010 && ./match.x'.
Can you give me the steps on how/where you downloaded it, untarred it and then executed it, this way i can make sure the instructions im using on the internet arent faulty
ASKER CERTIFIED SOLUTION
Avatar of unSpawn
unSpawn
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial