TP-LINK路由器固件结构分析(ver. 2.0版本)
之前我们讲述了ver. 1.0版本的固件结构,本文分析一下ver. 2.0版本的固件。ver. 2.0版本的固件,binwalk无法识别出固件头,所以得具体分析,可以参考 mktplinkfw3 。
这里分析的型号为TL-W8980,硬件版本v1,固件版本1_0.6.0_1.7,发布时间140619。首先我们用16进制工具查看固件头部0x200字节数据:

根据mktplinkfw3的文档说明,解析之后结果为:
序号 | 偏移 | 说明 |
1 | 0x00-0x03 | 固件头版本,值为0x03000000 |
2 | 0x04-0x33 | 固件版本类型,字符串为ver. 2.0 |
3 | 0x34-0x37 | 产品ID,值为0x89800001,解析型号为8980,硬件版本v1 |
4 | 0x38-0x3B | 产品版本,值为0x0000000E |
5 | 0x3C-0x3F | 填充数据,值为0x00000000 |
6 | 0x40-0x4F | 固件校验值,值为144F033A1F5365C25109847D96076CD1 |
7 | 0x50-0x53 | 填充数据,值为0x00000000 |
8 | 0x54-0x63 | 内核校验值 |
9 | 0x64-0x67 | 填充数据,值为0xFFFFFFFF |
10 | 0x68-0x6B | 内核加载地址,值为0x80002000 |
11 | 0x6C-0x6F | 内核入口点,值为0x800061B0 |
12 | 0x70-0x73 | 固件总长度,值为0x7C0200 |
13 | 0x74-0x77 | 内核偏移,值为0x200 |
14 | 0x78-0x7B | 内核长度,值为0x139689 |
15 | 0x7C-0x7F | 文件系统偏移,值为0x140000 |
16 | 0x80-0x83 | 文件系统长度,值为0x5F91B2 |
17 | 0x84-0x87 | bootloader偏移,值为0 |
18 | 0x88-0x8B | bootloader长度,值为0x0168EB |
19 | 0x8C-0x8D | magic,值为0x55AA |
20 | 0x8E | sver主版本号,值为1 |
21 | 0x8F | sver次版本号,值为7 |
22 | 0x90 | magic,值为0xA5 |
23 | 0x91 | 主版本号,值为0 |
24 | 0x92 | 次版本号,值为6 |
25 | 0x93 | 小版本号,值为0 |
26 | 0x94-0xCF | 未知数据 |
27 | 0xD0-0x14F | 签名校验 (boot)+kernel+rootfs |
28 | 0x150-0x1C0 | 签名校验,未使用值为0 |
29 | 0x1D0-0x1FF | 填充数据,值为0 |
根据解析的偏移,可以编写binwalk的识别方法(添加在binwalk目录的magic/firmware文件):
TP-Link firmware header structure v2.0 4 string ver.\x202.0 TP-Link firmware header v2.0, 0x91 byte x firmware version: %d. 0x92 byte x \b%d. 0x93 byte x \b%d_ 0x8E byte x \b%d. 0x8F byte x \b%d, 0x70 ubelong x image size: 0x%X bytes, 0x34 ubelong x product ID: 0x%08X, 0x38 ubelong x product version: 0x%08X, 0x3C ubelong x additional hardware version: 0x%08X, 0x68 ubelong&0xff 0x80 0x68 ulelong x kernel load address: 0x%X, 0x68 ubelong&0xff !0x80 0x68 ubelong x kernel load address: 0x%X, 0x6C ubelong&0xff 0x80 0x6C ulelong x kernel entry point: 0x%X, 0x6C ubelong&0xff !0x80 0x6C ubelong x kernel entry point: 0x%X, 0x74 ubelong x kernel offset: 0x%X, 0x78 ubelong x kernel length: 0x%X, 0x7C ubelong x rootfs offset: 0x%X, 0x80 ubelong x rootfs length: 0x%X, 0x84 ubelong x bootloader offset: 0x%X, 0x88 ubelong x bootloader length: 0x%X |
使用本站的固件分析工具可以分析固件结构:

最终根据固件头可以知晓固件的结构:
序号 | 偏移 | 说明 |
1 | 0x0-0x200 | TP v2固件头1 |
2 | 0x200-0x51FF | Bootloader,实为uboot |
3 | 0x5200-0x523F | uImage头1 |
4 | 0x5240-0x101FF | 压缩的内核1 kernel |
5 | 0x10200-0x10247 | uImage头2 |
6 | 0x10248-0x201FF | 压缩的内核2 kernel |
7 | 0x20200-0x203FF | TP v2固件头2 |
8 | 0x20400-0x1601FF | 文件系统 rootfs |
hi!,I like your writing so so much! share we be in contact
extra about your post on AOL? I require a specialist in this area to solve my problem.
May be that's you! Having a look forward to peer you.