如何从 .img 文件中提取 N150R 固件

逆向工程 固件
2021-07-01 07:30:57

我正在尝试为我的无线路由器固件安装一个 img 文件,但我似乎无法成功。

当我玩弄那个 .img 上的文件命令时,它返回以下内容:

$ file file.img 
file.img: data

当我尝试在其上使用 mount 时,我得到以下信息:

$ sudo mount file.img test/
mount: you must specify the filesystem type

当我尝试告诉使用“-t auto”时,我得到相同的输出:

$ sudo mount -t auto file.img test
mount: you must specify the filesystem type

xxd 返回以下内容:

$ xxd -a N150R-V1.0.0.5_1.0.1.img | head
0000000: 6465 7669 6365 3a4e 3135 3052 0a76 6572  device:N150R.ver
0000010: 7369 6f6e 3a56 312e 302e 302e 355f 312e  sion:V1.0.0.5_1.
0000020: 302e 310a 7265 6769 6f6e 3a0a 0000 0000  0.1.region:.....
0000030: 0000 0000 0000 0000 0000 0000 0000 0000  ................
*
0000070: 0000 0000 0000 0000 0000 0000 0000 1232  ...............2
0000080: 3036 3132 d9cf 3fc1 5297 2c87 0033 eed0  0612..?.R.,..3..
0000090: 9f05 0000 9f05 0000 9b63 9e62 0505 0700  .........c.b....
00000a0: 4e31 3530 522d 5631 2e30 2e30 2e35 5f31  N150R-V1.0.0.5_1
00000b0: 2e30 2e31 0000 0000 0000 0000 0000 0000  .0.1............

binwalk 给出了以下内容:

$ binwalk N150R-V1.0.0.5_1.0.1.img 

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
192           0xC0            Squashfs filesystem, big endian, version 3.0, size: 3403472 bytes, 1024 inodes, blocksize: 65536 bytes, created: 2013-11-28 11:44:07

fdisk(在 OS X 上)返回:

$ fdisk N150R-V1.0.0.5_1.0.1.img 
Disk: N150R-V1.0.0.5_1.0.1.img  geometry: 26/4/63 [6656 sectors]
Signature: 0x95EB
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: 02  648  41  48 -  107 220  28 [ 275573942 - 2530152094] XENIX /     
 2: C9  165 158   8 -  311  15  40 [1825336399 - 3160300718] <Unknown ID>
 3: 12  606 153  51 -  988 164  42 [3547124620 - 4171149652] Compaq Diag.
 4: BD  479 182  60 -  173 155  40 [2642289636 - 1573814809] <Unknown ID>

我能得到一些关于如何从 img 中提取文件的指导吗?我可以访问 OS X 和 Ubuntu。

固件链接

编辑 1:大脚野人的结果:

$ sasquatch N150R-V1.0.0.5_1.0.1.img 
SquashFS version [24373.11825] / inode count [1312449891] suggests a SquashFS image of a different endianess
Non-standard SquashFS Magic: devi
Reading a different endian SQUASHFS filesystem on N150R-V1.0.0.5_1.0.1.img
Filesystem on N150R-V1.0.0.5_1.0.1.img is (13663:12590), which is a later filesystem version than I support!
2个回答

SquashFS 镜像是 3.0 版,带有 LZMA 压缩;LZMA 压缩直到 4.0 版本才正式添加到 SquashFS,因此标准 SquashFS 工具将无法识别它。

然而,大脚野人提取它对我来说很好。事实上,如果你安装了 sasquatch,最新版本的 binwalk 将使用它来自动提取文件系统,如果你使用该-e选项运行 binwalk

更新:

您需要提供sasquatchSquashFS 映像,而不是原始固件映像。首先,使用以下命令提取它,dd然后sasquash针对提取的文件运行

$ dd if=N150R-V1.0.0.5_1.0.1.img bs=192 skip=1 of=fs.squashfs
$ sasquatch fs.squashfs

最新版本binwalk-e选项会自动为您执行此操作

$ binwalk -e N150R-V1.0.0.5_1.0.1.img

您可以强制老版本binwalk来使用sasquatch,以及:

$ binwalk --dd='squashfs:squashfs:sasquatch %e' N150R-V1.0.0.5_1.0.1.img

如果你不想安装另一个工具,如果你去掉头部(binwalk 谈到的前 192 字节),它可能会挂载:

dd if=file.img of=file.squashfs bs=192 skip=1
sudo mount file.squashfs test/

编辑:

由于路由器似乎具有大端 Mips 处理器,因此安装对我来说也不起作用。但是,以下内容适用于 Ubuntu 14.04:

apt-get install liblzo2-dev 
git clone https://github.com/devttyS0/sasquatch
make
sasquatch /path/to/file.squashfs

(显然,您还需要git, make,gcc安装。这liblzo2-dev是我之前没有安装的唯一依赖项。我必须使用dd如上所示准备的文件,而不是原始的 .img)。

如果你不能让它工作,这里是提取的文件:

https://mega.co.nz/#!xFoQkZRB!lcdUdDVGKsgEeu8Q5HnL3BSBXJKCHe0jZkGwOyTSxlQ