Skip to content

Extracting on-device FAT partitions #1

@stefand

Description

@stefand

This isn't a bug per se, but this seems like the best place to send this information for it to be potentially found by others.

I tried to extract the FAT partition data from the dumps of my Philips E2106 phone. The attached extract-fat.c file is a very crude implementation:

  1. Figure out the start of the data section. In my case it was at 0x00382000. I figured it out by guessing with a hex editor. I am sure there are some offsets stored in the mediatek headers.
  2. Copy the data section to a separate file: dd if=dump.bin n of=input.bin bs=1 skip=3678208
  3. Build and run the attached .c file - it has the input and output filenames hardcoded
  4. Output.fat is now a disk image with an MBR partition table. One partition (in my case) starts at sector 1 (offset 512), the other at sector 71.

mount -o loop,offset=512 output.fat /mnt/
mount -o loop,offset=36352 output.fat /mnt/

5: The first partition is the one the phone exports when attached as a USB mass storage device. The second one is its "internal" data store.

The format is pretty simple. I think it is a crude wear-leveling algorithm:

The data section is divided into blocks of 4096 bytes. Each block contains a 32 byte header, 480 byte padding, followed by 7 sectors of 512 bytes. Yeah, that's plenty of padding.

The header has a uint32_t value that I didn't figure out, followed by two uint16_t (little endian) values giving the disk sector number and some flags field. Although the flags I saw are either 0 (which means the sector is unused), 0xffff (which means it has never been written, so treat it as unused) or 0c000 (which means it is in use). The structs at the start of the .c file should give some idea.

My original goal was to extract SMS from the phone's internal storage. I found my text messages in NVRAM/NVD_DATA/MPA3_001. Note that they are PDU encoded, so simply grepping for a known string won't find it. It is easier if you send yourself a unicode-encoded SMS (e.g. with a 😊 character) and then grep for UCS-2 strings.

The phone book seems to be in MP0C_003 (UCS-2 or maybe UTF16 names) and MP0H_006(ascii string numbers).

Now that I have figured out the interesting part and the the tedious work of writing a user-friendly tool remains I'll probably lose interest and move to other adventures. I hope that by dumping this information online my time wasn't entirely wasted.

extract-fat.c.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions