Solved

converting bash script into binary??

Posted on 2007-04-01
11
5,011 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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 Schröder
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
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 …
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

770 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