#!/usr/local/bin/perl # report v1.0 (c) 23.9.2002 by Andreas Ley (u) 23.9.2002 # Report cracked accounts $to="andy\@rz.uni-karlsruhe.de bit8000\@rz.uni-karlsruhe.de"; $from="Andreas Ley "; $passwd="/etc/passwd.rztrans"; $crack="/usr/local/Crack"; use Getopt::Std; sub usage { my $image = $0; $image =~ s!.*/!!; print STDERR "Usage: $image [-h]\n"; exit(1); } getopts('Dhx'); &usage if ($opt_h || $#ARGV >= 0); chdir($crack) || die "Can't cd to $crack: $!\n"; open (PASSWD,$passwd) || die "Can't open $passwd: $!\n"; while () { if (/^([^:]+):([^:\*]+):\d+:(\d+):/ && length($2) == 13) { $pw{$1} = $2; $stud{$1} = 1 if ($3 >= 59900 && $3 <= 59999); } } close(PASSWD); open (REPORTER,"./Reporter -quiet |") || die "Can't run Reporter: $!\n"; while () { chomp; if (/^Guessed (\S+) \[([^\]]+)\] / && defined($pw{$1})) { $account = $1; $password = $2; if (crypt($password,$pw{$account}) eq $pw{$account}) { if ($stud{$account}) { push (@stud,$account); } else { push (@cracked,$account); } } else { push (@changed,$account); } } } close(REPORTER); sub break { my ($text); for (@_) { $text .= "$text $_" =~ /.{72,}/ ? "\n" : " " if (length($text)); $text .= $_; } return($text); } if ($#cracked >= 0 || $#stud >= 0) { open (MAIL,"| exec /usr/lib/sendmail -i ${to}") || die "Can't run /usr/lib/sendmail -i ${to}: $!\n"; print MAIL "From: $from\n"; print MAIL "Subject: Gecrackte Accounts\n"; if ($#cracked >= 0) { print MAIL "\nFolgende Instituts-Accounts haben ein crackbares Passwort und sollten\nvom BIT8000 (nach Information der IT-Beauftragten) gesperrt werden:\n"; print MAIL "\n",&break(sort @cracked),"\n"; } if ($#stud >= 0) { print MAIL "\nFolgende Studierenden-Accounts haben ein crackbares Passwort und\nsollten umgehend per Batch (-> Helmut Kempermann) gesperrt werden:\n"; print MAIL "\n",&break(sort @stud),"\n"; } if ($#changed >= 0) { print MAIL "\nNur zur Information/Belustigung: Diese Accounts haben inzwischen ein\nneues (sicheres? :) Passwort:\n"; print MAIL "\n",&break(sort @changed),"\n"; close(MAIL); } }