#!perl -w # decrypt_users_and_groups2.plx - decrypt Users & Groups passwords # by Chris Nandor, pudge@pobox.com, http://pudge.net/ # Wednesday, July 14, 1999 - Friday, July 16, 1999 # usage: decrypt [file] [user1 user2 ...] # file will be looked for if not provided and using MacPerl # program will prompt for users if not provided use POSIX qw(O_RDONLY isprint); use strict; my($file, @users, $text, @k); # get file if not supplied unless ($file = shift) { eval {require 'Mac/Files.pm'}; die $@ if $@; Mac::Files->import; $file = FindFolder(&kOnSystemDisk, &kPreferencesFolderType) . ':Users & Groups Data File'; } unless (@users = @ARGV) { print "Type a list of users. Hit ctrl-D to finish.\n"; chomp(@users = ); } @k = map ord, qw(s p c g t p r k); sysopen F, $file, O_RDONLY or die "Can't open `$file': $!"; binmode F; read F, $text, -s $file; for my $u (sort @users) { my $found; my $nu = $u; $nu .= "\000" unless length($nu) % 2; MAIN: while ($text =~ /\Q$nu\E(.{8})(.{4})/gs) { my $i = vec($2, 0, 32); my(@b, $p) = unpack 'C*', $1; next if $b[0] == 0; for my $n (0 .. $#b) { my $b = $b[$n] ^ ($n == 0 ? $i ^ 1 : $b[$n-1]) ^ $k[$n]; my $c = chr $b; next MAIN if $b != 0 &&! isprint $c; $p .= $c; } $p =~ s/\000+$//; printf "%-31.31s (%4d): $p\n", $u, $i, $p; $found++; } printf "%-31.31s ( ): no password found\n", $u unless $found; } __END__