APM: question on variable scope
Mike South
msouth at gmail.com
Tue Apr 15 13:53:18 PDT 2008
[Seth, sorry for the repeat, meant to replyall in the first place]
On Tue, Apr 15, 2008 at 4:36 PM, Seth Miller <seth at animejunkie.org> wrote:
> Hello all,
>
> I've having some trouble with a script. I'm trying to grab a complete
> list of email accounts on the server and check the password against a
> word list to find weak passwords. The hash %data has the email
> address in the key and the account password in the value.
>
> The word list file currently just has the word 'password' for testing
> but it doesn't seem to be working. Here's the portion of the script
> that's not working
>
> #BEGIN
>
> open (WORDLIST, "<$wordlist") or die "Can't open the wordlist: $!";
>
> while (my $pass = <WORDLIST>) {
You might need a "chomp $pass;" right here.
My reasoning is that your match is being done against "password[NEWLINE]",
which is what you got from the <> on WORDLIST.
(I didn't test though.)
mike
>
> while ( my ($user,$password) = each (%data) ) {
> print "$user - $password\n" if ($password =~ /$pass/);
> }
> }
>
> close WORDLIST;
>
> #END
>
> The while loop that iterates through the word list is working because
> if write a die to spit out the value of $pass, it prints the word
> password as expected. If I change the if statement to if ($value =~
> /password/) it works too.
>
> Also if I set the value of $pass manually just before the print line,
> it works. The script just doesn't work as it looks above. No errors
> or warnings, just no output. I'm assuming it has something to do with
> the scope of the $pass variable.
>
> Any ideas?
>
> --seth
> _______________________________________________
> Austin mailing list
> Austin at pm.org
> http://mail.pm.org/mailman/listinfo/austin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/austin/attachments/20080415/20dfad0d/attachment.html
More information about the Austin
mailing list