Closed RLS-Rylan closed 1 year ago
Thanks for reporting this and providing an example. Have you found documentation on this null-rootfs_offset behavior? It would help clarify the following questions:
OpenWrtTrxRootfs
should be empty (or nonexistant) and the OpenWrtTrxKernel
should include all the data starting from trx_kernel_offset
to the end (or trx_binheader_offset
if it's version 2)?I can see where in the Packer and Unpacker this change is needed, should be simple enough once the desired behavior is clear.
Unfortunately the only documentation I've come across so far is: 1) The OpenWRT header wiki page that the diagrams in the ofrak TRX unpacker appear to be from 2) trx.c from OpenWRT's firmware utils constructs TRX headers, but doesn't mention anything about the rootfs being null
Although I'm not seeing any documentation, I think your assumptions are accurate - ie. OpenWrtTrxRootfs
should be empty/nonexistant and OpenWrtTrxKernel
should include all data from trx_kernel_offset
to the end of the file or trx_binheader_offset
(if present).
It looks like all the TRX files I was able to pull from the OpenWRT website are TRX v1, so I have not yet tested this on TRX v2 firmware.
What is the problem? (Here is where you provide a complete Traceback.) Many TRX images seem to zero out the
rootfs_offset
field in the TRX header, and store data in a UBIFS filesystem atkernel_offset
within the image. When this happens, theOpenWrtTrxKernel
is empty, and theOpenWrtTrxRootfs
object contains all data from offset 0 to the end of the file.Please provide some information about your environment.
redballoonsecurity/ofrak/binaryninja
If you've discovered it, what is the root cause of the problem?
How often does the issue happen? This seems to affect all targets except
bcrm47xx/mips74k
across all versions of OpenWRTWhat are the steps to reproduce the issue? Running the following function on a (bcm53xx target)[https://downloads.openwrt.org/releases/19.07.0/targets/bcm53xx/generic/openwrt-19.07.0-bcm53xx-buffalo-wxr-1900dhp-squashfs.trx] and a (bcrm47xx)[https://downloads.openwrt.org/releases/21.02.0-rc1/targets/bcm47xx/mips74k/openwrt-21.02.0-rc1-bcm47xx-mips74k-asus_rt-n10u-b-squashfs.trx] will produce the output below
How would you implement this fix?
Are there any (reasonable) alternative approaches?
Are you interested in implementing it yourself?