华为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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值