华为p6官方固件包UPDATE.APP解包

华为官方固件包UPDATE.APP解包,大多依靠一个perl语言脚本split_updata.pl。JoeyJiao的split_updata.pl最新版本,可以解开华为p6的包,但文件名识别不了。源码地址:https://github.com/JoeyJiao/split_updata.pl

找到一个python版本的,可以解包并精确给出文件名。原始为python2版本,自行小修改成python3版本。

代码源自scue及jnjn,原始代码看这里:http://jnjn.blog.163.com/blog/static/275999382013311515491/

修改版如下:

#!/usr/bin/env python
# Version: 0.2.201308040830
# Author: linkscue
# Function: unpack any hauwei honor2 Update.app
# Thanks to McSpoon(zhaoxing-go@163.com)
# 20130411: Modified for alignment to 4 byte boundary by jnjn@163.com
# 20130804: Modified for python3 by atuo @ oschina.net

import os
import sys
import struct
from functools import reduce

print("Usage: unpack $huawei_app_file")
try:
    sys.argv[1]
except IndexError:
        File="UPDATE.APP"
else:
    File=sys.argv[1];

verify_code=0xa55aaa55
verify_bin=struct.pack("I",verify_code)

print("I: unpack",File)
f=open(File,'rb')
cont=f.read()
f.close()

start=0
sub_file=1
search=verify_bin
while True:
    index = cont.find(search, start)
    if index == -1:
        break

    if ((index) % 4  != 0 ):
    	print("skipping a 55aa5aa5 at offset: 0x%08x\n" % (index))
    	start = index + 1
    else:
	    packet_addr=cont[index+4:index+8]
	    data_addr=cont[index+24:index+28]
	    img_name=cont[index+60:index+76]
	    packet_size_tuple=struct.unpack("I",packet_addr)
	    data_size_tuple=struct.unpack("I",data_addr)
	    packet_size=int(reduce(lambda rst, d: rst * 10 + d, packet_size_tuple))
	    data_size=int(reduce(lambda rst, d: rst * 10 + d, data_size_tuple))
	    temp=cont[index+packet_size:index+packet_size+data_size]
	    filename=str(sub_file)+'_'+img_name.strip(b'\x00').decode('ascii')+'.img'
	    print( "%2d I: verify code found at: 0x%08x, size: %10d bytes, --> %-20s" \
	    % (sub_file,index,data_size,filename) )
	    f1=open(filename,'wb')
	    f1.write(temp)
	    f1.close()
	    start = index + 1
	    sub_file += 1



转载于:https://my.oschina.net/u/947271/blog/149911

非常威猛的官方固件UPDATE.APP解包工具(转自XDA论坛) Huawei Update Extractor After messing around a bit with the perl tools available for extracting Huawei update.app files, i got the idea to create an own (windows) tool. Requirements .Net Framework 3.5 Install Extract the content of the zip to a folder somewhere on your system. Execute HuaweiUpdateExtractor.exe I'm planning to create an installer sometime. Usage Press the browse (...) button and select an update.app file. Select a device or unknown and press on the open button. You'll see the content of the update.app file in the listview. Select one or more files and right click. Choose Extract selected from the context menu. Choose the ouput folder and press ok. Or just right click on the list and select Extract all, choose the output folder again and press ok. Press close on the extract window. You can sort the list on sequence, filename and size. Just press on the desired column header. Command line: HuaweiUpdateExtractor extract input output [profile] HuaweiUpdateExtractor repack input output profile Profile The profiles.xml file is used to identify the files in the update.app file. Every file in the update.app has a sequence or type, which is also shown in the list. Those sequences or types are used to identify the file/device partition. Example: system.img recovery.img baseband.img version.txt splash.raw565 boot.img cust.img userdata.img signature crc system.img cache.img cust.img userdata.img modemimage.img boot.img recovery.img signature crc - Root tag of the xml file. - Identifies a device - attribute name: name of the device - attribute author: author of the device - File root tag - Identifies a file - attribute sequence: sequence of the file in update.app - attribute type: type of the file in the update.app - attribute partition: destination partition on the device - attribute signature: used to identify the signature file - attribute checksum: used to identify the checksum file - value: file name You can add or edit devices. If you want them to integrate in newer version, pm 'em to me. I'm gonna make some auto update for the device file somewhere in the future Roadmap - You tell me ... Credits ZeBadger (zebadger@hotmail.com) for figuring out the file headers S34Qu4K3 for the P6 partition layout ngamyarthar for adding ALOT of devices! Changelog
含boot.exe huawei C8800 root工具 Android平台ROM的定制及精简教程.pdf signapk.jar 等等 2010.11.02.2更新 0. 添加crc校验,目前是关闭,只有在debug方式解开updata.app时才启用 (--unpack-updata UPDATA.APP debug) 1. 修复windows系统下系统目录符号\与linux下系统目录符号/不一致的情况,感谢cgw233@gmial.com提交bug 2010.11.02更新: 0. 修复unyaffs在windows下的文件打开模式bug,感谢cgw233@gmial.com提交bug 1. 添加注释 2. 代码兼容2.4, 2.5. 2.6, 2.7至3.0, 3.1 3. 增加对565文件的解析 以上内容请运行,看参数提示即可,基本改变不大。 unpack-yafffs, unpack-yaffs2, unpack-yaffs功能完全一致。 由于之前拼写错误,把yaffs文件系统弄成了yafffs,而这个版本实际是版本2,所以这几个都支持。 2010.10.27更新: 1. 添加解开及生成rle格式 2. 修订bootimg格式 工具主要语言为python,分两处版本,源文件及windows下可执行文件exe,内容及用法完全一致。 运行方法: bootimg.py 功能 参数 目前支持以下功能: --repack-ramdisk, 生成 ramdisk --unpack-ramdisk, 解开 ramdisk --repack-bootimg, 生成 bootimg (括boot.img及recovery.img) --unpack-bootimg, 解开 bootimg --unpack-updata, 解开 updata --unpack-yafffs, 解开 yafffs --unpack-rle, 解开rle,生成raw格式及png图片(如果pil可用, exe里有pil) --repack-rle, 生成rle,可支持多种格式 下面一一说明功能中的参数。 --unpack-updata [文件] [文件]为空时,默认使用UPDATA.APP 解开后,会有四个文件,boot.img, recovery.img, system.img, userdata.img 这些都是刷机时可能需要的。 --unpack-bootimg [文件] [文件]为空时,默认使用boot.img 解开后,会有两个文件,kernel和ramdisk.gz 同时,注意输出,比如base, cmdline, name等等 --repack-bootimg [base] [cmdline] [base]为空时,使用0x200000 (C8600默认) [cmdline]为空时,使用mem=211 console=null androidboot.hardware=qcom (c8600适用) 生成bootimg时,会使用kernel和ramdisk.gz(如果存在ramdisk.cpio.gz,优先使用),生成boot.img 更新: --repack-bootimg [base] [cmdline] [page_size] [padding_header] [padding_kernel] [padding_ramdisk] 具体的参数请在注意unpack时的原始参数。 2010.10.27更新 --repack-bootimg [base] [cmdline] [page_size] [padding_size] 有关padding_size请参看unpack-bootimg时的结果,c8600默认为4096字节 --unpack-ramdisk [文件] [目录] [文件]为空时,使用ramdisk.gz [目录]为空时,使用initrd, (请保证这个目录不存在) 输出:cpiolist.txt, initrd目录下的文件 --repack-ramdisk [cpiolist] [cpiolist]为空时,读取cpiolist.txt 根据cpiolist.txt生成ramdisk.cpio.gz cpiolist.txt格式 1). 文件 file 目标系统路径 当前系统路径 目标系统权限 2). 目录 dir 目录系统路径 目录系统权限 3). 软链接 slink 目录系统路径 链接路径 目标系统权限 --unpack-yafffs [文件] [目录] [文件]为空时,使用userdata.img (呃,这个比system.img小) [目录]为空时,使用文件除.img外的其它内容,比如userdata.img时使用userdata 注:目录必须不存在 将把文件解开到目录下去 注:windows系统不支持软链接和硬链接,可能会报警告信息 --unpack-rle [rle] [raw] 2010.10.27版本新增 如果有pil模块,将生成png,目前仅支持320x480 --repack-rle [raw] [rle] 2010.10.27版本新增 如果有pil模块,raw可以是任何图片格式。 已经测试的有jpg, png等等。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值