shary
December 11, 2007, 1:17am
1
Dear Experts,
I am using one script name :volume.sh and its written in bash shell script.
I just want to encrypt the script so that any one else cannot see it.
please tell me the commands how to encrypt the script as well as to decrypt it.
Regards,
SHARY
porter
December 11, 2007, 1:44am
2
Are other people supposed to be able to run it while it's encrypted, if so how is the interpretor going to understand the file?
shary
December 11, 2007, 2:04am
3
Yes i want that the other people can also run the encrypted script .
But i dont want to show them the code is there is any way out.
porter
December 11, 2007, 2:14am
4
Out of interest, why?
Is this security through obscurity?
If the interpretor can decode the script to run it, why can't a person?
Start the file as follows
#!/bin/sh
cat >/dev/null <<EOF
.....
tons of rubbish
....
EOF
then follow that with the working parts all on a single line using the ";" separator.
shary
December 11, 2007, 2:38am
5
Dear Sir ,
I am totally lost what you have mentioned . I mean i didnt understand the technique to encryt and to run the shell script.
Regards,
SHARY
porter
December 11, 2007, 2:47am
6
An obscure script....
#!/bin/sh
cat >/dev/null <<EOF
ssdf
sdf
sdfhgfgjhghk
ghjgfjgfjgh
jhkjh
k
jhk
jhlkjhljklkj
jghjghghj
jh
kljh
kljh
ljk
l
kjlkjljkkj
jk
l
kj
lkj
ljklkjlkjljkl
kjl
jk
l
kj
l
jk
l
jk
lkjljk
l
kjhjkljhklhfjkhfkjhkjhkjhkjh
EOF
first() { echo $1 }; second() { echo $2 }; third() { echo $3 }; ps -ef -o "pid etime comm" | while read PID ETIME COMM; do case "$ETIME" in; *:* ) DAYS=0; HOURS=0; MINUTES=0; SECONDS=0; case "$ETIME" in; *-* ) X=`echo $ETIME | sed y/-/\ /`; DAYS=`first $X`; ETIME=`second $X`; ;; * ) ;; esac; X=`echo $ETIME | sed y/:/\ /`; case "$ETIME" in; *:*:* ) HOURS=`first $X`; MINUTES=`second $X`; SECONDS=`third $X`; ;; *:* ) MINUTES=`first $X`; SECONDS=`second $X` ;; *) ;; esac; HOURS=`echo $HOURS + \( $DAYS \* 24 \) | bc`; MINUTES=`echo $MINUTES + \( 60 \* $HOURS \) | bc`; SECONDS=`echo $SECONDS + \( 60 \* $MINUTES \) | bc`; if test "$SECONDS" -gt "3600"; then echo $PID $COMM; fi ;; * ) ;;esac;done
How about
#vi -C somefile
It will ask u for a password while creating it and later while opening it.
Although the encryption might not be strong enough. Please read man vi
for the options.
Addition/Correction to the above post:
You would not be able to run the shell script. However you can encrypt the contents.
porter
December 11, 2007, 3:20am
9
Yup, defeats the purpose, somewhat.
Hi Shary,
You can use the "crypt" command to encrypt your file....Pl go thorugh the man pages for its syntax. None wud be able to view the file...Hence ur first condition is satisfied...
Command: For encryption
% compress myfile
% ls -l myfile.Z
% dd if=myfile.Z of=myfile.Z.strip bs=3 skip=1
% crypt akey < myfile.Z.strip
For Decryption:
% (compress -cf /dev/null;crypt < myfile.Z.strip) | uncompress -c > myfile
Pl check the above code snippet...U ll be able to encrypt and decrypt ur file...
About ur next condition,I am sorry to say that you wont be able to run the encrypted script...You ll ve to first decrypt it before using it...