LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-18-2004, 06:10 PM   #1
RitzContent
LQ Newbie
 
Registered: Nov 2004
Posts: 8

Rep: Reputation: 0
Question about scripting


Hello everyone
I have looked and haven't beable to find any answers that would help me..

So here I go..

I have writen up a korn script to be used in solaris and it works but I would like to protect it from it being edited because other people use it and I don't want to trouble shoot something they could of edited and messed up.

So is there away to encrypt the script so its not readable but yet still executeable? Or is there a way to complie it into a format to be used in solaris? Kind of like how you take a bat file for windows and turn it into a com file.

Or is there another lanuage that is close to korn that can be complied that someone can point me in the right direction?

thanks for any help
 
Old 11-18-2004, 06:27 PM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 58
You can just chmod it and remove their write permissions and leave the execute permissions.
 
Old 11-18-2004, 06:55 PM   #3
RitzContent
LQ Newbie
 
Registered: Nov 2004
Posts: 8

Original Poster
Rep: Reputation: 0
Well the script is on a floppy so it won't really work if they happen to use a windows OS to mess it up.
 
Old 11-18-2004, 06:56 PM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,500

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
If you want a stronger protection, try shc, at
http://www.datsi.fi.upm.es/~frosal/frosal.html

It wouldn't prevent truss/strace/dtrace or equivalent programs to snoop what's your program is doing, but the source code will be obfuscated.
 
Old 11-18-2004, 09:03 PM   #5
Chrax
Member
 
Registered: Apr 2004
Distribution: Dapper
Posts: 167

Rep: Reputation: 31
If nobody should be able to write to the disk at all, you could flick the little writable thing on the floppy (one of the corners, if it's open it's non-writable, if it's close it's writable). Otherwise keep a copy on your system and just copy it on everytime you want to give it to somebody new. I don't think there's any elegant solution to keeping windows machines from messing with it.
 
Old 11-18-2004, 10:12 PM   #6
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
You could take a small screwdriver and flip that write protect tab out completely. That way a user would have to purposely cover the hole ( tape ) in order to write to the disk. If the users aren't too savey, you might get by with that.
 
Old 11-18-2004, 11:32 PM   #7
Chrax
Member
 
Registered: Apr 2004
Distribution: Dapper
Posts: 167

Rep: Reputation: 31
I assumed it was to avoid accidents. But yeah, I forgot to mention that option.
 
Old 11-19-2004, 05:00 AM   #8
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
If this is not about real encryption, but only obfuscating, why not use ROT13?
(Example in for sh here, but should be very similar in ksh.)

Say your script is called "skript.sh":
Code:
#!/bin/sh

echo "Hello"
echo "Hallo"
echo "Gutentag"
echo "Hola"
echo "Aloha"
Then you "encrypt" it with ROT13:
Code:
shell$ cat skript.sh | tr 'a-zA-Z' 'n-za-mN-ZA-M'
This outputs:
Code:
#!/ova/fu

rpub "Uryyb"
rpub "Unyyb"
rpub "Thgragnt"
rpub "Ubyn"
rpub "Nybun"
Then you create an obfucated script called "obfuskript.sh" from the output above like this:
Code:
#!/bin/sh
FIFO=/tmp/qwee_asdd
rm $FIFO >/dev/null 2>/dev/null
mkfifo $FIFO
sh $FIFO &
tr 'a-zA-Z' 'n-za-mN-ZA-M' >$FIFO <<EOF_EOF

#!/ova/fu

rpub "Uryyb"
rpub "Unyyb"
rpub "Thgragnt"
rpub "Ubyn"
rpub "Nybun"

EOF_EOF

Last edited by Hko; 11-19-2004 at 05:02 AM.
 
Old 11-19-2004, 06:03 AM   #9
RitzContent
LQ Newbie
 
Registered: Nov 2004
Posts: 8

Original Poster
Rep: Reputation: 0
The script writes files to the root dir and to the floppy disk both. So making the floppy locked isn't a real option because it has test reports. And people print those reports out on a windows machine.

but I will try shc today and see if that will do.

Thanks for everyone's help so far.

with the ROT13 do you have to "decrpyt" the script before you can use it? And if so can you give a example of the command line for it?
 
Old 11-19-2004, 06:45 AM   #10
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
Quote:
Originally posted by RitzContent
with the ROT13 do you have to "decrpyt" the script before you can use it? And if so can you give a example of the command line for it?
The script I posted (the last code block) is the obfuscated script, and "decrypts" itself. It runs as posted. Just copy-paste it, and run it.

Last edited by Hko; 11-19-2004 at 06:48 AM.
 
Old 11-19-2004, 11:37 AM   #11
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,500

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
I just built shc-3.7 on Solaris, and had to change a couple a lines for it to work:

line 269, commented out the include
"/* #include <sys/ptrace.h> */",
line 290, replaced PTRACE_ATTACH by 0
" mine = !ptrace(0, pid, 0, 0);",

Compiling with gmake and gcc, I got a working shc. The generated binaries built from shell sources looks more difficult to hack that I thought before.
 
Old 11-19-2004, 04:32 PM   #12
RitzContent
LQ Newbie
 
Registered: Nov 2004
Posts: 8

Original Poster
Rep: Reputation: 0
Well I wasn't able to get the shc working ( which from how it sounds is what I am looking for )

I even edited those lines out but to no luck.
 
Old 11-20-2004, 02:59 AM   #13
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,500

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
I can help if you give more details about what fails.

What Solaris version are you using ?
What errors do you got ?
 
Old 11-20-2004, 12:58 PM   #14
RitzContent
LQ Newbie
 
Registered: Nov 2004
Posts: 8

Original Poster
Rep: Reputation: 0
I will try again when I get to work..

I didnt' write down the errors.. I know bad me..

Its solaris 8.

But I did make a little script that uses the tr function to "decrpyt" to a new file. had to do it that way because it wasn't able to use any of the vars I had set.

I'll try again monday and post back.
 
Old 11-22-2004, 10:42 AM   #15
RitzContent
LQ Newbie
 
Registered: Nov 2004
Posts: 8

Original Poster
Rep: Reputation: 0
cc -Wall -O6 -pedantic shc.c -o shc
gmake: cc: Command not found
gmake: *** [shc] Error 127
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
scripting question... Basslord1124 Linux - Networking 2 11-09-2005 05:52 AM
Scripting question mithereal Linux - General 2 09-21-2005 02:02 AM
Scripting question msandford Linux - Newbie 4 09-05-2005 10:23 AM
scripting question gearoid Programming 3 05-26-2004 02:43 PM
Scripting question glock19 Linux - Software 2 09-05-2003 12:45 AM


All times are GMT -5. The time now is 04:00 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration