Breaking the D-Link DIR3060 Firmware Encryption – Recon – Part 1
0x434b.dev
0x434b.dev
[0]: https://0x434b.dev/breaking-the-d-link-dir3060-firmware-encr...
[1]: https://0x434b.dev/breaking-the-d-link-dir3060-firmware-encr...
I appreciated the writeup, especially since I’ve done some firmware decryption and repacking myself (although in my case, the encryption was just repeating-XOR!).
$ gpg --output decrypted.img --decrypt <model><ver>.gpg.img
binwalk can handle the rest.
It looks like they mainly did this for verification, as there is an RSA public key embedded on the device. It unfortunately does make it nearly impossible to flash any modified firmware such as OpenWRT, which is very frustrating. I say nearly as I haven't fully investigated the models that I own. Some routers have a emergency recovery flash method that may bypass the PGP check, I recall older D-Link models having a web flasher integrated into u-boot.
Unlike with yours, no decryption script is required, gnupg can decrypt them as-is.
Code signing is enough to prevent tampering, so D-Link obviously doesn't want their users to know how their own hardware works. Does D-Link view their users as the adversary? If so, should the users view D-Link as hostile?
I quickly reversed that thinking, knowing DLink's rep for pushing buggy insecure garbage.
All your thoughts and feedback are much appreciated :). I'm happy if you guys liked it!
cheers
It seems like it would be possible that once you find the "key" for one router, you could potentially exploit a bunch of other router/switch models as well. Am I incorrect in this thinking?
Of course this is D-Link and the product is an embedded garbage router, so chances are high they are doing it entirely wrong.
TL;DR: They verify the length of the encrypted and decrypted firmware as well as multiple RSA signatures.
As much as I like pushing security vectors on embedded/IoT devices... This approach of obscuring what is being pushed in an update may not be the right approach imo.
As for software, there was an issue earlier this year with Exchange Server failing to generate unique keys [0] (prev. discussion[1]).
[0]: https://www.thezdi.com/blog/2020/2/24/cve-2020-0688-remote-c...
I was able to finally extract the squashfs file from my routers firmware using dd and program I found on github called “sasquash” which patches decompression tools and can also flip endianness.