查找文件结尾

逆向工程 二元分析 文件格式
2021-06-16 08:16:37

我有一个包含其他文件的文件。我知道子文件从哪里开始 ( header) 但我怎么知道子文件在哪里结束?

编辑:文件类似于:声音文件(.wav)图像(.bmp、png、jpeg)

例子:

file1
file2
data
file3

我怎么知道从哪里file2开始和file2结束?

3个回答

从技术上讲,您所描述的是档案。如果归档数据结构设计得当,则必须在标题中找到标题中每个文件条目的起始偏移量和大小或起始和结束偏移量,除非文件都一个接一个地存储。在后一种情况下,您只需要知道每个文件的起始偏移量,因为(假设 file0 首先出现,然后是 file1)file1 的起始偏移量是 file0 的结束偏移量。

下面的例子显示了后一种情况:

  Offset00:file0
  Offset10:file1
  Offset30:file2
  Offset35:file3

除了 yaspr 所说的,我建议您查找这些包含文件的规范。大多数文件格式的大小都在标题中的某处指定。这将允许您从存档中提取文件,甚至不知道存档结构。

这就是scalpel雕刻文件之工具它们将标头与已知文件类型匹配,然后在该标头中查找文件大小。某些文件格式具有特定的结尾,您也可以使用它们来分割它们(例如,每个png文件都有IEND结尾)。

试试你的运气scalpel和类似的文件雕刻工具。

查看hachoir-subfile来自他们的回购示例。

$ hachoir-subfile chiens.PPS
[+] Start search (828.5 KB)

[+] Found file at 0: Microsoft Office document
[+] Found file at 537 size=28449 (27.8 KB): JPEG picture: 433x300 pixels
[+] Found file at 29011 size=34761 (33.9 KB): JPEG picture: 433x300 pixels
[+] Found file at 63797 size=40326 (39.4 KB): JPEG picture: 433x300 pixels
[+] Found file at 104148 size=30641 (29.9 KB): JPEG picture: 433x300 pixels
[+] Found file at 134814 size=22782 (22.2 KB): JPEG picture: 384x325 pixels
[+] Found file at 157621 size=24744 (24.2 KB): JPEG picture: 443x313 pixels
[+] Found file at 182390 size=27241 (26.6 KB): JPEG picture: 443x290 pixels
[+] Found file at 209656 size=27407 (26.8 KB): JPEG picture: 443x336 pixels
[+] Found file at 237088 size=30088 (29.4 KB): JPEG picture: 388x336 pixels
[+] Found file at 267201 size=30239 (29.5 KB): JPEG picture: 366x336 pixels
[+] Found file at 297465 size=81634 (79.7 KB): JPEG picture: 630x472 pixels
[+] Found file at 379124 size=36142 (35.3 KB): JPEG picture: 599x432 pixels
[+] Found file at 415291 size=28801 (28.1 KB): JPEG picture: 443x303 pixels
[+] Found file at 444117 size=28283 (27.6 KB): JPEG picture: 433x300 pixels
[+] Found file at 472425 size=95913 (93.7 KB): PNG picture: 433x431x8
[+] Found file at 568363 size=219252 (214.1 KB): PNG picture: 532x390x8
[+] Found file at 811308 size=20644 (20.2 KB): Microsoft Windows Metafile (WMF) picture

如果您需要分割文件,可以使用ExtractSubFile