Git Product home page Git Product logo

ubi_reader's Introduction

UBI Reader

UBI Reader is a Python module and collection of scripts capable of extracting the contents of UBI and UBIFS images, along with analyzing these images to determine the parameter settings to recreate them using the mtd-utils tools.

Testing Branch

The testing branch includes a tools/ directory, that with scripts to help when trying to extract data from broken images. These also serve as examples of how to use ubi_reader in custom scripts.

An override system is also included, for manually setting certain parameters that may be reported wrong by the UBI/FS data.

This branch will probably remain seperate, as it is meant to be customized to aid in extracting data from problematic images. You can install it with 'python setup.py develop' to make it easier to modify ubi_reader as needed.

Dependencies:

Python 2.7 is required.

python-lzo is the only non-standard module, it may or may not be available for your distro.

$ sudo apt-get install liblzo2-dev

If it is available.
$ sudo apt-get install python-lzo

Else you will need to install from sources.
$ git clone https://github.com/jd-boyd/python-lzo.git
$ cd python-lzo
$ python setup.py install

Installation:

$ git clone https://github.com/jrspruitt/ubi_reader
$ cd ubi_reader
$ sudo python setup.py install

Or

$ sudo pip2 install ubi_reader

Usage:

For basic usage, the scripts need no options and if applicable will save output to ./ubifs-root/. More advanced usage can set start and end offset, specify an output directory, or for debugging can print out what it is doing to the terminal.

Run program with -h or --help for explanation of options.

Extracting File Contents:

ubireader_extract_files [options] path/to/file

The script accepts a file with UBI or UBIFS data in it, so should work with a NAND dump. It will search for the first occurance of UBI or UBIFS data and attempt to extract the contents. If file includes special files, you will may need to run as fakeroot and set the (-k, --keep-permissions) option, for it to create these files. With out it, it'll skip them and show a warning that these files were not created.

Extracting Images:

ubireader_extract_images [options] path/to/file

This script will extract the whole UBI or UBIFS image from a NAND dump, or the UBIFS image from a UBI image. You can specify what type of image to extract by setting the (-u, --image-type) option to "UBI" or "UBIFS". Default is "UBIFS".

MTD-Utils Parameters:

ubireader_utils_info [options] path/to/file

The script will analyze a UBI image and create a Linux shell script and UBI config file that can be used for building new UBI images to the same specifications. For just a printed list of the options and values, use the (-r, --show-only) option.

Display Information:

ubireader_display_info [options] path/to/file

Depending on the image type found, this script displays some UBI information along with the header info from the layout block, including volume table records. If it is a UBIFS image, the Super Node, and both Master Nodes are displayed. Using the (-u, --ubifs-info) option, it will get the UBIFS info from inside a UBI file instead.

Options:

Some general option flags are

  • -l, --log: This prints to screen actions being taken while running.
  • -v, --verbose: This basically prints everything about anything happening.
  • -p, --peb-size int: Specify PEB size of the UBI image, instead of having it guess.
  • -e, --leb-size int: Specify LEB size of UBIFS image, instead of having it guess.
  • -s, --start-offset int: Tell script to look for UBI/UBIFS data at given address.
  • -n, --end-offset int: Tell script to ignore data after given address in data.
  • -g, --guess-offset: Specify offset to start guessing where UBI data is in file. Useful for NAND dumps with false positives before image.
  • -w, --warn-only-block-read-errors: Attempts to continue extracting files even with bad block reads. Some data will be missing or corrupted!
  • -i, --ignore-block-header-errors: Forces unused and error containing blocks to be included and also displayed with log/verbose.
  • -o, --output-dir path: Specify where files should be written to, instead of ubi_reader/output

Known Issues

  • Socket files will be ignored, you can change modules/settings.py to have it created dummy files in their place.

  • For NAND dumps and the like, this will not fix anything ECC would take care of, so some bad data may be extracted.

  • This does not replay the journal, so uncommited data will not be retrieved.

  • Assumes things are in good condition and where it thinks they should be...

TODO

  • Organize, document, the usual.

  • Arbitrary block analyzer script.

ubi_reader's People

Contributors

jrspruitt avatar sviehb avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.