UPDATE: FIXED, and it will extract based off of offsets.
I should add MD5 verification to this. Should be easy enough to do!
i have figured it out. i had to change the until loop to stop at =~ "file25", then change the cursor position in the until loop to "0". Now it works great. :)
Here is the updated code:
use File::Path qw(make_path);
open (my $infile, '<', 'file') or die "cannot open file: $!";
binmode ($infile);
make_path ('./extracted');#or die "Failed to create Direcotry: $!";
my $curpos = '';
my $fileLocation = '';
my $fileSize = '';
my $fileName = '';
my $file ='';
my $chunk = '';
seek ($infile, 0x10, 0);
#GET File Location, File Size, File Name and write to file
until ($curpos =~ 0x04c0){
$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;
$fileLocation =~ s/(.)/sprintf("%02x",ord($1))/eg;
$fileSize =~ s/(.)/sprintf("%02x",ord($1))/eg;
$fileName =~ s/\0+$//;
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 = '';
};
you can download the file and run the script to try it out if you want. its extracting 25 files based off references in TOC and in 45-50 lines of AS perl. :P
You could possibly extract alot more data with this as long as the references are static. this is very very VERY useful LOL
the actual function is ironically 25 lines lol.
But you could extract a huge amount of data with this, just change the offsets to YOUR OWN references in YOUR OWN FILES TOC.
Wow 9 rep point lol, thanks guys/gals for checking this out :)
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.