Ausnahme gefangen: SSL certificate problem: certificate is not yet valid ๐Ÿ“Œ MindShaRE: Dealing with encrypted router firmware

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š MindShaRE: Dealing with encrypted router firmware


๐Ÿ’ก Newskategorie: Hacking
๐Ÿ”— Quelle: thezdi.com

Perhaps you read our multiple previous blog posts on router vulnerability research and decided to give it a try. Great! You downloaded the firmware of your home router from the vender website, threw it in binwalk so that you could just emulate it in QEMU. Then the following screen appearedโ€ฆ

Fig 1. binwalk tosses its hands into the air, shrugs, and reports back nothing.

Fig 1. binwalk tosses its hands into the air, shrugs, and reports back nothing.

What now?

In general, each non-binwalk friendly firmware will be an adventure of its own, making it impossible to provide a step-by-step guide for defeating all types of encrypted firmware. This blog aims to go through a few common scenarios and provide a general guide to dealing with this type of firmware. Weโ€™ll also provide an example for decrypting the D-Link DIR-882 firmware.

Look back and look around: Three common scenarios of encrypted firmware releases

The simplest method to decrypt the firmware is to look for the decryption routine within the firmware. โ€œHow?โ€ you ask. If the router can decrypt the new firmware for updates, the decryption routine must be located in the old firmware image somewhere. If you encounter an encrypted firmware, go to the vendor website and look for archived versions of the firmware, download all old versions and start poking around.

Below are three common firmware release scenarios:

Scenario 1

The device firmware was not encrypted nor did it contain any decryption routine when it was factory released. A decryption routine is shipped along with an unencrypted version of the firmware in a newer version (v1.1) for future encrypted firmware update. Subsequent firmware releases are encrypted.

Figure 2: Firmware release scenario 1

Figure 2: Firmware release scenario 1

In this scenario, we can obtain the decryption routine from firmware v1.1 and use it to decrypt the latest firmware version 1.2.

Scenario 2

The device firmware is encrypted in the original release. The vendor decided to change the encryption scheme and release an unencrypted transition version v1.2 which contains the new decryption routine.

Figure 3: Firmware release scenario 2

Figure 3: Firmware release scenario 2

Similar to scenario 1, we can obtain the decryption routine from v1.2 image and apply it to the latest encrypted firmware. Reading the release notes of the firmware releases could be helpful in identifying the unencrypted transition version. The release notes will usually direct the user to upgrade to an intermediate version before upgrading to the latest version. The intermediate version is very likely to be the unencrypted transition firmware.

Scenario 3

The device firmware is encrypted in the original release. However, the vendor decided to change the encryption scheme, and release an unencrypted transition version which contains the new decryption routine.

Figure 4: Firmware release scenario 3

Figure 4: Firmware release scenario 3

In this case, there is no easy method to obtain the decryption routine. One route is to purchase a device and extract the unencrypted firmware from the hardware directly. Another possible route is to perform more analysis on the firmware in hopes to โ€œbreak the encryption.โ€

Scenario 3: Bust out the Hex Editor

Quickly scrolling through the firmware in a hex editor can give us an intuitive sense of what we are dealing within. View it in binary mode; view it in hex mode. Are there fields of 0xFF bytes or 0x00 bytes? Are there patterns within the file? Is it a homogenous blob of random hex bytes? In that case, there is a good chance the firmware has been instead of a simple XOR with a static key. Inspect the histogram, is there a hex byte that appears more often than the others?

Scenario 3: Compressed, Encrypted, or Obfuscated?

Entropy provides important insights into the firmware. A section of the firmware with high entropy suggests encryption. A section of low entropy bytes suggests low-randomness, structures, and predictability. When combined with other analytics, it allows us to determine if compressed, encrypted or obfuscated. The vast number of options of binwalk could become useful in this stage of analysis.

Work in theory, also works in practice

Letโ€™s apply our newfound knowledge to an encrypted D-Link DIR-882 firmware image:

Figure 5: binwalk unable to identify anything in the firmware image

Figure 5: binwalk unable to identify anything in the firmware image

From the vendorโ€™s FTP server, we can find all the old firmware for this router. If we examine the earliest firmware version v1.00B07 with binwalk, it will correctly detect the uImage header, and the LZMA compress data:

Figure 6: binwalk scan results for the early DIR-882 router firmware

Figure 6: binwalk scan results for the early DIR-882 router firmware

This shows that we are in Scenario 1 of firmware release schedule. After going through all available versions of the firmware image, we discover that v1.04B02 of the firmware is the transition version and it is included within the v1.10B02 firmware package. You may also calculate the entropy of the images to quickly determine which one has been encrypted.

Figure 7: binwalk results for the unencrypted transition version and the first encrypted firmware

Figure 7: binwalk results for the unencrypted transition version and the first encrypted firmware

We then extract the file system from the v1.04B02 firmware with binwalk.

Figure 8: binwalk extracting the root file system for firmware version 1.04B02

Figure 8: binwalk extracting the root file system for firmware version 1.04B02

After a successful extraction, we can start investigating the firmware update process and determine how the firmware is being decrypted. Luckily, a quick browse of the file system found a promising looking binary named imgdecrypt in the /bin directory.

Figure 9: Directory contents of /bin for the extracted file system.

Figure 9: Directory contents of /bin for the extracted file system.

Just one small problem

We have the small problem of difference in processor architecture between the host and the binary. Luckily, we can perform a cross-architectural chroot with QEMU. To do this, first we copy the qemu-mipsel-static binary to the /usr/bin/ directory of the firmware root file system. We also copy the encrypted firmware to the unencrypted firmware file system. Finally, we chroot into the firmware root and obtain a working shell. Special thanks to the researcher known as chung96vn for showing us this cross-architectural chroot technique.

Figure 10: Using QEMU to perform a cross-architectural chroot and decrypt the firmware

Figure 10: Using QEMU to perform a cross-architectural chroot and decrypt the firmware

With a working shell, we may run imgdecrypt and decrypt the encrypted firmware.

Figure 11: binwalk successfully detecting different sections of the decrypted firmware

Figure 11: binwalk successfully detecting different sections of the decrypted firmware

Conclusion

And there you have it! This is how you deal with encrypted firmware. If you encounter scenario 3, donโ€™t panic. Consumer routers are often limited in computing power. This limitation rules out slower, harder-to-crack asymmetrical encryption such as RSA. Also, vendors sometimes use the same encryption scheme for multiple routers. In fact, the imgdecrypt binary can also be used for decrypting the firmware for DIR-878, and DIR-867. Look for routers that are in the same product line, with same processor architecture. Look around there and you might just hit jack pot. In any case, I wish you luck in your hardware hacking endeavors and look forward to seeing your submission!

You can find me on Twitter @TrendyTofu, and follow the team for the latest in exploit techniques and security patches.

References and further reading

https://wzt.ac.cn/2019/09/18/D-Link_BUG/

https://www.itcodemonkey.com/article/13631.html

https://ownyourbits.com/2018/06/13/transparently-running-binaries-from-any-architecture-in-linux-with-qemu-and-binfmt_misc/

...



๐Ÿ“Œ MindShaRE: Dealing with encrypted router firmware


๐Ÿ“ˆ 69.13 Punkte

๐Ÿ“Œ Dealing with encrypted firmware when reversing a wireless router


๐Ÿ“ˆ 42.07 Punkte

๐Ÿ“Œ MindShaRE: Hardware Reversing with the Belkin Surf N300 Router


๐Ÿ“ˆ 34.36 Punkte

๐Ÿ“Œ MindShaRE: Hardware Reversing with the TP-Link TL-WR841N Router


๐Ÿ“ˆ 34.36 Punkte

๐Ÿ“Œ MindShaRE: Hardware Reversing with the TP-Link TL-WR841N Router - Part 2


๐Ÿ“ˆ 34.36 Punkte

๐Ÿ“Œ MindShaRE: Automated Bug Hunting by Modeling Vulnerable Code


๐Ÿ“ˆ 27.06 Punkte

๐Ÿ“Œ CISO Mindshare Is Influencing Tomorrowโ€™s Platforms


๐Ÿ“ˆ 27.06 Punkte

๐Ÿ“Œ MindShaRE: Using lldbinit to Enhance the LLDB Debugger


๐Ÿ“ˆ 27.06 Punkte

๐Ÿ“Œ MindShaRE: How to โ€œJust Emulate It With QEMUโ€


๐Ÿ“ˆ 27.06 Punkte

๐Ÿ“Œ MindShaRE: Analysis of VMware Workstation and ESXi Using Debug Symbols from Flings


๐Ÿ“ˆ 27.06 Punkte

๐Ÿ“Œ MindShaRE: When MySQL Cluster Encounters Taint Analysis


๐Ÿ“ˆ 27.06 Punkte

๐Ÿ“Œ MindShaRE: Analyzing BSD Kernels for Uninitialized Memory Disclosures using Binary Ninja


๐Ÿ“ˆ 27.06 Punkte

๐Ÿ“Œ Debian Chooses Reasonable, Common Sense Solution To Dealing With Non-Free Firmware


๐Ÿ“ˆ 23.92 Punkte

๐Ÿ“Œ Should /boot be encrypted on an encrypted linux system?


๐Ÿ“ˆ 21.73 Punkte

๐Ÿ“Œ Hardware Encrypted Drive with Tails OS and Software Encrypted Persistence


๐Ÿ“ˆ 21.73 Punkte

๐Ÿ“Œ Encrypted Email: How to Send Encrypted Email (Outlook, Gmail iOS, Android, OSX or Webmail)


๐Ÿ“ˆ 21.73 Punkte

๐Ÿ“Œ Dealing With Third-Party Vendor Connections in Your Network


๐Ÿ“ˆ 16.94 Punkte

๐Ÿ“Œ Samsung Isn't The Only One, Xiaomi Reportedly Also Dealing With Exploding Phones


๐Ÿ“ˆ 16.94 Punkte

๐Ÿ“Œ Dealing With Third-Party Vendor Connections in Your Network


๐Ÿ“ˆ 16.94 Punkte

๐Ÿ“Œ Before, During and After: Dealing With Attacks and Applying Effective Incident Management


๐Ÿ“ˆ 16.94 Punkte

๐Ÿ“Œ Dealing With Third-Party Vendor Connections in Your Network


๐Ÿ“ˆ 16.94 Punkte

๐Ÿ“Œ FBI Dark Web Drug Crackdown Charges Father And Son With Dealing Fentanyl


๐Ÿ“ˆ 16.94 Punkte

๐Ÿ“Œ Cybersecurity 101: How universities are dealing with hackers


๐Ÿ“ˆ 16.94 Punkte

๐Ÿ“Œ Boeing Is Dealing With a Suspected WannaCry Ransomware Outbreak


๐Ÿ“ˆ 16.94 Punkte

๐Ÿ“Œ Samsung Isn't The Only One, Xiaomi Reportedly Also Dealing With Exploding Phones


๐Ÿ“ˆ 16.94 Punkte

๐Ÿ“Œ Security Leaders: When Dealing with DevOps, Get Your Mind Right


๐Ÿ“ˆ 16.94 Punkte

๐Ÿ“Œ Dealing With Data Loss Your Firewall Can't Stop


๐Ÿ“ˆ 16.94 Punkte

๐Ÿ“Œ Streaming Service Tidal May Be Dealing With A Data Breach


๐Ÿ“ˆ 16.94 Punkte

๐Ÿ“Œ DEF CON 26 CANNABIS VILLAGE - Mayor Chad Wanke - Primer On Dealing with Local Gov for Legal Cannabis


๐Ÿ“ˆ 16.94 Punkte

๐Ÿ“Œ After Germany, Kenya Is Now Dealing with Emotet Malware Infection


๐Ÿ“ˆ 16.94 Punkte

๐Ÿ“Œ Approaches to dealing with an unresponsive desktop


๐Ÿ“ˆ 16.94 Punkte

๐Ÿ“Œ San Jose Mayor Quits FCC Advisory Committee, Says It is Dealing ISPs a 'Very Favorable Hand'


๐Ÿ“ˆ 16.94 Punkte

๐Ÿ“Œ What are the early detection strategies of dealing with Memcached DDoS?


๐Ÿ“ˆ 16.94 Punkte











matomo