用实现的纠错码 (ECC) 编码和解码 NAND 存储芯片的简单软件工具
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).
The NAND Dump Tools can be downloaded and installed in the following way:
git clone https://github.com/SySS-Research/nand-dump-tools.git
cd NAND_Dump_Tools
./setup.shThe 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:
…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.binIf 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_dumpBy 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.iniBefore 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.
…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.
Use at your own risk. Do not use without full consent of everyone involved. For educational purposes only.
暂无开放 Issues,或尚未同步最近议题。