美文网首页
微信小程序源码提取

微信小程序源码提取

作者: 灰斗儿 | 来源:发表于2020-04-28 14:35 被阅读0次

    流程

    1. 安卓手机安装微信,并下载对应小程序打开
    2. 进入微信文件目录,提取.wxapkg 文件
    3. 使用wxapkg工具解包

    安装adb及链接mumu模拟器

    brew cask install android-platform-tools

    【win版】
    adb connect 127.0.0.1:7555
    adb shell

    【mac版】

    adb kill-server && adb server && adb shell

    提取

    $adb connect 127.0.0.1:5555
    $ adb devices
    List of devices attached
    127.0.0.1:5555  offline
    emulator-5554   device
    
    $ adb -s emulator-5554 shell
    root@x86:/ # cd /data/data/com.tencent.mm/MicroMsg/f53075a62982bc3092e95c9fe1e1531a/appbrand/pkg
    FaiWongdeMacBook-Pro:~ faiwong$ adb -s emulator-5554 pull /data/data/com.tencent.mm/MicroMsg/f53075a62982bc3092e95c9fe1e1531a/appbrand/pkg
    
    

    f53075a62982bc3092e95c9fe1e1531a为微信为每个用户创建的独立文件夹, 进入MicroMsg逐个寻找。

    解包

    这里是python3 运行环境

    # unwxapkg.py
    # coding: utf-8
    # py2 origin author lrdcq
    # usage python3 unwxapkg.py filename
    
    __author__ = 'Integ: https://github.com./integ'
    
    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 [output_dir]')
        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 = {}'.format(firstMark))
    
        info1 = struct.unpack('>L', f.read(4))[0]
        print('info1 = {}'.format(info1))
    
        indexInfoLength = struct.unpack('>L', f.read(4))[0]
        print('indexInfoLength = {}'.format(indexInfoLength))
    
        bodyInfoLength = struct.unpack('>L', f.read(4))[0]
        print('bodyInfoLength = {}'.format(bodyInfoLength))
    
        lastMark = struct.unpack('B', f.read(1))[0]
        print('last header mark = {}'.format(lastMark))
    
        if firstMark != 0xBE or lastMark != 0xED:
            print('its not a wxapkg file!!!!!')
            f.close()
            exit()
    
        fileCount = struct.unpack('>L', f.read(4))[0]
        print('fileCount = {}'.format(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 = {} at Offset = {}'.format(str(data.name, encoding = "utf-8"), data.offset))
    
            fileList.append(data)
    
        #save files
        for d in fileList:
            d.name = '/' + name + str(d.name, encoding = "utf-8")
            path = root + os.path.dirname(d.name)
    
            if not os.path.exists(path):
                os.makedirs(path)
    
            w = open(root + d.name, 'wb')
            f.seek(d.offset)
            w.write(f.read(d.size))
            w.close()
    
            print('writeFile = {}{}'.format(root, d.name))
    
        f.close()
    
    

    usage: python unwxapkg.py ./_111122233.wxapkg

    相关文章

      网友评论

          本文标题:微信小程序源码提取

          本文链接:https://www.haomeiwen.com/subject/zybvwhtx.html