Solved

converting bash script into binary??

Posted on 2007-04-01
11
5,005 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
Comment Utility
WHy don't you use
chmod 700 nis.sh

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

Expert Comment

by:NickUpson
Comment Utility
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
Comment Utility
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
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
Comment Utility
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
Comment Utility
> 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 48

Expert Comment

by:Tintin
Comment Utility
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
Comment Utility
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
Comment Utility
Sometimes you have to read between the lines.

BTW, welcome back :-)
0
 
LVL 51

Expert Comment

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

Expert Comment

by:Hanno Schröder
Comment Utility
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
Comment Utility
Forced accept.

Computer101
EE Admin
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now