Password checking program

Randal Schwartz merlyn at iwarp.intel.com
Thu Aug 3 01:08:49 AEST 1989


In article <60964 at linus.UUCP>, ccel at community-chest (CCEL) writes:
| I'm still getting requests for that silly password checking program
| I talked about last week, and I thought i'd posted the source here
| to the net but people are still asking me for it. My mailer is, well,
| terrible, so rather than sending out 20 copies of it and having half
| of them come back to me, i'll post the source (again?). Sorry to all
| of you who have seen this before ...
| 
| Remember to take my .sig off the end of this guy.
| 
| -------------------------------CUT HERE-----------------------------
| [long c program deleted]

Or, the same thing in Perl (v2.0)...
==================================================snip snip
#/usr/bin/perl
print "Enter username to search for: ";
chop($username = <stdin>);
print "Searching for '$username' ...\n";
open(PASSWD, "</etc/passwd") || die "Cannot open /etc/passwd ($!)";
while (<PASSWD>) {
	($thisuser,$passwd) = split(/:/);
	last if $thisuser eq $username;
}
die "User not found in passwd file." unless $_;
close(PASSWD);
open(DICT,"</usr/dict/words") || die "Cannot open /usr/dict/words ($!)";
$ch = '@';
while (<DICT>) {
	chop;
	printf "Now on the %s's\n", $ch = substr($_,0,1) unless /^$ch/i;
	print "The password is '$_'\n", last if crypt($_,$passwd) eq $passwd;
}
die "Sorry ... password not found in dict.\n" unless $_;
close(DICT);
==================================================snip snip

Just a satisfied Perl hacker...
-- 
/== Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ====\
| on contract to Intel, Hillsboro, Oregon, USA                           |
| merlyn at iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn	         |
\== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/



More information about the Comp.unix.questions mailing list