Now that we have gained access to the box, let’s start gather some info – this is the very first step if we want to try to build a custom firmware.
First of all, let’s make a dump of the flash.
We said that the router has a telnet access: when we log in, we’re in the command line shell of OpenRG. From there we can control various aspects of the box, but if we type ‘system shell‘ and press enter… voilà! We’re in a busybox shell!
We can put a pendrive in one of the USB ports and mount it:
mount /dev/sda1 /mnt/flash
then use dd to dump the flash:
dd if=/dev/mtdblock0 of=/mnt/flash/flashdump.img bs=1m
Now we have a 16Mb file, but what there’s inside?
We saw that our router uses U-Boot as its bootloader. This is a good thing: U-Boot is open source, and this version keeps a bunch of useful commands.
With flayout, we have the layout of the flash:
=> flayout
Section 00 Type UNKNOWN Address 0xBF000000 MaxSize 0×00060000
Section 01 Type IMAGE Address 0xBF060000 MaxSize 0x003E0000
Section 02 Type IMAGE Address 0xBF440000 MaxSize 0x00AE0000
Section 03 Type CONF Address 0xBFF20000 MaxSize 0×00060000
Section 04 Type CONF Address 0xBFF80000 MaxSize 0×00060000
Section 05 Type FACTORY Address 0xBFFE0000 MaxSize 0x0001FC00
Section 06 Type LAYOUT Address 0xBFFFFC00 MaxSize 0×00000400
Also, from bdinfo, we know at wich address is the flash start:
flashstart = 0xBF000000
Now, we can split our flash image:
dd if=flashimage.img of=uboot.img ibs=1 count=$((0×00060000))
dd if=flashimage.img of=openrg_1.img ibs=1 skip=$((0×00060000)) count=$((0x003E0000))
dd if=flashimage.img of=openrg_2.img ibs=1 skip=$((0×00440000)) count=$((0x00AE0000))
dd if=flashimage.img of=conf_1.img ibs=1 skip=$((0x00F20000)) count=$((0×00060000))
dd if=flashimage.img of=conf_2.img ibs=1 skip=$((0x00F80000)) count=$((0×00060000))
dd if=flashimage.img of=conf_factory.img ibs=1 skip=$((0x00FE0000)) count=$((0x0001FC00))
dd if=flashimage.img of=conf_factory.img ibs=1 skip=$((0x00FFFC00)) count=$((0×00000400))






