http://qs321.pair.com?node_id=217883
Category: Cryptography
Author/Contact Info Limbic~Region
Description: http://www.users.dircon.co.uk/~crypto/ requires to work against a file in the format of /etc/passwd. Unfortunately on HPUX in trusted mode, the encrypted passwords for each user is stored in /tcb/files/auth/<first character of user name>/<user name> This little program goes through and creates a /tmp/passwords file with the encrypted password back in the second field.
#!/usr/bin/perl

open (MERGED , "> /tmp/passwords");
open (PASSWD , "/etc/passwd");
while ( my $line = <PASSWD> ) {
 my @fields = split(":", $line);
 my $fletter = substr($fields[0],0,1); 
 my $trusted_file = "/tcb/files/auth/$fletter/$fields[0]"; 
 if ( -r $trusted_file ) {
  open (TRUSTED , $trusted_file);
  while ( my $entry = <TRUSTED> ) {
   next unless ( $entry =~ /u_pwd/ );
   if ( $entry =~ /u_pwd=(.*):.*$/ ) {
    $fields[1] = $1;
   } 
  }
 }
 close (TRUSTED);
 print MERGED join ':' , @fields;
}
close (PASSWD);
close (MERGED);