Solved

converting bash script into binary??

Posted on 2007-04-01
11
5,019 Views
Last Modified: 2013-11-22
How to convert bash scripts into binary's, so noone can read it.
For example i just created script to set up NIS server as follows but anyone can view with just vi nis.sh cmd.
#vi makenis.sh
clear
echo "                       WELCOME TO NIS SEVER CREATOR"
echo
echo
mkdir /nisserver
if [ $? == 0 ]; then
echo
echo "A FOLDER NAMED /nisserver HAS BEEN CREATED FOR USER'S HOME DIRECTORY"
fi
cd /nisserver
echo
echo  "           ENTER THE USER NAME "
read x
echo "            ENTER THE NUMBER OF RECURSSION"
read y

if [ $y == 0 ]; then
echo "wrong choice try again"
else
      for i in $(seq 1 1 $y)
      do
            mkdir `echo $x`_$i
            useradd -d /nisserver/`echo $x`_$i `echo $x`_$i
            passwd `echo $x`_$i
            chown `echo $x`_$i /nisserver/`echo $x`_$i
            chgrp `echo $x`_$i /nisserver/`echo $x`_$i
            
      
done
fi
clear
echo "USERS ARE CREATED"
sleep 3
cd /var/yp/
cp -f /usr/share/doc/ypserv-2.13/securenets .
clear
echo "change the netmask to 255.255.255.0       192.168.0.0                                                                                                                    (range) mention it at bottom"
echo
echo "CHEAT CODE : highlight with help of mouse"
sleep 8
vi securenets
nisdomainname nisserver
clear
echo "NISDOMAINNAME CREATED AS nisserver "
echo
echo "NOW MENTION NISDOMAIN NAME PERMANENTLY"
sleep 5
vi /etc/sysconfig/network
clear
echo "now SHARE nissuser folder in /etc/exports AS:   /nisserver     *(rw,sync)"
echo
echo "CHEAT CODE : highlight with help of mouse"
sleep 8
vi /etc/exports
clear
echo "PRESS ctrl d AND PRESS y AND Enter"
sleep 2
echo
/usr/lib/yp/ypinit -m

sleep 2
service ypserv restart

service yppasswdd restart

service nfs restart
sleep 2
clear
echo "          CONGRATULATIONS YOU HAVE SUCCESSFULLY CREATED NIS SERVER"
echo
echo
echo
echo
echo
echo
echo "                          CREATED BY NAVEED - abhijeet"
sleep 5

0
Comment
Question by:w2kservers
11 Comments
 
LVL 29

Expert Comment

by:TeRReF
ID: 18831976
WHy don't you use
chmod 700 nis.sh

so only root/owner can access it...
0
 
LVL 19

Expert Comment

by:NickUpson
ID: 18832018
There is no mechanism I've every seen to convert a shell script into a binary, you could re-write it into C, such that each line of script was hard-coded into the C program and then compile that
0
 
LVL 34

Expert Comment

by:Duncan Roe
ID: 18833364
If the lines were hardcoded into a C program, the strings command would display them (or less, or cat -A). You would need to write a C program to programatically do what the shell script did. But and string constants would be visible. Why do you care so much?
If (as it seems) the file is only for use by root, then chmod 700 is the answer, as  TeRReF said.
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 18833720
See the following links for shell script compilers.  Essentially they work by encrypting the shell script and wrapping C code around it.  

http://www.datsi.fi.upm.es/~frosal/
http://www.comeaucomputing.com/faqs/ccshfaq.html
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 18835103
> How to convert bash scripts into binary's, so noone can read it.
Impossible. Dot.

shc already mentioned, but it also does not fit your requirement "noone can read" ;-)
0
 
LVL 48

Expert Comment

by:Tintin
ID: 18839693
ahoffmann.

You know as well as I do, that when most people say "no one can read it", they really mean "no one can easily read it".

shc is a perfectly acceptable solution to prevent casual viewing of the source script.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 18839753
Why do people write different things than they mean?

Tintin, you know I'm picky as usual (when security counts;-)
0
 
LVL 48

Expert Comment

by:Tintin
ID: 18840291
Sometimes you have to read between the lines.

BTW, welcome back :-)
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 18841542
damn, I only can write, never learned to read ...
0
 
LVL 16

Expert Comment

by:Hanno P.S.
ID: 21170170
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup Zone:
ACCEPT Tintin's comment {http:#18833720} as answer

Any objections should be posted here in the next 4 days. After that time, the question will be closed.
JustUNIX, Experts Exchange Cleanup Volunteer
0
 
LVL 1

Expert Comment

by:Computer101
ID: 21198269
Forced accept.

Computer101
EE Admin
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question