-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdumphfs.pl
executable file
·49 lines (43 loc) · 1.08 KB
/
dumphfs.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin";
use Getopt::Long;
use IO::File;
use Harddisk;
use HFSVolume;
use Hexdump;
use Getopt::Long;
my $diskname="/dev/rdisk0s2";
my $offset=0;
my $volhdrname;
my $savehfsfules;
GetOptions(
"disk=s"=>\$diskname,
"o=s"=>sub { $offset=eval($_[1]); },
"volhdr=s"=>\$volhdrname,
"savehfs"=>\$savehfsfules,
);
my $hd= Harddisk->new($diskname);
my %params;
$params{volhdr}= read_file($volhdrname, binmode=>':raw') if $volhdrname;
$params{startsector}= $offset/0x200;
my $vol= HFSVolume->new($hd, %params);
if ($savehfsfules) {
$vol->{volhdr}{allocationFile}->save("alloc.bitmap");
$vol->{volhdr}{extentsFile}->save("ext.btree");
$vol->{volhdr}{catalogFile}->save("cat.btree");
}
my $bitmap= $vol->calc_alloc_bitmap();
#my $allocbm= Bitmap->new();
#$allocbm->readfromhandle($vol->{volhdr}{allocationFile});
#$bitmap->add($allocbm);
$vol->dump();
if (@ARGV) {
$bitmap->save(shift);
}
else {
printf("\nreferenced blocks:\n");
$bitmap->dump();
printf("\n");
}