Decrypting An Encrypted Firmware (DIR842)
To download the firmware copy the firmware version shown below from the D-Link FTP Server
unzip the file DIR-842_REVC_FIRMWARE_v3.13B05.zip
and run binwalk on the extracted file
1 | ┌──(kali㉿kali)-[~/DIR842] |
As we can see that our file firmware DIR842C1_FW313WWb05.bin
is encrypted.
Now let’s Unzip the file DIR-842_REVC_FIRMWARE_v3.10B05.zip
and extract the filesystem of DIR842C1_FW302b03_middle.bin
using binwalk
1 | ┌──(kali㉿kali)-[~/DIR842] |
Go to extracted file system and identify the architecture by using file
command of it’s busybox binary
1 | ┌──(kali㉿kali)-[~/DIR842/_DIR842C1_FW302b03_middle.bin.extracted/squashfs-root] |
As we can see that the architecture is mips32
. Let’s try to run the busybox using qemu-mips-static
1 |
|
Now let’s try to find the string decrypt
in the squashfs-root
using grep
1 | ┌──(kali㉿kali)-[~/DIR842/_DIR842C1_FW302b03_middle.bin.extracted/squashfs-root] |
There are many out of which the interesting match is encimg
file. let’s try to run with qemu-mips-static
1 | ┌──(kali㉿kali)-[~/DIR842/_DIR842C1_FW302b03_middle.bin.extracted/squashfs-root] |
Copy the the firmware file to squashfs-root
directory
1 | ┌──(kali㉿kali)-[~/DIR842/_DIR842C1_FW302b03_middle.bin.extracted/squashfs-root] |
Now if we try to run with qemu-mips-static
we get an error
1 | ┌──(kali㉿kali)-[~/DIR842/_DIR842C1_FW302b03_middle.bin.extracted/squashfs-root] |
Now copy the qemu-mips-static
to the squashfs-root
, use chroot
to open up a shell
1 | ┌──(kali㉿kali)-[~/DIR842/_DIR842C1_FW302b03_middle.bin.extracted/squashfs-root] |
As we can see that when trying to decrypt it says that no signature specified!
which means we need the signature in order to decrypt the firmware. Let’s try to find the signature by search for decrypt
string once again.
1 | ┌──(kali㉿kali)-[~/DIR842/_DIR842C1_FW302b03_middle.bin.extracted/squashfs-root] |
Let’s try to open up the bash file, as we can see from below image_sign
looks interesting
1 | ┌──(kali㉿kali)-[~/DIR842/_DIR842C1_FW302b03_middle.bin.extracted/squashfs-root] |
Now if we once again search for string image_sign
using grep.
1 | ┌──(kali㉿kali)-[~/DIR842/_DIR842C1_FW302b03_middle.bin.extracted/squashfs-root] |
We can see an interesting file /etc/config/image_sign
, Now if open the file we can see a string wrgac65_dlink.2015_dir842
1 | ┌──(kali㉿kali)-[~/DIR842/_DIR842C1_FW302b03_middle.bin.extracted/squashfs-root] |
Now let’s input the extracted string as signature to decrypt the firmware file.
1 | ┌──(kali㉿kali)-[~/DIR842/_DIR842C1_FW302b03_middle.bin.extracted/squashfs-root] |
If we run binwalk
we can see various information which means our firmware is decrypted
1 | ┌──(kali㉿kali)-[~/DIR842/_DIR842C1_FW302b03_middle.bin.extracted/squashfs-root] |