#!/usr/bin/perl # # Name: Matthew Reeves # # program to execute a very simple dictionary attack # use warnings; use strict; use feature ":5.10"; use Digest::MD5 qw(md5_hex); #open both files needed open(SHADOW, ") { $_ =~ /(\w*):([0-9a-fA-F]*)/; push (@username, $1); push (@password, $2); } #while not at EOF for dictionary file, read line by line, read each dictionary #password, push onto array @dictionary; tracks # of dictionary passwords while() { $_ =~ /(\w*)/; push (@dictionary, $1); } #nested for loops, for each username, tries each dictionary password hashed #with each possible salt with the perl md5_hex function, prints to screen #username:salt:password if match found foreach my $pass (@password) { foreach my $dict (@dictionary) { foreach my $salt (@byte) { $tmp = md5_hex($salt.$dict); # print $salt.$dict.":$tmp\n"; if ($tmp ~~ $pass) { print "$username[$count]:$salt_check:$dict\n"; } $salt_check++; } #resets salt value for next password to be tried $salt_check = 0; } #increments $count which is used to track decimel value of byte value $count++; }