CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Find and replace MD5 hash from file

 



adroc
New User

Jun 29, 2011, 11:24 AM

Post #1 of 1 (459 views)
Find and replace MD5 hash from file Can't Post

Hello, I am attempting to do a search and replace of MD5 hashes contained in a file but am having issues with the special characters contained within the hash.

For example:

#Just generating random hashes for this example and storing them in variables.

$hash1= `makepasswd --clearfrom=$path/keys/temppw --crypt-md5 --verbose | grep Password=| cut -d"=" -f3`;
chomp($hash1);

$hash2=`makepasswd --clearfrom=$path/keys/temppw2 --crypt-md5 --verbose | grep Password=| cut -d"=" -f3`;
chomp($hash2);

#I need to update the hashes over ssh because I will be doing this on remote machines, so I'm doing the following to test on the local machine for now....

system("ssh -o StrictHostKeyChecking=no root\@localhost /usr/bin/perl -p -i -e s/$hash1/$hash2/ee hashfile") == 0
or @errors=(@errors,"\n$server hash update error: $?\n");


Doing the above generates an error similar to this.

Bareword found where operator expected at -e line 1, near "s/$/7OWwo4h/FWHShP3"
syntax error at -e line 1, near "s/$/7OWwo4h/FWHShP3"
Execution of -e aborted due to compilation errors.


Some example hashes..........

$1$UGXeHYG/$c8iQxpnMsSSCWlEPo0utZTxDjc.qCyTD59PjclG3iKW8p.ZRCySuul8mfl2xffClNH6m/0MqpbIaaHCsI/ziY0

$1$mOdDtc/f$iKpqV8NR7mfM9DrJ7ebS1/

What am I doing wrong here?

Thanks in advance...


(This post was edited by adroc on Jun 29, 2011, 11:57 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives