python解包wxapkg_微信小程序wxapkg解包器c++版(免装py环境 绿色90k)

基于lrdcp大神的py的源码,用mfc写的gui程序,免py环境安装,方便使用。

wxapkg的存储位置:/data/data/com.tencent.mm/MicroMsg/{User}/appbrand/pkg

{User} 为用户的用户名,pkg目录就是微信用于存放小程序和小游戏下载包的位置。

Python代码:

#!/usr/bin/env python2

# lrdcq

# usage python2 unwxapkg.py filename

import sys, os

import struct

class WxapkgFile(object):

nameLen = 0

name = ""

offset = 0

size = 0

if len(sys.argv) < 2:

print 'usage: unwxapkg.py filename'

exit()

with open(sys.argv[1], "rb") as f:

root = os.path.dirname(os.path.realpath(f.name))

name = os.path.basename(f.name) + '_dir'

if len(sys.argv) > 2:

name = sys.argv[2]

#read header

firstMark = struct.unpack('B', f.read(1))[0]

print 'first header mark = ' + str(firstMark)

info1 = struct.unpack('>L', f.read(4))[0]

print 'info1 = ' + str(info1)

indexInfoLength = struct.unpack('>L', f.read(4))[0]

print 'indexInfoLength = ' + str(indexInfoLength)

bodyInfoLength = struct.unpack('>L', f.read(4))[0]

print 'bodyInfoLength = ' + str(bodyInfoLength)

lastMark = struct.unpack('B', f.read(1))[0]

print 'last header mark = ' + str(lastMark)

if firstMark != 0xBE or lastMark != 0xED:

print 'its not a wxapkg file!!!!!'

exit()

fileCount = struct.unpack('>L', f.read(4))[0]

print 'fileCount = ' + str(fileCount)

#read index

fileList = []

for i in range(fileCount):

data = WxapkgFile()

data.nameLen = struct.unpack('>L', f.read(4))[0]

data.name = f.read(data.nameLen)

data.offset = struct.unpack('>L', f.read(4))[0]

data.size = struct.unpack('>L', f.read(4))[0]

print 'readFile = ' + data.name + ' at Offset = ' + str(data.offset)

fileList.append(data)

#save files

for d in fileList:

d.name = '/' + name + d.name

path = root + os.path.dirname(d.name)

if not os.path.exists(path):

os.makedirs(path)

w = open(root + d.name, 'w')

f.seek(d.offset)

w.write(f.read(d.size))

w.close()

print 'writeFile = ' + root + d.name

f.close()

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值