onekey-sec / ubi_reader

Collection of Python scripts for reading information about and extracting data from UBI and UBIFS images.
GNU General Public License v3.0
524 stars 136 forks source link

AttributeError: 'NoneType' object has no attribute 'data_size' #68

Closed 7ider5 closed 1 year ago

7ider5 commented 1 year ago

Hi,

Thank you for your work!

Trying to analyse an ubi image extracted with binwalk from a NAND flash dump, I get the following error:

$ ubireader_display_info ./_dump.bin.extracted/7BC000.ubi Traceback (most recent call last): File "/home/itsme/.local/bin/ubireader_display_info", line 132, in ubi_obj = ubi(ufile_obj) File "/home/itsme/.local/lib/python3.10/site-packages/ubireader/ubi/init.py", line 146, in init super(ubi, self).init(ubi_file) File "/home/itsme/.local/lib/python3.10/site-packages/ubireader/ubi/init.py", line 46, in init self._blocks = extract_blocks(self) File "/home/itsme/.local/lib/python3.10/site-packages/ubireader/ubi/block/init.py", line 131, in extract_blocks blk.data_crc = (~crc32(buf[blk.ec_hdr.data_offset:blk.ec_hdr.data_offset+blk.vid_hdr.data_size]) & UBI_CRC32_INIT) AttributeError: 'NoneType' object has no attribute 'data_size'

What goes wrong here ?

Pierre

jrspruitt commented 1 year ago

Hi Pierre,

I'm not sure exactly what binwalk does to extract a UBI image. Since it's a NAND dump, the usual suspects are, incomplete dump, that is, a block of data is missing, or there is OOB data that has been left in, which will throw off ubi_reader, another possibility is an error that was not corrected at just the right spot.

OOB and error correction are likely if you dumped the chip with a hardware reader. If you dumped it from a running system, that may not be the case.

-Jason

7ider5 commented 1 year ago

Thank you Jason,

It is indeed probably because of reading errors during the dump

Pierre