Issues Masking(Encrypting) a string


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Issues Masking(Encrypting) a string
# 8  
Old 10-10-2016
Hammer & Screwdriver

Quote:
Originally Posted by RudiC
Code:
echo "mypassword" | base64
bXlwYXNzd29yZAo=

How to get the original password from "bXlwYXNzd29yZAo=" ?
# 9  
Old 10-10-2016
Quote:
Originally Posted by mohtashims
How to get the original password from "bXlwYXNzd29yZAo=" ?
By carefully reading the man page of "base64", until, upon chance, stumbling upon the description of the secret "-d" (decode) command line option and subsequently applying this arcane knowledge to your command line.

I hope this helps.

bakunin
These 3 Users Gave Thanks to bakunin For This Post:
# 10  
Old 10-10-2016
What would be the point of storing an encrypted password? Is this so that it can be checked against user input?

A possible better way might be:-
  • Read a password from the user in to a file
  • Use sum or md5sum on the file and compare it to a stored value.
Obviously you would have to store the output from a previous sum or md5sum in your script, but that is less likely to be cracked.


Would that help, OR is everyone going to shoot me down for doing something really daft. I hope it's helpful but I would like to be corrected if necessary.



Kind regards,
Robin
# 11  
Old 10-10-2016
Quote:
Originally Posted by rbatte1
A possible better way might be:-
  • Read a password from the user in to a file
  • Use sum or md5sum on the file and compare it to a stored value.
Obviously you would have to store the output from a previous sum or md5sum in your script, but that is less likely to be cracked
First off: this is perhaps the most ingenious way of being most secure in employing insecure methods in general. Sorry for this rather double-edged compliment, but you have to be aware that there are secure methods and there are other (not secure) methods. If you decide against secure methods you will always be able to move farther up the security scale, but only to some extent - principally insecure will always remain principally insecure, regardless of what you do.

Your method suffers from the fact that scripts are readable. I can extract the necessary md5sum from it, create a fitting PW offline (using all sorts of methods: dictionary attacks, ...) and then feed that PW into the script.

Still, your method is better than many others i have seen suggested in similar threads here and elsewhere.

I hope this helps.

bakunin
# 12  
Old 10-10-2016
Quote:
Originally Posted by rbatte1
What would be the point of storing an encrypted password? Is this so that it can be checked against user input?

A possible better way might be:-
  • Read a password from the user in to a file
  • Use sum or md5sum on the file and compare it to a stored value.
Obviously you would have to store the output from a previous sum or md5sum in your script, but that is less likely to be cracked.


Would that help, OR is everyone going to shoot me down for doing something really daft. I hope it's helpful but I would like to be corrected if necessary.



Kind regards,
Robin
Note that a user's encrypted login password is created using crypt() exactly as you suggested and the system used to store the encrypted string in plain text in /etc/passwd (which is readable by everyone so tools like ls can decode the user-IDs and group-IDs returned by stat() into user and group names in long listings). Many, many moons ago, the actual encrypted passwords were moved into /etc/shadow which is readable only by root to avoid the problem bakunin mentioned in post #11.
# 13  
Old 10-11-2016
I quite agree that this is not a great solution, but hopefully it's better than some. I would always prefer to use the tool designed for the job, (e.g. SSH keys) but as we still don't know the real purpose I'm not sure what the best tool is.

Are we discussing it here too:- https://www.unix.com/shell-programmin...#post302983344

It seems rather similar to me.


Robin
# 14  
Old 10-11-2016
Quote:
Originally Posted by RudiC
Code:
echo "mypassword" | base64
bXlwYXNzd29yZAo=

A little late into this thread but wouldn't the '=' be a bit of a give away?
Just a thought...

I know it is a padding character...

EDIT:
Also there would be a newline added using echo...
echo -n "mypassword" | base64
gives...
bXlwYXNzd29yZA==

Last edited by wisecracker; 10-11-2016 at 01:16 PM.. Reason: See above.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. High Performance Computing

Encrypting interconnect

Hi, i've got a qusetion regarding interconnect of compute nodes. In our company we are running a Simulation Cluster which is administrated by the Simulation department. Now our central IT requires to encrypt the interconnect of the compute nodes. Does anybody in that business encrypt... (3 Replies)
Discussion started by: fiberkill
3 Replies

2. Shell Programming and Scripting

Encrypting password

Hello All, I need to accept a password from the user and validate it, without having to hard-code it anywhere. Any ideas? (3 Replies)
Discussion started by: optimus_1
3 Replies

3. Shell Programming and Scripting

Encrypting the password

Iam using the teradata... and running the scripts in unix, I wan to encrypt the teradata password in Unix... my hostname is : bprod usename: KRN777 passwrd: passwrd can ant one tell me the exact command to encrypth the passwrd.... thanks, (5 Replies)
Discussion started by: nani1984
5 Replies

4. Shell Programming and Scripting

String Comparison Issues

Hello there. I am trying to write a simple script that pulls the date on which the system was last shutdown (stored in a file called 'last_shutdown') and today's date (the days only) and compares the two. If the two match, I want it to perform some tasks. That is, if today is 31 May 2010 and the... (2 Replies)
Discussion started by: ksk
2 Replies

5. Shell Programming and Scripting

Shell script for encrypting a string

Hi, I am new to Unix server and shell scripting.I want to encrypt username/password using shell script.I know that there's a Crypt command to encrypt but it is not installed in my unix server and cannot be installed due to some reason.So i want the shell script of the crypt command or is there... (3 Replies)
Discussion started by: Princessp
3 Replies

6. Shell Programming and Scripting

Issues with string replacement

I posted this issue a week or so ago and I still cant get the script to work. Here is what I have so far and what Im trying to do. #!/bin/ksh old="$1" new="$2" file=$3 grep $1 $3 > /dev/null if ;then cp $3 ${3}.bak sed "s/$1/$2/g" $3 > ${3}~ mv ${3}~ ${3} fithe script is... (5 Replies)
Discussion started by: gordonheimer
5 Replies

7. Shell Programming and Scripting

Masking Content of a String

Hello, I need to know that whether a content of a string can be hidden or masked inside a shell script. My Sample Code is given below <Code> #!/usr/bin/ksh Userid=test DB=temp Passwd=`java Decryption test` # The Above command will get the encryped password for "test" user id and store... (2 Replies)
Discussion started by: maxmave
2 Replies

8. Solaris

Encrypting a script......

Hiiiiii..... every one..... I have written a script, and i want to make that script confidential.So that, only i can see that script. I am using " crypt " command in solaris 9, to encrypt that script.But when i am executing this... (6 Replies)
Discussion started by: prashantshukla
6 Replies

9. UNIX for Dummies Questions & Answers

masking or encrypting in shell script

Hi folks, I am writing a script which asks the user to enter a user name and password to telnet and logon to some other machine. The script promts the user to enter the login name and password as below. echo "Enter the login name to be used to login on the machine" read login echo "Enter the... (4 Replies)
Discussion started by: dshrish
4 Replies

10. AIX

Encrypting password

I have a strange question for someone regarding the AIX 5.2 environment. Here is the scenerio: I have a script that is running a menu full of options. 1. I like food 2. I don't like food Enter Option:_ Enter userID:_ Enter Password:_ (The menu is conversational only so go with me on... (6 Replies)
Discussion started by: Justman
6 Replies
Login or Register to Ask a Question