2

I recently extracted the firmware (u-boot system) from an old Sagemcom router and analyzed it using the binwalk utility for a personal reverse engineering project.

Despite identifying a root filesystem (likely JFFS2 based on string analysis), binwalk was unable to recognize or extract it. I know that the filesystem is JFFS by examining the boot info, and performing strings analysis on my dump. (You can check the git repo given further down)

Steps Taken:​

  1. Initial Extraction with Binwalk:
  • Binwalk was used to analyze the firmware, but it failed to identify the root filesystem.

binwalk x dd

  1. Manual Binary Segmentation:
  • Based on MTD (Memory Technology Device) partitions, I attempted to segment the binary using the dd command.
  • Encountered overlapping addresses and excessive total pages exceeding 65536 (total memory size of 16MB divided by page size of 2048 bytes).

MTD partitionning

Challenges:​

  • Translating MTD addresses to NAND offsets.
  • Understanding the relationship between MTD partitions and NAND subsystems.
  • Ensuring correct memory dumping and assembly.
  • Extracting the JFFS2 rootfs

Additional Information:

  • Utilized dd for binary segmentation.
  • Cleaned .dmp files to remove Out-Of-Band (OOB) data and other unnecessary lines.

Memory Extraction steps:

  1. dump from router through UART : 'dump_nand_memory.py' ; use nand dump offset to dump nand page
  2. assure no error in the file : assure_140_lines.py
  3. clean .dmp file (dont keep oob) : clean_dmp.py
  4. concatenate all .dmp file into .bin : concatenated_all_to_bin.py
  5. Search for magic number in the binary for JFFS2 filesystem : check_for_JFFS2.py

Questions:

  • How do I accurately convert MTD partition addresses into corresponding NAND offsets?
  • Is MTD simply an abstraction layer for NAND, or is there more complexity involved ?
  • Do I have correctly extracted memory, do I need to correct errors using OOB ?
  • Where can I find more info about u-boot, embed system, ... (doc is pretty much non existent)

1 Answer 1

2

There's no need for binwalk to be further utilized for JFFS2 extraction.

Since Binwak detect ubi filesystem (and not JFFS2) it is smarter to use tools like ubireader to extract it from the firmware.

So i've installed ubireader from the AUR, and performed ubireader_extract_images firmware.bin which cave me a set of .ubifs files that could be extracted by binwalk.

Further investigation still need to be done sine /etc/passwd & /etc/shadow from ubirootfs does not contain password hash for root user

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.