# UBI Reader UBI/UBIFS 镜像读取工具

> 读取 UBI 和 UBIFS 镜像的 Python 模块与命令行脚本，通过定位文件中首个 UBI 或 UBIFS 数据来处理镜像，也适用于原始 NAND 转储。它们可提取文件或完整的 UBI、UBIFS 镜像，列出并复制单个文件，显示 UBI 头部、卷表以及 UBIFS 的超级节点和主节点，并能在提取失败时按条件搜索物理擦除块进行调试。ubireader_utils_info 还能推算出 mtd-utils 参数，生成按相同规格重建镜像所需的 shell 脚本和配置文件。

- 类型：工具
- 目标：固件
- 类别：固件工具
- 关联：基础工具
- 来源复核于：2026-10-27
- 收录于：2026-11-03
- 原始资源：<https://github.com/onekey-sec/ubi_reader>
- 一手来源：<https://github.com/onekey-sec/ubi_reader/blob/5f45e50c813599d689b8cf88e12e7c79dec1728f/README.md>
- 目录页面：<https://awesomerea.org/zh/resources/ubi-reader/>
- 记录 JSON：<https://awesomerea.org/resources/ubi-reader/record.json>
- 英文版：[English](https://awesomerea.org/resources/ubi-reader/index.md)

## 使用条件与局限

- 审阅对象为 main 分支提交 5f45e50（2026-09-13）。最新版本为 0.8.16，于 2026-09-04 发布在 GitHub，并以 ubi-reader 包名发布到 PyPI；pyproject 列出的作者为 ONEKEY 和 Jason Pruitt，所审阅的 unblob main 提交依赖 ubi-reader>=0.8.15。README 提到的独立 testing 分支提供修复工具和用于损坏镜像的参数覆盖功能，最后更新于 2018 年。
- 需要 Python 3.10+，可从 PyPI 安装，或用 Poetry 从源码安装；依赖包括用于 LZO 的 lzallright、zstandard 和 cryptography。提取时创建特殊文件需要 root 权限，套接字文件默认跳过，除非修改 settings.py。采用 fscrypt v1 策略加密的文件只有在用户提供主密钥时才会被解密。
- 输入为用户自行提供的 UBI 或 UBIFS 镜像或 NAND 转储。仓库没有提交任何固件或闪存镜像；唯一的测试检查提取文件名时防止路径穿越的保护逻辑，CI 在 Python 3.10 上用 pytest 运行该测试。
- README 列出的已知问题：不会重放日志，因此无法恢复未提交的数据；视 NAND 的转储方式而定，数据位可能未经纠错。自动推测失败时可手动指定偏移以及 PEB 或 LEB 大小。采用 GPL-3.0（LICENSE；pyproject 写作 GNU GPL）；提取出的固件内容仍归各厂商所有。

## 一手来源

1. <https://github.com/onekey-sec/ubi_reader/blob/5f45e50c813599d689b8cf88e12e7c79dec1728f/README.md>
2. <https://github.com/onekey-sec/ubi_reader/blob/5f45e50c813599d689b8cf88e12e7c79dec1728f/pyproject.toml>
3. <https://github.com/onekey-sec/ubi_reader/blob/5f45e50c813599d689b8cf88e12e7c79dec1728f/LICENSE>
4. <https://github.com/onekey-sec/ubi_reader/blob/5f45e50c813599d689b8cf88e12e7c79dec1728f/ubireader/scripts/ubireader_extract_files.py>
5. <https://github.com/onekey-sec/ubi_reader/blob/5f45e50c813599d689b8cf88e12e7c79dec1728f/ubireader/ubifs/decrypt.py>
6. <https://github.com/onekey-sec/ubi_reader/blob/5f45e50c813599d689b8cf88e12e7c79dec1728f/tests/test_ubifs_output.py>
7. <https://github.com/onekey-sec/ubi_reader/blob/5f45e50c813599d689b8cf88e12e7c79dec1728f/.github/workflows/tests.yml>
8. <https://github.com/onekey-sec/ubi_reader/releases/tag/0.8.16>
9. <https://pypi.org/project/ubi-reader/0.8.16/>
10. <https://github.com/onekey-sec/unblob/blob/0f40c3c6940fa2bcfd2945f519fe8caf99e31e44/pyproject.toml>

## 同分区更多条目：固件与硬件

- [payload-dumper-go Android OTA 载荷提取工具](https://awesomerea.org/zh/resources/payload-dumper-go/index.md) · 工具
- [mithril 物联网固件静态扫描器](https://awesomerea.org/zh/resources/mithril-iot-scanner/index.md) · 工具
- [img4tool Apple IMG4 容器工具](https://awesomerea.org/zh/resources/img4tool/index.md) · 工具
- [payload dumper Android OTA 分区镜像提取工具](https://awesomerea.org/zh/resources/payload-dumper/index.md) · 工具
- [PMCA-RE RELOADED 索尼相机分析与管理工具](https://awesomerea.org/zh/resources/pmca-re-reloaded/index.md) · 工具
- [ThisFirmwareDoesNotExist MicroFreak 固件分析与补丁工具](https://awesomerea.org/zh/resources/thisfirmwaredoesnotexist/index.md) · 工具

## 关于此条目

说明已依据一手来源复核。
原创说明采用 MIT 许可；外部项目、论文与素材保留各自的权利和许可。
