Analysis of Asus TRX firmware
Introduction
Analysis of file FW_RT_N53_30043763754.trx corresponding to firmware of Asus RT N53.
Header Structure
Offset | Size (Bytes) | Item | Value (FW_RT_N53_30043763754.trx) |
---|---|---|---|
0 | 4 | Magic Bytes | HDR0 |
4 | 4 | Length (including header) | 0x00707000 |
8 | 4 | CRC32 (for data from offset 0xC) | 0x512E08B5 |
0xC | 2 | Flags | 0 |
0x0E | 2 | Version | 0x0001 |
0x10 | 4 | Loader Offset | 0x0000001C |
0x14 | 4 | Kernel Offset | 0x00000A8C |
0x18 | 4 | Rootfs Offset | 0x001299EC |
Analysis
If the magic bytes is HDR0 firmware is little endian.
1. Verify size of file is same as that in header, ie. 0x707000 or 7368704 bytes.
2. To calculate CRC32 extract data from offset 0xC.
dd iflag=skip_bytes if=fw.trx skip=$((0xC)) of=crc_data
Calculate CRC32:
crc32 crc_data
Convert result obtained, 0xaed1f74a to signed value and verify with header.
printf %X $((~0xaed1f74a & 0xFFFFFFFF))
3. Extract loader:
dd iflag=skip_bytes,count_bytes if=fw.trx skip=$((0x1C)) count=$((0xA8C - 0x1C)) of=loader
4. Extract kernel:
dd iflag=skip_bytes,count_bytes if=fw.trx skip=$((0xA8C)) count=$((0x1299EC - 0xA8C)) of=kernel
5. Extract rootfs:
dd iflag=skip_bytes,count_bytes if=fw.trx skip=$((0x1299EC)) of=rootfs
sasquatch rootfs
Nice post! I followed your code but realized my firmware doesnt start like yours. Its missing the HDR0, and everything else. Do you have any recommendation on how can I continue? If it helps my firmware is the RT-AC1200_V2_3.0.0.4_382_70167-g57155ad.trx from an asus router (rt-ac1200 v2)
ReplyDelete