1828933 Members
2273 Online
109986 Solutions
New Discussion

Re: Shell Compiler

 
SOLVED
Go to solution
Mark Philip L. Castro
Occasional Advisor

Shell Compiler

Is there such thing as a posix shell compiler or any thing software that can make your executable posix shell script unreadable but executable?
11 REPLIES 11
John Carr_2
Honored Contributor

Re: Shell Compiler

Hi

not sure exactly what you are trying to achieve but try this

cp /usr/bin/sh ~
cd ~
chmod 111 ./sh

ls -l ./sh

./sh

you have an executable shell with no read permissions

John.
Mark Philip L. Castro
Occasional Advisor

Re: Shell Compiler

Rephrasing my question, is there any way I can hide the contents of a posix shell SCRIPT so as to make the file executable but not readable?
Eric Antunes
Honored Contributor

Re: Shell Compiler

Try the following:

chmod ugo-rw <script>.sh
Each and every day is a good day to learn.
John Carr_2
Honored Contributor

Re: Shell Compiler

Hi

I do not think it is possible to compile a shell script to achieve this. You can however compile perl which will hide the code.

John.
John Carr_2
Honored Contributor

Re: Shell Compiler

I think Antunes is mistaken the script will not execute without read permission.

carrjo% chmod 111 test
carrjo% ls -la
total 418
drwxr-xr-x 2 carrjo root 96 Jun 4 08:51 .
drwxr-xr-x 23 root root 1024 May 27 13:56 ..
-rw------- 1 carrjo 1494 4 Jun 4 08:37 .sh_history
-rw-r--r-- 1 carrjo 1494 0 Mar 17 14:47 foo
---x--x--x 1 carrjo 1494 209136 Jun 4 08:36 ksh
---x--x--x 1 carrjo 1494 53 Jun 4 08:51 test
---------- 1 carrjo 1494 29 Mar 17 14:27 testfile
carrjo% ./test
./test: ./test: cannot open
carrjo% chmod 555 test
carrjo% ls -la
total 418
drwxr-xr-x 2 carrjo root 96 Jun 4 08:51 .
drwxr-xr-x 23 root root 1024 May 27 13:56 ..
-rw------- 1 carrjo 1494 4 Jun 4 08:37 .sh_history
-rw-r--r-- 1 carrjo 1494 0 Mar 17 14:47 foo
---x--x--x 1 carrjo 1494 209136 Jun 4 08:36 ksh
-r-xr-xr-x 1 carrjo 1494 53 Jun 4 08:51 test
---------- 1 carrjo 1494 29 Mar 17 14:27 testfile
carrjo% ./test
hello world
***********
ss1025:carrjo%
Eric Antunes
Honored Contributor

Re: Shell Compiler

Your're wright John, if I can´t read it, I can´t execut
Each and every day is a good day to learn.
Steve Lewis
Honored Contributor

Re: Shell Compiler

Look at this shell compiler:

http://www.comeaucomputing.com/faqs/ccshlit.html

These things have been around for a while.

Mark Philip L. Castro
Occasional Advisor

Re: Shell Compiler

where can I download or acquire this compiler?
John Carr_2
Honored Contributor
Solution

Re: Shell Compiler

Mark

you will have problems if you use the ccsh compiler Steve has pointed you to it is NOT the posix shell you have mentioned. You may be able to change your scripts to be the bourne shell then compile the script of course.

John.

Sanjay Kumar Suri
Honored Contributor

Re: Shell Compiler

You can do this by writing/compiling a small c program on the lines below:

#file1.c
main()
{
system("shell_script");
}

cc file1.c -o file1

Now file1 is executable and the script file shell_script can be hidden.

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Mark Grant
Honored Contributor

Re: Shell Compiler

I'll second that. Many people trust shell compilers but I wouldn't personally.

And you definately can't execute anything without read access.

There is one possiblity that comes to mind and that is to compress your scripts or even encrypt them but have a C program that you use as a decrypter/runner. Users have to use your C program to run the script.

I would ask why you need to do this. If it's a script that contains passwords or such like, there is nearly always a better way to achieve it. If it contains other sensitive information, just encrypt the parts of the code that are sensitive and get the script itself to decrypt that and use "eval" or some thing to run that portion of code.
Never preceed any demonstration with anything more predictive than "watch this"