#! /usr/bin/perl # parser skeleton for john's --show=types options use strict; use warnings; while (<>) { chomp; # print "input: $_\n"; s/.(.)(.)$// || die "bad john's output on line $.\n"; my $line_consistency = $1; my $sep = $2; if ($line_consistency == 2) { print "line skipped, NIS stuff: $_\n"; } elsif ($line_consistency == 3) { print "line skipped, invalid salt for descrypt or empty: $_\n"; } elsif ($line_consistency == 1) { print "line is inconsistent, separator occurred in field: $_\n"; } elsif ($line_consistency ne "0") { print "unknown line consistency code: $line_consistency in line: $_\n" } else { # The main case my ($login, $ciphertext, $uid, $gid, $gecos, $home, $shell, $formats) = split /\Q$sep\E/, $_, 8; if (!defined $formats) { print "no valid formats for line: $.\n"; } else { for (split /\Q$sep$sep\E/, $formats) { # print "valid format: $_\n"; my ($label, $disabled, $is_dynamic, $as_orig, @parts) = split /\Q$sep\E/; if ($as_orig) { print "valid format $label (disabled $disabled, dynamic $is_dynamic)\n"; print "orig: $ciphertext\n"; my $number_of_parts = @parts; print "$number_of_parts parts:\n"; for (@parts) { print " $_\n"; } } else { # We need to get the line by number from the original file. # TODO: die here. print "this parser does not support not orig hash, see line $. of input file (format $label)\n"; } } } } }