Link to home
Start Free TrialLog in
Avatar of Slightly_Imperfect
Slightly_Imperfect

asked on

encrypt a shell script

Is there anyway of encrypting a shell script so that no one can look at it ?

whilst it can still run as usual ?

just curious cheers
Avatar of jlevie
jlevie

Well, there's no built in way on any Unix that I know to do that. But I can think of a couple of ways it could be done. One would be to have the encrypted script executed by a script or code wrapper that decrypts the script file and feeds it to a shell. The other would require writing a program that would replace the "#!/bin/sh" line in the script. That code would decript the contents of the script and feed the result to a shell.

The difficulty with all of these is that the decrypt key will have to come from somewhere and that a somepoint the plain text has to exist. A clever user could find the key or intercept the plain text to see what the script contents are.

Like most things in Unix there's probably another way to solve the problem. Why exactly would you want to have the contents of the script hidden?
Avatar of Slightly_Imperfect

ASKER

The reason we are after doing this is so the customer cannot get at our code !!!!  


i was thinking of uuencode or something similar !!!! then a c program just to go out and run the command so as nobody would see the code !!!


Does anyone know of a utility out there that might compile shell scripts?
Well if you really don't want a customer to get at the code then it needs to be a compiled program, not a script. As I mentioned, at some point in the scripts execution (assuming the use of a standard shell) the commands must exist as plain text. Even a moderately clever customer would be able to recover those commands pretty easily.

The only way that I can thing of other than compiled code to really hide what you are doing would be to use a modified shell that could read the encrypted script directly. In that case the crypto key could be hidden in the shell executable, so the script would be pretty secure.
Avatar of ozo
A compiled program can also be disassembled, If you really want to keep the code secure, you may want to use a protocol that only allows running the code, and not reading it.
ASKER CERTIFIED SOLUTION
Avatar of skakee
skakee

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
I have found a freeware shell script compiler called shc if anybody wants it

go to msn search and type shell script compiler !!!

you should have a page from someone called francisco rosales garcia

it is in gzip format !!! it works reaaly well !!!


cheers guys !!!
Does this compiler work for UNIX OS's, or just Winders.
I have found a freeware shell script compiler called shc if anybody wants it

go to msn search and type shell script compiler !!!

you should have a page from someone called francisco rosales garcia

it is in gzip format !!! it works reaaly well !!!


cheers guys !!!
It says it works on all unix backgrounds !! not to sure but it works on HP-UX.