I'm working on writing an MD5 hash scanner (searches for files on a system, if it finds a file that matches a filename of a known bad, does and MD5 on it and compares to known bad files MD5), and I've got it working up to the point of identifying the files on a system that match in my list of bad files (I think), but when I try to take the match data and put it into a multi-dimensional array, it seems to not be working.

If you'd like to give it a go up to this point, you need psexec (http://www.microsoft.com/technet/sysinternals/security/psexec.mspx) and also replace the IP address 1.2.3.4 in the script to the IP of the system you are currently on (need admin rights to do the scan). Any advice would be appreciated.
#!C:\perl\bin\perl.ex#!C:\perl\bin\perl.exe use strict; my @fileinfo; my @sysfiles; my $i = 0; my $md5sum; my $filename; my $md5data; my @md5info; my @md5filename; open(FILE, "knownbad.txt") or die("Unable to open file"); my @knownbad = <FILE>; close(FILE); my $k = 0; foreach $md5data (@knownbad) { chop($md5data); ($filename, $md5sum) = split(/\,/, $md5data); $md5info[$k] = [$filename, $md5sum]; $md5filename[$k] = $filename; $k++; } open FILES, "psexec.exe -n 2 \\\\1.2.3.4 cmd.exe \/C dir C\:\\ \/S \/B + |" or die; while ( <FILES> ) { my $dir; my $file; ( $dir, $file ) = m/(.*)[\\\/](.+)/ ? ( $1, $2 ) : ( undef, $_ ); # print "$file is in the directory $dir\n"; $fileinfo[$i] = [$file, $dir]; $sysfiles[$i] = $file; $i++; } close FILES; sleep 5; my $filecount = (scalar (@fileinfo)) - 1; my $hashcount = (scalar (@md5info)) - 1; my $refarray1 = $fileinfo[$filecount]; print "File: $refarray1}[0] --- Directory: ${$refarray1}[1]]\n"; my $refarray2 = $md5info[$hashcount]; my @isect_list; my %isect = (); map { $isect{$_} = 1 } @md5filename; @isect_list = grep { $isect{$_} } @sysfiles; my @uniq = sort keys %{ { map { $_, 1 } @isect_list } }; my @matchedfiles; my $intersect; foreach $intersect (@uniq) { my $c=0; while ($c <= $filecount){ $refarray1 = $fileinfo[$c]; if (${$refarray1}[0] eq $intersect) { print "File: ${$refarray1}[0] in directory ${$refarray1}[1]\n"; push(@{$matchedfiles[$c]}, [${$refarray1}[0], ${$refarray1}[1]]) +; } $c++; } } print "\n\n"; my $refarray3 = $matchedfiles[5]; print "it's not defined!\n" unless defined(${$refarray3}[0]); print "it's not defined!\n" unless defined(${$refarray3}[1]); print "File: ${$refarray3}[0] in directory ${$refarray3}[1]\n";

In reply to Uninitialized value in concatenation (.) or string? by jbush82

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.