我正在尝试对 Dlink 的 DI-8002W 固件进行逆向工程,以搜索路由器中的漏洞。我已经恢复了 Linux 映像,但目前我无法恢复文件系统本身。我将介绍我迄今为止所做的一切。
固件可以在这里找到 - http://support.dlink.com.cn/ProductInfo.aspx?m=DI-8002W(第二个选项)
提取uImage
解压下载显示我们DI_8002W-16.07.26A1.trx。从严格的“trx”格式来看,这似乎是无效的,而是在前 76 个字节中有一些特定于 Dlink 的信息,例如VER216.07.26等。我用 DD 将其剥离以从 trx 文件中获取 uBoot 图像。
binwalk DI_8002W-16.07.26A1.trx
DECIMAL HEXADECIMAL DESCRIPTION
--------------------------------------------------------------------------------
76 0x4C uImage header, header size: 64 bytes, header CRC: 0x6850C842, created: 2016-08-03 22:52:13, image size: 5612788 bytes, Data Address: 0x80000000, Entry Point: 0x8000C2F0, data CRC: 0xBE8E9338, OS: Linux, CPU: MIPS, image type: OS Kernel Image, compression type: lzma, image name: "Linux Kernel Image"
140 0x8C LZMA compressed data, properties: 0x5D, dictionary size: 33554432 bytes, uncompressed size: 8550244 bytes
dd if=DI_8002W-16.07.26A1.trx of=clean.trx bs=1 skip=76
uImage
在这一点上,我似乎有一个有效的 uImage 文件,包括一个 linux 内核映像和 lzma 压缩数据。
mkimage -l clean.trx
Image Name: Linux Kernel Image
Created: Thu Aug 4 08:52:13 2016
Image Type: MIPS Linux Kernel Image (lzma compressed)
Data Size: 5612788 Bytes = 5481.24 kB = 5.35 MB
Load Address: 80000000
Entry Point: 8000c2f0
file clean.trx: u-boot legacy uImage, Linux Kernel Image, Linux/MIPS, OS Kernel Image (lzma), 5612788 bytes, Wed Aug 3 22:52:13 2016, Load Address: 0x80000000, Entry Point: 0x8000C2F0, Header CRC: 0x6850C842, Data CRC: 0xBE8E9338
我假设文件/文件系统位于 lzma 数据中,因此我再次将其提取出来,从文件中删除标题。
dd if=clean.trx of=uboot.lzma skip=64 bs=1
LZMA数据
文件确认我们有有效的 LZMA 数据(至少根据魔术字节)。
file uboot.lzma: LZMA compressed data, non-streamed, size 8550244
我用 unlzma uboot.lzma 解压文件,得到以下文件。这与我知道如何提供的诊断信息差不多。
file uboot: data
mkimage -l uboot
Image Type: MVEBU Boot from (null) Image
Image version:0
Data Size: -4 Bytes = 4194304.00 kB = 4096.00 MB
Load Address: 00000000
Entry Point: 00000000
binwalk uboot
DECIMAL HEXADECIMAL DESCRIPTION
--------------------------------------------------------------------------------
3399752 0x33E048 Linux kernel version "2.6.36+ (root@jhl-ubuntu) (gcc version 3.4.2) #2035 Wed Aug 3 18:52:00 EDT 2016"
3587968 0x36BF80 CRC32 polynomial table, little endian
3608048 0x370DF0 Base64 standard index table
3900536 0x3B8478 xz compressed data
3959784 0x3C6BE8 HTML document header
3959845 0x3C6C25 HTML document footer
3962060 0x3C74CC HTML document header
3962252 0x3C758C HTML document footer
3962416 0x3C7630 HTML document header
3962785 0x3C77A1 HTML document footer
3986999 0x3CD637 Neighborly text, "neighbor %.2x%.2x.%pM lostde"
我希望从这一点过渡到发现/分析文件系统以查找漏洞。尝试执行 binwalk 提取(即 binwalk -eM *)会导致重复提取相同文件的递归结果。换句话说,创建了一个包含三个文件的提取文件夹。进入这个文件夹并对这些文件中的任何一个执行 binwalk -eM 将再次提取完全相同的三个文件。
我不知道我们如何从这一点过渡到恢复文件系统。
您可以建议我阅读的任何想法或领域将不胜感激。