chickendrop89/imagefv-extractor

GitHub: chickendrop89/imagefv-extractor

一个使用 Python 编写的固件提取工具,用于从安卓设备的 imagefv blob 中解析和提取 UEFI 结构内的 bootloader 启动画面与充电图片。

Stars: 4 | Forks: 3

# imagefv-extractor 从 `imagefv` blob 中提取 bootloader/充电图片 ## 使用方法: 1. 安装 python 依赖项 ``` pip install -r requirements.txt ``` 2. 从互联网获取 `imagefv` blob,或者通过 `adb` 从设备中提取 3. 对该 blob 运行 `extractor.py`: ``` python ./extractor.py ./imagefv.elf ``` ## 用法: ``` usage: extractor.py [-h] [-o OUTPUT] [-v] input [input ...] Extract bootloader/charging pictures from imagefv blobs positional arguments: input Input file to process options: -h, --help show this help message and exit -o, --output OUTPUT Output directory (default: extracted_images) -v, --verbose Enable verbose logging (default: False) ``` ## 工作原理: 1. 脚本使用 `uefi-firmware` 包扫描输入文件中的 `UEFI` 结构 2. 如果找到,它会将所有文件/区块转储到临时目录中 3. 然后识别转储文件中的已知类型(在 `magic_map` 结构中定义)并进行分类整理 4. 此外,如果找到包含 GZip 归档的文件(通常是 `logo.img`),也会将其提取 ## 是否可以重新打包,并制作自定义启动画面? 在调查过程中,我注意到 `imagefv` blob 包含一些 CoT 证书, 所以完全有可能该分区在 `XBL` 阶段会被验证, 如果被修改,会导致设备无法启动。 ``` DECIMAL HEXADECIMAL DESCRIPTION -------------------------------------------------------------------------------- 0 0x0 ELF, 32-bit LSB executable, ARM, version 1 (SYSV) 4096 0x1000 UEFI PI Firmware Volume, volume size: 6291456, header size: 0, revision: 0, EFI Firmware File System v2, GUID: 8C8CE578-8A3D-4F1C-3599-896185C32DD3 4216 0x1078 LZMA compressed data, properties: 0x5D, dictionary size: 16777216 bytes, uncompressed size: 7237640 bytes 6296088 0x601218 Certificate in DER format (x509 v3), header length: 4, sequence length: 596 6296688 0x601470 Certificate in DER format (x509 v3), header length: 4, sequence length: 685 6297377 0x601721 Certificate in DER format (x509 v3), header length: 4, sequence length: 720 ``` 我也没能找到任何用于它的开源(重新)打包工具,因此需要自行开发一个。不过我不想冒变砖的风险。 以下是关于它在 `xiaomi-amethyst` 的 `ABL` 阶段被加载的一些参考: ``` GetAdjustLogoIndexpDisplayInfo->uDisplayWidth 1220: 2712, country_info = 1, uLogoIndex = 0, realLogoIndex = 128! Display_Utils_RenderSplashScreen: load imagefv name is: logo.img LoadCompressedImageFromLogoData: Setvariable Logo Image returned eStatus: Success, LogoMagic: LOGO!!! LoadCompressedImageFromLogoData: LogoCompressedBlockNum:9 LogoCompressedBytesNum:35458 Display_Utils_RenderSplashScreen: CompressedData size is: 35458 logo index = 128 DeCompressLogoData: DecompressBufferSize:9925976 ScratchSize:131072 DeCompressLogoData: logo decompress done, use time: 19ms Display_Utils_RenderSplashScreen: OEM Logo Successfully Loaded ``` ## 要求 - Python 3.10 或更高版本 - 已安装 `uefi_firmware` pip 包
标签:Python, UEFI, 云资产清单, 固件解析, 图片提取, 无后门, 移动设备, 逆向工具, 逆向工程