一个用 Go 编写的 Android OTA 有效载荷抽取器
An android OTA payload dumper written in Go.
See how fast payload-dumper-go is: https://imgur.com/a/X6HKJT4. (MacBook Pro 16-inch 2019 i9-9750H, 16G)
-old), bit-exact output.github.com/ssut/payload-dumper-go/payload)xz. (The reason I didn't use the pure Go implementation is written in the Performance section below.)PUFFDIFF, ZUCCHINI and LZ4DIFF_* delta operations are not supported yet. Affected partitions (usually only system/product/system_ext) fail with a clear error; extract the rest with -p.chmod +x payload-dumper-go
export PATH=$PATH:/path/to/payload-dumper-go
Note: This command sets the PATH environment variable only for the current terminal session. To make it permanent, you need to add the command to your system's profile file (e.g. .bashrc or .zshrc for Linux/Unix systems).
Just simply run:
$ brew install payload-dumper-go
Run the following command in your terminal:
payload-dumper-go /path/to/payload.bin
The input can be a raw payload.bin or an OTA zip, detected by content.
Options:
-c, -concurrency Number of workers to extract concurrently (default: number of CPUs)
-l, -list Show list of partitions in payload.bin
-o, -output Set output directory
-p, -partitions Dump only selected partitions (comma-separated)
-old Directory with base images, required for incremental OTA
-q, -quiet Quiet mode - suppress non-essential output
-m, -machine-readable Machine-readable output format
-no-verify Skip sha256 verification
Extract the base (previous) full OTA first, then pass it via -old:
payload-dumper-go -o base_images base_full_ota.zip
payload-dumper-go -old base_images -o new_images incremental_ota.zip
import "github.com/ssut/payload-dumper-go/payload"
p, _ := payload.Open("ota.zip")
defer p.Close()
err := p.Extract(context.Background(), payload.ExtractOptions{
OutputDir: "out",
SourceDir: "base_images",
})
Machine: MacBook Pro 16-inch 2021 (Apple M1 Max, 64G), OS: macOS Sonoma 14.5, Go: 1.22.4.
Tested with a 2.31GB payload.bin file from https://developers.google.com/android/ota (akita).
…
The pure Go implementation of xz is very slow compared to the C implementation used with CGO. Here's the result with the same payload.bin file on the same conditions:
…
As you can see, the pure Go implementation is about 6~ times slower than the C implementation.
https://android.googlesource.com/platform/system/update_engine/+/master/update_metadata.proto
This source code is licensed under the Apache License 2.0 as described in the LICENSE file.