On Monday 29 September 2003 10:14 am, Wagner, David --- Senior Programmer Analyst --- WGO wrote: > Why re-invent the wheel if some aspect of what you are doing can possibly > help others. I would enjoy seeing what is going on!
Well, since I started this thread, it's only appropriate that I contribute my $0.02 CAD. test-accounts.pl - Loop through a list of email accounts / passwords, check them, and print out which ones work and which ones don't. unify-passwdshadow.pl - Take a /etc/passwd and /etc/shadow file and merge them together to create an un-shadow'd file. classVersion - Shortcut to print out the version number for a given perl class There's more where that came from, if people are interested. -- /* Michael A. Nachbaur <[EMAIL PROTECTED]> * http://nachbaur.com/pgpkey.asc */ "He expanded his chest to make it totally clear that here was the sort of man you only dared to cross if you had a team of Sherpas with you. "
#!/usr/bin/perl
# Name : test-emailpasswords.pl
# Description : Takes a /etc/passwd formatted file with clear-text passwords
# : and attempts to log into a POP3 server to verify if the
# : username/password tuple works. Accepts input as multiple
# : files on the command-line, or from STDIN.
use strict;
use warnings;
use constant POP3LIST => '/home/nachbaur/bin/pop3list';
use constant HOSTNAME => 'mail.shuswap.net';
while (<>) {
chomp;
my ($username, $password) = split /:/;
unless ($username and $password) {
warn "No username or password supplied on line $.\n";
next;
}
open INPIPE, POP3LIST . " -h " . HOSTNAME .
" -u '$username' -p '$password' 2>&1 |"
or die "Can't open the pop3 command: $!\n";
my $succeeded = 1;
while (<INPIPE>) {
if (/failed/i) {
$succeeded = 0;
last;
}
}
close INPIPE;
print join(':', $username, $password, $succeeded), "\n";
}
#!/usr/bin/perl
# Name : unify-passwdshadow.pl
# Description : Take a passwd and shadow file as input, and merge
# : the results together creating a unified passwd
# : file. Assumes you're giving it intelligent data.
use strict;
use warnings;
my ($passwd_file, $shadow_file) = @ARGV;
my %passwd = ();
my %shadow = ();
open INPASSWD, $passwd_file
or die "Can't open the bloody password file\n";
foreach my $passwd_ent (<INPASSWD>) {
chomp $passwd_ent;
my ($username) = split(':', $passwd_ent);
$passwd{$username} = $passwd_ent;
}
close INPASSWD;
open INSHADOW, $shadow_file
or die "Can't open the bloody shadow file\n";
foreach my $shadow_ent (<INSHADOW>) {
chomp $shadow_ent;
my ($username) = split(':', $shadow_ent);
$shadow{$username} = $shadow_ent;
}
close INSHADOW;
foreach my $username (keys %passwd) {
my ($username, undef, $uid, $gid, $gecos, $home, $shell)
= split(':', $passwd{$username});
my (undef, $password) = split(':', $shadow{$username});
print join(':', $username, $password, $uid, $gid, $gecos, $home, $shell), "\n";
}
classVersion
Description: application/shellscript
