首页 > 其他分享 >【日常记录】解包android vendor_boot.img和vendor_boot-debug.img

【日常记录】解包android vendor_boot.img和vendor_boot-debug.img

时间:2024-11-07 09:59:15浏览次数:1  
标签:vendor img -- boot bootimg unpack

查看文件类型:

$ file vendor_boot.img
vendor_boot.img: data
$ file vendor_boot-debug.img
vendor_boot-debug.img: data

unpack_bootimg用法:

$ ./unpack_bootimg -h
usage: unpack_bootimg [-h] --boot_img BOOT_IMG [--out OUT] [--format {info,mkbootimg}] [-0]

Unpacks boot, recovery or vendor_boot image.

options:
  -h, --help            show this help message and exit
  --boot_img BOOT_IMG   path to the boot, recovery or vendor_boot image
  --out OUT             output directory of the unpacked images
  --format {info,mkbootimg}
                        text output format (default: info)
  -0, --null            output null-terminated argument strings

Output format:

  * info

    Pretty-printed info-rich text format suitable for human inspection.

  * mkbootimg

    Output shell-escaped (quoted) argument strings that can be used to
    reconstruct the boot image. For example:

    $ unpack_bootimg --boot_img vendor_boot.img --out out --format=mkbootimg |
        tee mkbootimg_args
    $ sh -c "mkbootimg $(cat mkbootimg_args) --vendor_boot repacked.img"

    vendor_boot.img and repacked.img would be equivalent.

    If the -0 option is specified, output unescaped null-terminated argument
    strings that are suitable to be parsed by a shell script (xargs -0 format):

    $ unpack_bootimg --boot_img vendor_boot.img --out out --format=mkbootimg \
        -0 | tee mkbootimg_args
    $ declare -a MKBOOTIMG_ARGS=()
    $ while IFS= read -r -d '' ARG; do
        MKBOOTIMG_ARGS+=("${ARG}")
      done <mkbootimg_args
    $ mkbootimg "${MKBOOTIMG_ARGS[@]}" --vendor_boot repacked.img

unpack vendor_boot.img

bin$ ./unpack_bootimg --boot_img ../vendor_boot.img --out ../vendor_boot
boot magic: VNDRBOOT
vendor boot image header version: 4
page size: 0x00001000
kernel load address: 0x00008000
ramdisk load address: 0x01000000
vendor ramdisk total size: 8479036
vendor command line args: video=vfb:640x400,bpp=32,memsize=3072000 bootconfig buildvariant=userdebug
kernel tags load address: 0x00000100
product name:
vendor boot image header size: 2128
dtb size: 3046854
dtb address: 0x0000000001f00000
vendor ramdisk table size: 108
vendor ramdisk table: [
    vendor_ramdisk00: {
        size: 8479036
        offset: 0
        type: 0x1
        name:
        board_id: [
            0x00000000, 0x00000000, 0x00000000, 0x00000000,
            0x00000000, 0x00000000, 0x00000000, 0x00000000,
            0x00000000, 0x00000000, 0x00000000, 0x00000000,
            0x00000000, 0x00000000, 0x00000000, 0x00000000,
        ]
    }
]
vendor bootconfig size: 124

unpack之后vendor_boot目录:

vendor_boot$ ls
bootconfig  dtb  vendor-ramdisk-by-name  vendor_ramdisk  vendor_ramdisk00
vendor_boot$ file *
bootconfig:             ASCII text
dtb:                    Device Tree Blob version 17, size=224217, boot CPU=0, string block size=21729, DT structure block size=202432
vendor-ramdisk-by-name: directory
vendor_ramdisk:         LZ4 compressed data (v0.1-v0.9)
vendor_ramdisk00:       LZ4 compressed data (v0.1-v0.9)
vendor_boot$ ll
total 19560
drwxr-xr-x 3    4096 Nov  7 09:07 ./
drwxr-xr-x 5    4096 Nov  7 09:07 ../
-rw-r--r-- 1     124 Nov  7 09:07 bootconfig
-rw-r--r-- 1 3046854 Nov  7 09:07 dtb
drwxr-xr-x 2    4096 Nov  7 09:07 vendor-ramdisk-by-name/
-rw-r--r-- 1 8479036 Nov  7 09:07 vendor_ramdisk
-rw-r--r-- 1 8479036 Nov  7 09:07 vendor_ramdisk00

LZ4解压缩vendor_ramdisk(LZ4 compressed data):

lz4解压缩命令:

lz4 -d file.lz4 output_file

实际使用命令:

vendor_boot$ lz4 -d vendor_ramdisk vendor_ramdisk.cpio
vendor_ramdisk                 : decoded 28476928 bytes
vendor_boot$ ll
total 47220
drwxr-xr-x 3     4096 Nov  7 09:22 ./
drwxr-xr-x 6     4096 Nov  7 09:18 ../
-rw-r--r-- 1      124 Nov  7 09:07 bootconfig
-rw-r--r-- 1  3046854 Nov  7 09:07 dtb
drwxr-xr-x 2     4096 Nov  7 09:07 vendor-ramdisk-by-name/
-rw-r--r-- 1  8479036 Nov  7 09:07 vendor_ramdisk
-rw-r--r-- 1 28476928 Nov  7 09:07 vendor_ramdisk.cpio
-rw-r--r-- 1  8479036 Nov  7 09:07 vendor_ramdisk00

解压vendor_ramdisk.cpio:

vendor_boot$ mkdir vendor_boot_out
vendor_boot$ cd vendor_boot_out/
vendor_boot_out$ cpio -idmv < ../vendor_ramdisk.cpio
first_stage_ramdisk
first_stage_ramdisk/fstab.default
first_stage_ramdisk/fstab.emmc
lib
lib/modules
lib/modules/altmode-glink.ko
lib/modules/arm_smmu.ko
//.........
lib/modules/usb_f_ccid.ko
lib/modules/usb_f_cdev.ko
lib/modules/usb_f_diag.ko
lib/modules/usb_f_gsi.ko
lib/modules/usb_f_qdss.ko
lib/modules/usbpd.ko
55619 blocks
vendor_boot_out$ tree
.
├── first_stage_ramdisk
│   ├── fstab.default
│   └── fstab.emmc
└── lib
    └── modules
        ├── altmode-glink.ko
        ├── arm_smmu.ko
        ├── atomic64_test.ko
        ├── bam_dma.ko
        ├── bcl_pmic5.ko
        ├── bcl_soc.ko
        ├── boot_stats.ko
        |//..............................

同样方法unpack vendor_boot-debug.img:

vendor_boot-debug-out$ tree
.
├── adb_debug.prop
├── first_stage_ramdisk
│   ├── fstab.default
│   └── fstab.emmc
├── force_debuggable
├── lib
│   └── modules
│       ├── altmode-glink.ko
│       ├── arm_smmu.ko
│       ├── atomic64_test.ko
│       ├── bam_dma.ko
│       ├── bcl_pmic5.ko
│       ├── bcl_soc.ko
//.........................................
│       ├── usb_f_ccid.ko
│       ├── usb_f_cdev.ko
│       ├── usb_f_diag.ko
│       ├── usb_f_gsi.ko
│       ├── usb_f_qdss.ko
│       └── usbpd.ko
└── userdebug_plat_sepolicy.cil

3 directories, 252 files

其他:

WSL中安装lz4失败及解决:

没有lz4:

vendor_boot$ lz
lzcat     lzdiff    lzfgrep   lzless    lzmainfo
lzcmp     lzegrep   lzgrep    lzma      lzmore

install error:

vendor_boot$ sudo apt-get install lz4
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package lz4 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'lz4' has no installation candidate

下载源码并编译安装:

源码地址:https://github.com/lz4/lz4

编译并安装:

lz4-dev$ make
compiling static library
compiling dynamic library 1.10.0
creating versioned links
creating pkgconfig
==> building with multithreading support
lz4 build completed
lz4-dev$ sudo make install
Installing libraries in /usr/local/lib
Installing headers in /usr/local/include
lz4 libraries installed
Installing binaries in /usr/local/bin
Installing man pages in /usr/local/share/man/man1
lz4 installation completed
vendor_boot$ lz
lz4       lz4cat    lzcmp     lzegrep   lzgrep    lzma      lzmore
lz4c      lzcat     lzdiff    lzfgrep   lzless    lzmainfo

关于unpack_bootimg:

来自于高通代码的out目录:out/target/product/device_name/obj/PACKAGING/otatools_intermediates/otatools/bin

out/target/product/device_name/obj/PACKAGING/otatools_intermediates/otatools/bin$ ls
aapt2                    bsdiff                         debugfs_static   generate_gki_certificate  make_f2fs_casefold  mksquashfsimage.sh     signapk                 verity_signer
add_img_to_target_files  build_image                    defrag.f2fs      generate_verity_key       merge_target_files  mkuserimg_mke2fs       sign_target_files_apks  verity_verifier
apex_compression_tool    build_super_image              delta_generator  host_init_verifier        merge_zips          ota_extractor          sign_virt_apex          zip2zip
apexer                   build_verity_metadata          dump.f2fs        img2simg                  minigzip            ota_from_target_files  simg2img                zipalign
apksigner                build_verity_tree              e2fsck           imgdiff                   mkbootfs            repack_bootimg         sload_f2fs              zucchini
append2simg              care_map_generator             e2fsdroid        img_from_target_files     mkbootimg           resize2fs              soong_zip
avbtool                  check_ota_package_signature    fc_sort          lib                       mke2fs              resize.f2fs            toybox
blk_alloc_to_base_fs     check_target_files_signatures  fec              lpmake                    mke2fs.conf         secilc                 tune2fs
boot_signer              check_target_files_vintf       fsck.erofs       lpunpack                  mkf2fsuserimg.sh    sefcontext_compile     unpack_bootimg
brillo_update_payload    checkvintf                     fsck.f2fs        lz4                       mkfs.erofs          sgdisk                 update_host_simulator
brotli                   deapexer                       fs_config        make_f2fs                 mksquashfs          sign_apex              validate_target_files

实际上这里也有:out/host/linux-x86/bin/unpack_bootimg

out/host/linux-x86/bin$ ./unpack_bootimg -h
usage: unpack_bootimg [-h] --boot_img BOOT_IMG [--out OUT] [--format {info,mkbootimg}] [-0]

Unpacks boot, recovery or vendor_boot image.

options:
  -h, --help            show this help message and exit
  --boot_img BOOT_IMG   path to the boot, recovery or vendor_boot image
  --out OUT             output directory of the unpacked images
  --format {info,mkbootimg}
                        text output format (default: info)
  -0, --null            output null-terminated argument strings

Output format:

  * info

    Pretty-printed info-rich text format suitable for human inspection.

  * mkbootimg

    Output shell-escaped (quoted) argument strings that can be used to
    reconstruct the boot image. For example:

    $ unpack_bootimg --boot_img vendor_boot.img --out out --format=mkbootimg |
        tee mkbootimg_args
    $ sh -c "mkbootimg $(cat mkbootimg_args) --vendor_boot repacked.img"

    vendor_boot.img and repacked.img would be equivalent.

    If the -0 option is specified, output unescaped null-terminated argument
    strings that are suitable to be parsed by a shell script (xargs -0 format):

    $ unpack_bootimg --boot_img vendor_boot.img --out out --format=mkbootimg \
        -0 | tee mkbootimg_args
    $ declare -a MKBOOTIMG_ARGS=()
    $ while IFS= read -r -d '' ARG; do
        MKBOOTIMG_ARGS+=("${ARG}")
      done <mkbootimg_args
    $ mkbootimg "${MKBOOTIMG_ARGS[@]}" --vendor_boot repacked.img

编译log:

    行 61608: [ 61% 49653/81155] //system/tools/mkbootimg:unpack_bootimg python library archive [linux_glibc]
    行 61639: [ 61% 49684/81155] //system/tools/mkbootimg:unpack_bootimg embedded python archive [linux_glibc]
    行 61658: [ 61% 49703/81155] host Prebuilt: unpack_bootimg (out/host/linux-x86/obj/EXECUTABLES/unpack_bootimg_intermediates/unpack_bootimg)
    行 61658: [ 61% 49703/81155] host Prebuilt: unpack_bootimg (out/host/linux-x86/obj/EXECUTABLES/unpack_bootimg_intermediates/unpack_bootimg)
    行 61658: [ 61% 49703/81155] host Prebuilt: unpack_bootimg (out/host/linux-x86/obj/EXECUTABLES/unpack_bootimg_intermediates/unpack_bootimg)
    行 61673: [ 61% 49718/81155] Install out/host/linux-x86/bin/unpack_bootimg

本次实验目录介绍:

unpack$ tree -L 1
.
├── bin  //unpack_bootimg所在目录
├── gki
├── lz4-dev //lz4源码包
├── lz4-dev.zip
├── lz4-dev.zip:Zone.Identifier
├── vendor_boot //unpack_bootimg vendor_boot.img的out目录,lz4及解包后的cpio以及最终目录都放在此处
├── vendor_boot-debug //同上,vendor_boot-debug.img的解包中间文件及结果
├── vendor_boot-debug.img //看名字
└── vendor_boot.img  //看名字

5 directories, 4 files

 

标签:vendor,img,--,boot,bootimg,unpack
From: https://www.cnblogs.com/xiululu/p/18531580

相关文章

  • springboot+vue新闻微信小程序 毕业设计源码06401
    摘要在数字化浪潮的推动下,我们紧跟时代步伐,借助SpringBoot强大的后端开发能力和Vue.js前端框架的灵活性,结合微信小程序的广泛用户基础,精心打造了一款新颖的新闻微信小程序。这款小程序不仅提供了实时、便捷的新闻资讯服务,还通过其用户友好的界面和丰富的社交功能,为用户带......
  • 基于springboot框架在线生鲜商城推荐系统 java实现个性化生鲜/农产品购物商城推荐网站
    基于springboot框架在线生鲜商城推荐系统java实现个性化生鲜/农产品购物商城推荐网站爬虫、数据分析、排行榜基于协同过滤算法推荐、基于流行度热点推荐、平均加权混合推荐机器学习、大数据、深度学习OnlineShopRecommendEx一、项目简介1、开发工具和使用技术IDEA,jdk......
  • SpringBoot获取文件将要上传的IP地址
    说明:有的项目会涉及文件上传,比如“更换logo业务”,或者“自定义任务上传脚本等业务”都会涉及上传,而有的项目上传成功后找不到上传地址,所以需要打印IP,方便用户知晓上传的精确地址,下面封装了一个IPv4工具类(因为是拷贝现成代码其中会有某些参数未注释,不知道啥意思,敬请谅解!)IPv4......
  • 基于SpringBoot+Vue的名城小区物业管理系统设计与实现毕设(文档+源码)
            目录一、项目介绍二、开发环境三、功能介绍四、核心代码五、效果图六、源码获取:        大家好呀,我是一个混迹在java圈的码农。今天要和大家分享的是一款基于SpringBoot+Vue的名城小区物业管理系统,项目源码请点击文章末尾联系我哦~目前有各类......
  • 个人练习前端技术使用Bootstrap、JQuery、thymeleaf
    说明:本代码只是为了本人练习前后端联动技术,包含html,jquery,thymeleaf模板、ajax请求及后端功能联动,方便自己查找及使用。@目录代码场景场景1.table批量查询功能(有默认值),点击"查询最新数据"从后台查询覆盖默认显示的数据场景2.新增,点击“新建”显示form表单,提交成功后隐藏form表......
  • 七、Spring Boot集成Spring Security之前后分离认证最佳实现
    一、SpringBoot集成SpringSecurity专栏一、SpringBoot集成SpringSecurity之自动装配二、SpringBoot集成SpringSecurity之实现原理三、SpringBoot集成SpringSecurity之过滤器链详解四、SpringBoot集成SpringSecurity之认证流程五、SpringBoot集成SpringSecu......
  • 109 基于springboot+vue校内店铺网上订单小程序
    项目介绍校内店铺网上订单小程序分为客户端和服务端登录模块,客户端主要是用户进行登录,用户在校内店铺网上订单小程序中进行注册、登录,可以修改个人信息,还可以查看商品信息,对商品信息进行收藏、评论、立即订购、加入购物车等操作。管理员在服务端可以修改个人信息和密码,可以......
  • 基于微信小程序的智慧停车系统设计与实现(源码+springboot+uinapp+部署文档+讲解等)
    收藏关注不迷路!!......
  • 2025最新-计算机毕业设计java基于Springboot的智慧教学平台的系统设计与实现
    一、项目介绍  基于SpringBoot的智慧教学平台系统设计与实现是一个复杂但充满挑战的项目,旨在通过现代软件开发技术优化教育流程,提升教学质量和管理效率。以下是对该系统的详细介绍:智慧教学平台是一款集成了多种功能的综合性教育管理系统,通过运用SpringBoot框架、MySQ......
  • 基于SpringBoot+Vue的学生档案管理系统(源码+LW+调试文档+讲解)
    背景及意义目的档案信息整合与存储:基于SpringBoot+Vue的学生档案管理系统,目的是将学生的各类档案信息进行整合和存储。包括学生的个人基本信息(姓名、性别、出生日期、民族、籍贯等)、学业信息(入学成绩、每学期各科成绩、考试排名、奖惩情况等)、家庭背景信息(家庭成员、......