Encrypted script not working


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Encrypted script not working
# 8  
Old 02-10-2011
What Operating System and version are you using?
What Shell are you using?

The script in post #1 has appeared on many boards. For example

Can we hide the code of a Shell Script?

Is is dangerous to cut/paste code you find on the internet unless you understand that code.

Why do you want to obfuscate or encrypt shell script? There is really no substitute for correct file permissions and access lists.

---------- Post updated at 16:43 ---------- Previous update was at 16:39 ----------

Quote:
tr 'a-zA-Z' "some-encryption-key" <<EOF_EOF | sh /dev/stdin |
To my mind the /dev/stdin and the trailing pipe character are surplus.

Also in most versions of "tr" there must be exactly the same number of characters either side. So your "key" would probably be 52 characters (it depends on the character set).

Last edited by methyl; 02-10-2011 at 12:58 PM..
# 9  
Old 02-10-2011
yes i roughly understand it, and i'm running it on cygwin so i'm not too bothered about any dangers. I want to encrypt or obfuscate stuff because somebody said to me that I won't be able to. I know that anyone can easily decrypt it if they bother having a go.

I did try it without the /dev/stdin | originally but it said that it was expecting something after it so wouldn't work. I added the pipe and the error disappeared. the key variable is as you describe it.

The problem is how I'm ending the script. the actual encrypted script is fine. after the #!/ova/fu there is the encrypted #!/bin/bash. This is the full code though, feel free to criticise how bad I am at this.

the 'scrypt' variable is the path of the script that is to be encrypted
the 'key' variable is the encryption key.

Code:
#BACKUP
cat $scrypt > $scrypt.old
#ENCRYPTER
cp $scrypt temps1.txt
cat temps1.txt | tr 'a-z' \""$key"\" > $scrypt
rm temps1.txt
#DECRYPTER 
cp $scrypt tempscrypt.txt
echo "#!/bin/sh
tr 'a-z'" \
" \""$key"\" <<EOF_EOF | sh /dev/stdin |" > tempscrypt.txt
echo "#!/ova/fu" >> tempscrypt.txt
cat $scrypt >> tempscrypt.txt
echo 'EOF_EOF' >> tempscrypt.txt
cp tempscrypt.txt $scrypt
rm tempscrypt.txt
echo ""
echo "Done."
read -p "Press enter to exit..."
exit


Last edited by Trichopterus; 02-10-2011 at 01:56 PM..
# 10  
Old 02-10-2011
I think methyl got it. Get rid of that trailing "/dev/stdin | ". The trailing | is especially bad.
# 11  
Old 02-10-2011
ok its working now. thanks everyone!
# 12  
Old 02-10-2011
Because I cannot believe that the code in post #9 is the finished product, please post the final version of the code.
# 13  
Old 02-11-2011
Quote:
Originally Posted by Trichopterus
thanks for all the help, I've skipped out all the fifo stuff and now have this:

Code:
#!/bin/sh
tr 'a-zA-Z' "some-encryption-key" <<EOF_EOF | sh /dev/stdin |
#!/ova/fu
*encrypted script goes here*
EOF_EOF

I'm getting only one error: unexpected end of file
its not surprising since I don't fully understand EOFs. Any help?
What is that extra pipe for? You're not piping the shell's output into anything that I can see...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to pass an argument to encrypted script having openssl ?

Hi, can it be possible to pass and argument to an encrypted script? for example.. Say I have this script which takes one input.. > cat aa #!/bin/ksh UNAME=$1 echo "Hi $UNAME.." > aa TEST Hi TEST.. Now I encrypted this code.. (6 Replies)
Discussion started by: akore83
6 Replies

2. Shell Programming and Scripting

Encrypted password in script

How to keep encrypted password in a shell script.? I have the file which has the following: a.sh ----- username=abc password=abc I will be using this username and password in another script. But I don't want to reveal the password in the script. How to keep the password... (3 Replies)
Discussion started by: sanvel
3 Replies

3. UNIX for Dummies Questions & Answers

Execute a encrypted shell script

Hi All, I have a shell script test.sh. I encrypted it using the command vi -x test.sh , and protected it with a password to view the file. When i tried to execute the file with ./test.sh..It is trying to execute the encrypted file but not he original one. Can someone help me with how to... (1 Reply)
Discussion started by: pracheth
1 Replies

4. Shell Programming and Scripting

Script not working in cron but working fine manually

Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered. The script is as follow: #!/bin/sh for file in file_1.txt file_2.txt file_3.txt do awk '{ print "0" }' $file > tmp.tmp mv tmp.tmp $file done And the cron... (2 Replies)
Discussion started by: jasperux
2 Replies

5. Shell Programming and Scripting

run vi/vim encrypted shell script without decryption on multiple servers

Hello Everyone, How do we run vi/vim encrypted shell script without decryption on multiple servers. It is a simple bash script and vim -nx <filename> has been used to encrypt with desired password. Now I have few errors, the syntax is absolutely fine as I have run that script multiple times on... (0 Replies)
Discussion started by: lovesaikrishna
0 Replies

6. Shell Programming and Scripting

Script is not working from cron while working manually

Hello, I am facing a very strange problem when I run my script manuallu ./Fetchcode which is using to connect with MKS integrity from linux end it workks fine but when I run it from cron it doesn't work.Can someone help me 1) How could I check my script when it is running from cron like... (3 Replies)
Discussion started by: anuragpgtgerman
3 Replies

7. Shell Programming and Scripting

gzip and encrypted in a shl script

After I move the file to a directory, I need to gzip and encrypted. I never do this in a shl script, I do it from the command line and it works.. cd /home/nelnet spinel:/home/nelnet$ gpg -e 2010_11_07_05_11_xxxxxx_bills.dat.gz `/home/nelnet/.gnupg/gpg.conf' `/home/nelnet/.gnupg/gpg.conf'... (3 Replies)
Discussion started by: rechever
3 Replies

8. Shell Programming and Scripting

Script not working..."sort" not working properly....

Hello all, I have a file - 12.txt cat 12.txt =============================================== Number of executions = 2 Total execution time (sec.ms) = 0.009883 Number of executions = 8 Total execution time (sec.ms) = 0.001270 Number of... (23 Replies)
Discussion started by: Rahulpict
23 Replies

9. Shell Programming and Scripting

executing an encrypted script

Can we execute an encrypted shell script . I encrypted a shell scripts with crypt with keys and tried to execute it it gave me segmentation faul?? Can somebody answer this one please?? If we can is there any settings i need to change?? Thanks (2 Replies)
Discussion started by: ajnabi
2 Replies

10. Solaris

Execute shell or script encrypted

Hi. I want to execute a script when it's encrypted with "crypt". I tried with "sh <script_crypted>", but it's incorrect because the commands into "script" can not be executed because they are encrypted. :confused: (1 Reply)
Discussion started by: hilsie
1 Replies
Login or Register to Ask a Question