Here you go, its a working script that gets md5 and puts it in a file in "C:\md5.txt"



use Digest::MD5; use File::Path qw(make_path); open (my $infile, '<', 'file') or die "cannot open file: $!"; binmode ($infile); make_path ('./extracted'); my $curpos = ''; my $fileLocation = ''; my $fileSize = ''; my $fileName = ''; my $file =''; my $chunk = ''; my $exit = ''; #GET File Location, File Size, File Name and write to file seek ($infile, 0x10, 0); until ($exit){ $curpos = tell $infile; seek ($infile, $curpos, 0); read ($infile, $fileLocation, 0x08); $curpos = tell $infile; seek ($infile, $curpos, 0); read ($infile, $fileSize, 0x08); $curpos = tell $infile; seek ($infile, $curpos, 0); read ($infile, $fileName, 0x20); $curpos = tell $infile; if ($fileLocation =~ 'unformatted characters'){ last; } $fileLocation =~ s/(.)/sprintf("%02x",ord($1))/eg; $fileSize =~ s/(.)/sprintf("%02x",ord($1))/eg; $fileName =~ s/\0+$//; if ($fileLocation =~ 'formatted characters'){ last; } #THIS PART ACTUALLY EXTRACTS THE DATA BASED OFF OF OFFSETS open($file, '>', "extracted/$fileName") or die "Cannot open $fileName +$!"; binmode($file); sysseek ($infile, hex($fileLocation), 0); sysread ($infile, $chunk, hex($fileSize)); syswrite ($file, $chunk); $fileLocation = ''; $fileSize = ''; }; #GET MD5 my $dirname = "extracted"; foreach my $file (<$dirname/*>) { next if -d $file; open( my $FILE, $file ); binmode($FILE); open (my $md5, "+>>", "C:/md5") or die "cant open md5.txt: $!"; binmode($md5); $file =~ s{.*/}{}; syswrite $md5, Digest::MD5->new->addfile($FILE)->hexdigest; syswrite $md5, " $file\n"; };


seeing how $fileLocation is the first check, you can also exit with that if you have many many files to extract. but this will extract those files and it will also get the md5 of them in a split sec lol
yall have a good one :)
Any Questions?

In reply to Re^2: problem with sysseek in loop by james28909
in thread problem with sysseek in loop by james28909

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.