Operating System - HP-UX
1754976 Members
3149 Online
108828 Solutions
New Discussion юеВ

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

 
SOLVED
Go to solution
Aneesh Mohan
Honored Contributor

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

Hi Dennis ,

I tried to do using ansi c too ,

# echo $CC
/opt/ansic/bin/cc
# ldd /opt/ansic/bin/cc
libstd.so.1 => /usr/lib/hpux32/libstd.so.1
libstream.so.1 => /usr/lib/hpux32/libstream.so.1
libCsup.so.1 => /usr/lib/hpux32/libCsup.so.1
libm.so.1 => /usr/lib/hpux32/libm.so.1
libunwind.so.1 => /usr/lib/hpux32/libunwind.so.1
libc.so.1 => /usr/lib/hpux32/libc.so.1
libdl.so.1 => /usr/lib/hpux32/libdl.so.1
libuca.so.1 => /usr/lib/hpux32/libuca.so.1
libdl.so.1 => /usr/lib/hpux32/libdl.so.1
# make cleanall
rm -f *.o *~ *.x.c
rm -f shc *.x

Edited Makefile :-

Comment out all the CFLAGS line except the below

# For HPUX
CFLAGS = -Ae -O +wlint

#make test


"shc.c", line 715, procedure do_all: warning #20202-D: Allocated memory may
potentially be leaked (at line 962)

*** Compiling script "match"
CFLAGS="-Ae -O +wlint" ./shc -v -f match
shc shll=sh
shc [-i]=-c
shc [-x]=exec '%s' "$@"
shc [-l]=
shc opts=
shc: /opt/ansic/bin/cc -Ae -O +wlint match.x.c -o match.x
"match.x.c", line 284: error #2165: too few arguments in function call
mine = !ptrace(PTRACE_ATTACH, pid, 0, 0);
^

1 error detected in the compilation of "match.x.c".
./shc: Error 0
*** Error exit code 1

Stop.

Thanks,
Abi
Dennis Handly
Acclaimed Contributor

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

>I tried to do using ansi C too,
"match.x.c", line 284: error #2165: too few arguments in function call
mine = !ptrace(PTRACE_ATTACH, pid, 0, 0);

Now that you are using a real compiler, it is obvious. You are hosed. You can't use ptrace on IPF since ptrace isn't supported. You must port to ttrace(2) instead.
http://docs.hp.com/en/B2355-60130/ttrace.2.html

>ME: If this is ptrace(2), this isn't supported on IPF. See the man page.
mark_gtz
Occasional Visitor

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

Hi Everyone!

I find a fix for shc ..

# export CC=/usr/local/bin/gcc

# ldd /usr/local/bin/gcc

make test
make strings
make install
***     Installing shc and shc.1 on /usr/local
-n ***  ┬┐Do you want to continue?
y
        install -c -s shc /usr/local/bin/
install: The -c, -f, -n options each require a directory following!
*** Error exit code 2
And this error is removed when executing these 2 commands manually (I need to put the DIR after the -c:)

# /usr/sbin/install  -c /usr/local/bin/ -s shc /usr/local/bin/

# /usr/sbin/install -c /usr/local/bin/ -m 644 shc.1 /usr/local/man/man1/

and the executable is installed by you!! :

/usr/local/bin/shc

# file /usr/local/bin/shc

/usr/local/bin/shc:     ELF-32 executable object file - IA64

example of usage:
shc -r -T -f myscript.sh

And generates the executable:

myscript.sh.x

Kind Regards.   !