Hide code in shell script???


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Hide code in shell script???
# 1  
Old 07-30-2003
Question Hide code in shell script???

Hello,

I am very new to Unix so I want to apologize in advance in case my question is stupid.

I wrote a KORN script that I am planning to distribute to many users. This script contains sensitive information that the users should not see: user name and password to our database servers with payroll info.

Is there a way to hide ("obfuscate"?) parts (usernames/passwords..) or the entire script from the end users while still allowing them to execute it?

I am thinking that the right CHMOD command would do the trick i.e. something like "chmod ??? myscript.ksh...". I already did a "chmod 777 myscript.ksh" so I can run/test this script in my shell account but maybe I need to do something else? Do you guys agree? Is there a better option?

Thanks in advance for helping me.

Al.
# 2  
Old 07-31-2003
Chmod 777 means everyone can read, edit and execute the file. If you want to prevent others from reading the file, you can use something else with the chmod command, like "chmod 711 file" which will make the file executable for everyone, but only able to be read or edited by you, the owner.
# 3  
Old 07-31-2003
711 will not work for scripts. The shell can't execute commands that it can't read.

Putting a password in script is a very severe security problem. The only real solution is: don't do that.
# 4  
Old 07-31-2003
Quote:
Originally posted by Perderabo
711 will not work for scripts. The shell can't execute commands that it can't read.
Not sure what you mean by this. I used 711 on my script and ran it using 3 different logins: it executed successfully all 3 times.

Nevertheless, I agree with you that putting passwords in a script is asking for trouble.

Time constraints and little knowledge of shell scripting (I am teaching myself) leave me with no other option for the time being.

Al.
# 5  
Old 07-31-2003
I just tried it on HP-UX 11.0, i get:
Code:
./xyz: ./xyz: cannot open

And on SunOS 5.6:
Code:
/usr/bin/ksh: ./xyz: cannot open

seems like a problem to me. What OS are you using?

Last edited by Yogesh Sawant; 08-11-2010 at 01:48 AM.. Reason: added code tags
# 6  
Old 07-31-2003
Quote:
Originally posted by Perderabo
I just tried it on HP-UX 11.0, i get:
./xyz: ./xyz: cannot open

And on SunOS 5.6:
/usr/bin/ksh: ./xyz: cannot open

seems like a problem to me. What OS are you using?
'uname -r' gives me (HP-UX) "B.11.0"...just like you??

For all my tests, I
-"physically" logged in as user A, ran the script, logged off
-"physically" logged in as user B, ran the script, logged off
-...

Not sure if makes a difference....?
# 7  
Old 07-31-2003
This is very odd. Yes, my uname -r is B.11.00.

What is the first line of your script? I have:
Code:
#! /usr/bin/ksh

Could you post the results of a
ls -ln script
or whatever you called your script. And a
Code:
id -u

The numeric uids control access. If your current uid as displayed by "id -u" is not zero or equal to numeric uid that owns the script you should not be able to run it.

Unless the interpreter itself is suid to either root or the owner of the script. My ksh is 555.

Last edited by Yogesh Sawant; 08-11-2010 at 01:49 AM.. Reason: added code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to hide password in shell script?

I am writing a shell script for sql loader (just copy part of the code) : For security reason, I have to put the below loginName and password into another separate file instead of in the same file of this script. Anyone can give me a hand. Thanks. Shell Script :... (12 Replies)
Discussion started by: Jaewong
12 Replies

2. Programming

How to hide from UNIX strings - obfuscate or hide a literal or constant?

Hi, I need to somehow pipe the password to a command and run some SQL, for example, something like echo $password | sqlplus -s system @query01.sql To make it not so obvious, I decided to try out writing a small C program that basically just do echo $password. So now I just do x9.out | sqlplus... (8 Replies)
Discussion started by: newbie_01
8 Replies

3. Shell Programming and Scripting

Hide bash code which is inside C plus plus program

I am embedding bash in cpp. Can the bash code be hidden (when we cat the executable to not be able to see the bash code) The simple code I am using: #include <iostream> #include <cstdlib> using namespace std; #define test1 "\ #!/bin/sh --posix \n\ echo... (1 Reply)
Discussion started by: frad
1 Replies

4. Shell Programming and Scripting

Help to hide shell terminal and run prompt program after ssh login for specified user

Hey guys, I have some task from my office to lock user on the specified directory after the user logged on using ssh. And then run prompt program to fill the required information. Yeah, just like an ATM system. My question: How could I do those?? AFAIK I have to edit the ~./bashrc. But the... (1 Reply)
Discussion started by: franzramadhan
1 Replies

5. Shell Programming and Scripting

Hide my shell commands

I am writing a tool that connects using SSH to a remote server and perform some actions (through root) However - I would like to hide my operations so they will be hard to track. I tried STRACE on the SSHD process and saw all the traffic going there so I am quite transparent to STRACE ... (1 Reply)
Discussion started by: yamsin789
1 Replies

6. Shell Programming and Scripting

How Do I Hide the Password in a Script

Hi, I am writing a UNIX .ksh script and need to send the login password of the login id that is executing the script to a command that I am executing in the script. I don't want that password to be seen by anyone except whoever is executing the script. Does anyone know how I can accomplish... (6 Replies)
Discussion started by: samd
6 Replies

7. Shell Programming and Scripting

Hide a script ?

Hi all, i have a perl script for my users to run. My sys admin created an account for the users to log in and execute the script. They just type "perl myscript.pl" at the unix prompt to run it. Is there any way that i can hide my script? ,ie, do not allow my users to view the script. either... (5 Replies)
Discussion started by: new2ss
5 Replies

8. Shell Programming and Scripting

How to hide user inputted text for interactive unix shell script?

Hi everybody, Do you know how to hide the text for interactive unix shell script? Just like the case for inputting password during logon. Patrick (1 Reply)
Discussion started by: patrickpang
1 Replies
Login or Register to Ask a Question