Languages and Scripting

Re: How to convert bash scripts into binary's, so no one can read it

 
SOLVED
Go to solution
Abii
Advisor

How to convert bash scripts into binary's, so no one can read it

Hi all,

Can you please help me to create a binary file for a bash script, I need step by step procedure for doing this .....decent points assured for helpfull answers ..Thanks in advance

Abi
22 REPLIES 22
VK2COT
Honored Contributor
Solution

Re: How to convert bash scripts into binary's, so no one can read it

Hello,

THis is what is commonly called
security through obscurity. Most
of those binary converters can be broken.

Anyway, one of the most popular ones
is Generic Shell Script Converter:

http://directory.fsf.org/project/shc/

or go directly to it:

http://www.datsi.fi.upm.es/~frosal/

Easy to use. Its current version is 3.8.6.
Typical install:

make test
make strings
make install

One example of usage:

shc -r -T -f myscript

C complier is required to compile this utility.

Cheers,

VK2COT
VK2COT - Dusan Baljevic
Abii
Advisor

Re: How to convert bash scripts into binary's, so no one can read it

Hi Dusan,

If have tried what you said ,but I am getting the below error .Please let me know where I am wrong .

FYI:- SHC has been installed .

root@hp:/var/abi/c/shc-3.7# ls
CHANGES c2s.sed s2c.sed shc.c test.csh
Copying match shc.1 shc.html
Makefile pru.sh shc.README test.bash
root@hp:/var/abi/c/shc-3.7# make test
cc -Wall -O6 -pedantic -o shc
(Bundled) cc: error 1914: bad form for `-W' option
*** Error exit code 1

Stop.

A. Clay Stephenson
Acclaimed Contributor

Re: How to convert bash scripts into binary's, so no one can read it

I rather doubt that you are going to be able to compile this utility using the Bundled C compiler. It is intended for building kernels and only understands K&R syntax. You probably need to install aCC (purchased) or gcc (free).
If it ain't broke, I can fix that.
Abii
Advisor

Re: How to convert bash scripts into binary's, so no one can read it

Hi Clay ,

Thanks for your advice , I will install ac++ developer bundle tomorrow and update you .

Abi
James R. Ferguson
Acclaimed Contributor

Re: How to convert bash scripts into binary's, so no one can read it

Hi Abi:

My first thought is the same as Dusan's. My curiosity is up.

I might guess that you don't work for a vendor who has and uses the tool about which you asked.

I might guess that you're a free-lance consultant who would like to make sure that any modifications your client might want to the shell you have provided requires them to come back (pay?) you.

Are you trying to hide the (human) readability of the code because it has a password buried in it? There are better ways.

Are you writing a shell script and trying to make it a 'setuid' script? There are ways to implement this without resort to translating shell into binary (C) code.

Since you responded that you were going to install the HP-UX C/aC++ bundle I assume that you are going to pay for the full version since the evaluation copy will expire leaving you high-and-dry when you want to change your shell script.

Frankly, I'd ask you, "What problem are you trying to solve?"

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: How to convert bash scripts into binary's, so no one can read it

>but I am getting the below error
cc -Wall -O6 -pedantic -o shc
(Bundled) cc: error 1914: bad form for `-W' option

>Clay: I rather doubt that you are going to be able to compile this utility using the Bundled C compiler.

We don't know because the above error is related to using gcc options that HP's IPF compiler doesn't allow.

>I will install aC++ developer bundle tomorrow

You will have to remove these gcc options: -Wall -O6 -pedantic
James R. Ferguson
Acclaimed Contributor

Re: How to convert bash scripts into binary's, so no one can read it

Hi (again) Abii:

...and if you should want to use the GNU gcc compiler, you can obtain it free from either:

http://mirrors.develooper.com/hpux/

or:

http://hpux.connect.org.uk/hppd/hpux/Gnu/gcc-4.2.2/

Regards!

...JRF...

Abii
Advisor

Re: How to convert bash scripts into binary's, so no one can read it

Hi ,

Sorry ,let me clear about my requirement.

I need to convert my Unix shell script file to binary file.

Clay ,
I have installed C developers bundle and gcc too ,still am getting the below error while doing make


fyi:-

# pwd
/var/abi/shc/shc-3.8.6
# ls
CHANGES Makefile pru.sh shc.1 shc.c test.bash
Copying match shc shc.README shc.html test.csh

# make test
*** Compiling script "match"
CFLAGS="-Wall -O6 -pedantic" ./shc -v -f match
/usr/bin/sh: ./shc: Execute permission denied.
*** Error exit code 1

Stop.

# swlist |grep -e aC++ -e gcc
B9007AA C.11.23.12 HP C/aC++ Developer's Bundle
gcc 4.2.2 gcc
#


Please help me to resolve this issue at the earliest

Thanks,
Abi
Dennis Handly
Acclaimed Contributor

Re: How to convert bash scripts into binary's, so no one can read it

>I need to convert my Unix shell script file to binary file.

(You still haven't said why.)

CFLAGS="-Wall -O6 -pedantic" ./shc -v -f match
sh: ./shc: Execute permission denied.

Was this the gcc or cc run?
Is shc executable?
You'll probably have to do a clean and then show all errors.