-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript_unpack.php
More file actions
46 lines (30 loc) · 955 Bytes
/
Copy pathscript_unpack.php
File metadata and controls
46 lines (30 loc) · 955 Bytes
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
<?php
$fd = fopen('/data/SCRIPT.PAK', 'rb');
list($junk, $file_count) = unpack('N*', fread($fd, 4));
echo $file_count;
$offset = array();
$filesize = array();
$filename = array();
for($i=0; $i< $file_count; $i++) {
list($junk, $offset[$i]) = unpack('N*', fread($fd, 4));
list($junk, $filesize[$i]) = unpack('N*', fread($fd, 4));
$filename[$i] = 'package/' . rtrim(fread($fd, 16));
}
for($i=0; $i< $file_count; $i++) {
$offset[$i] = 0x800 * $offset[$i];
}
for($i=0; $i< $file_count; $i++) {
if ($i < $file_count -1) {
$filesize[$i] = $offset[$i+1] - $offset[$i];
}
echo "hex index : " . dechex($offset[$i]). ", " . $offset[$i] . ", file size : " . $filesize[$i] . "\n";
}
for($i=0; $i<$file_count; $i++) {
$fo = fopen($filename[$i], 'w');
fseek($fd, $offset[$i], SEEK_SET);
//echo "offset : " . $offset[$i] . " , SEEK : " . $seekvalue . "\n";
fputs($fo, fread($fd, $filesize[$i]));
fclose($fo);
}
fclose($fd);
?>