james289o9 has asked for the wisdom of the Perl Monks concerning the following question:
Hopefully you understand what i am trying to accomplish. Its sort of like a dynamic extractor. It extract data based of the information it finds in the static references.open file binmode file seek to static reference offset (file location) in file read a predefined byte length seek to static reference offset (file size) in file read a predefined byte length use that info (file location) to goto to the actual data. then extract (file size)
open(my $infile, "<", "./file") or die "Cannot open file: $!"; # GET FILESIZE AND LOCATION $buffer1 = ''; $buffer2 = ''; seek $infile, 0x15, 0; read $infile, $location, 0x03; seek ($infile, 0x1D, 0); read ($infile, $filesize, 0x03); $location =~ s/(.)/sprintf("%02x",ord($1))/eg; $filesize =~ s/(.)/sprintf("%02x",ord($1))/eg; # GET FILENAME seek $infile, 0x20, 0; read $infile, $filename, 0x25; $filename =~ s/\0*$//g; print $filename, "\n"; my $directory = "extracted\\"; system "mkdir $directory"; # EXTRACT FILE open($newfile, '>', "extracted//$filename"); sysseek $infile, hex($location), 0; sysread $infile, $new, hex($filesize); syswrite $newfile, $new;
|
|---|