百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
N

nand-dump-tools

> 编程语言
开源

用实现的纠错码 (ECC) 编码和解码 NAND 存储芯片的简单软件工具

100 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

用实现的纠错码 (ECC) 编码和解码 NAND 存储芯片的简单软件工具

NAND Dump Tools

The SySS NAND Dump Tools are a collection of software tools for working with raw NAND flash memory dumps and images.

By using error-correcting codes, for instance BCH codes (Bose–Chaudhuri–Hocquenghem Codes), supporting different configurations, the NAND Dump Decoder can create error-corrected data dumps from raw NAND flash memory dumps, which can then be used with other tools, for instance the ubireader tools.

The NAND Dump Encoder can be used to create raw NAND flash memory images from binary input files for supported target platforms, which can then be directly written to corresponding NAND memory chips.

The NAND Dump Tools are based on and inspired by the open source software tool PMECC Reader and Decoder by Mickaël Walter (@MickaelWalter).

Supported NAND modes/target platforms

  1. ATMEL PMECC (BCH)
  2. NXP i.MX28 (BCH)
  3. NXP P1014 (BCH)
  4. YAFFS2 (Hamming code, experimental)

Installation

The NAND Dump Tools can be downloaded and installed in the following way:

bash
git clone https://github.com/SySS-Research/nand-dump-tools.git
cd NAND_Dump_Tools
./setup.sh

Usage

The Python tools NAND Dump Decoder and NAND Dump Encoder can be used via Shell script wrappers which automatically use the virtual environment for Python created during the software installation.

The following output shows the help screen of the NAND Dump Decoder:

…

The following output shows the help screen of the NAND Dump Encoder:

…

Example

The following example shows how the errors of a raw NAND flash memory dump of a SAMA5D4 Xplained Ultra evaluation board with a MT29F4G08 NAND flash memory chip (device ID 2CDC90A6) are corrected using the NAND Dump Decoder. The configuration of the ATMEL target system is read from the dump itself (PMECC header in first NAND dump block) using the command line argument --atmel-config. Alternatively, the command line argument --config can be used to specify a suitable NAND configuration.

…

Besides an error-corrected data dump, in this example, the NAND Dump Decoder also extracts a found cryptographic key which is used by some target systems for encrypting the error-correcting codes within the NAND spare areas, like in our SAMA5D4 device.

The created error-corrected NAND dump contains only data of user areas and can be used with the Memory Technology Device (MTD) System for Linux and its NAND simulator in the following way:

modprobe nandsim first_id_byte=0x2C second_id_byte=0xdc third_id_byte=0x90 fourth_id_byte=0xa6
 
cat /proc/mtd
 
nandwrite /dev/mtd1 sama.bin

If the NAND flash memory dump contains an Unsorted Block Image (UBI) with a UBI file system (UBIFS), like in this example, it can be mounted as follows:

modprobe ubi mtd=/dev/mtd1,4096
 
mkdir /tmp/nand_dump
 
mount -t ubifs -o rw /dev/ubi0_0 /tmp/nand_dump

By using the software tool ubireader_utils_info, the corresponding configuration of the Unsorted Block Image can be extracted, as the following output shows:

…

With this information, an Unsorted Block Image with the correctly formatted UBIFS can be created in the following way:

mkfs.ubifs -m 4096 -e 253952 -c 2082 -x lzo -f 8 -k r5 -p 1 -l 4 -r /tmp/nand_dump/ sama_hacked.ubifs
 
ubinize -p 262144 -m 4096 -O 4096 -s 4096 -x 1 -Q 928361211 -o sama_hacked.ubi sama_hacked.ini

Before such a created UBI file is further processed, its size should be adjusted via padding with 0xFF bytes to match the specification of the corresponding NAND memory chip, for instance 536870912 bytes for the 512 MB MT29F4G08. In doing so, there won't be any problems when programming the NAND chip with a universal programmer like the UP-828P.

Now, a valid NAND flash memory image can be created with the NAND Dump Encoder using a suitable configuration for the target system (SAMA5D4 in this example) and the correct cryptographic key for encrypting the error-correcting BCH codes within the NAND spare areas.

…

Demo

This demo video exemplarily shows a chip-off/chip-on attack for gaining unauthorized root access on a SAMA5D4 device (SAMA5D4 Xplained Ultra evaluation board) by exploiting the unencrypted NAND flash memory.

To-do

  • improve speed ;-)

References

  • BCH codes, Wikipedia, 2020
  • PMECC Reader and Decoder, Mickaël Walter, 2018
  • SAMA5D4 Xplained Ultra, Microchip
  • UP-828P

Disclaimer

Use at your own risk. Do not use without full consent of everyone involved. For educational purposes only.

Issues· 7 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Python

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言