#!C:\perl\bin\perl.exe -w use strict; my @known_bad; #each element is a line within the knownbad.txt file open(FILE, "knownbad.txt") or die("Unable to open file"); @known_bad = ; close(FILE); my $bad_data; my $bad_file; my $bad_md5; my $bad_file_array_element; my %bad_file_md5; foreach $bad_data (@known_bad) { #take data from knownbad.txt file and parse it into a hash chomp($bad_data); ($bad_file, $bad_md5) = split(/\,/, $bad_data); push(@{ $bad_file_md5{"$bad_file"} }, "$bad_md5"); } my $system_file_location; my $system_file; my %system_file_data; #open FILES, "psexec.exe -n 2 \\\\192.168.1.10 cmd.exe \/C dir C\:\\ \/S \/B |" or die; open FILES, "cmd.exe \/C dir C\:\\ \/S \/B |" or die; #take data from directory listing and parse it into a hash while ( ) { ( $system_file_location, $system_file ) = m/(.*)[\\\/](.+)/ ? ( $1, $2 ) : ( undef, $_ ); # print "$system_file is in the directory $system_file_location\n"; push(@{ $system_file_data{"$system_file"} }, "$system_file_location"); } close FILES; #### $VAR1 = { 'arbies.dll' => [ '388B8FBC36A8558587AFC90FB23A3B99' ], 'psexec.exe' => [ '78A2C9D79C21DDFCB7CED32F5EBEC618', '388B8FBC36A8558587AFC90FB23A3B99' ], 'notepad.exe' => [ '388B8FBC36A8558587AFC90FB23A3B99' ], 'angelfood.txt' => [ '388B8FBC36A8558587AFC90FB23A3B99' ] };