日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網為廣大站長提供免費收錄網站服務,提交前請做好本站友鏈:【 網站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

這篇文章主要介紹了php微信小程序解包過程實例詳解,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下

這個解包只能看個大概

1、找到小程序壓縮包

1.1、手機root或安裝模擬器(我用的是夜神)

1.2、在模擬器上安裝微信(用android5系統的模擬器,低版本小程序容易打不開)

1.3、打開登陸微信后,打開小程序

1.4、打開模擬器自帶的文件管理器來到目錄:/data/data/com.tencent.mm/MicroMsg/{{一串32位的16進制字符串文件夾}}/appbrand/pkg/

1.5、里面有很多wxapkg文件,找到最新修改日期的文件比如 -357038350_91.wxapkg,前面打勾選中

1.6、文件管理器回到/mnt/shared/Other目錄,粘貼即可,打開安卓模擬器上我的電腦 =〉打開電腦文件夾找到粘貼的文件-357038350_91.wxapkg 夜神教程鏈接:跳轉查看

2、對壓縮包解包

詳細參考:https://codechina.csdn.net/mirrors/leo9960/wechat-app-unpack?utm_source=csdn_github_accelerator

我用的php類:

使用方法:cmd =>cd php文件目錄 =〉php wx_unpak.php 357038350_91.wxapkg

我主要是想用其中的一些圖片,很多圖片都被base64了放到js(app-service.js)和樣式(app-wxss.js)文件中了;需要我們匹配組裝一下

<?php
$str = file_get_contents('_-357038350_97.wxapkg.unpacked/app-service.js');
$preg = '/(data:image.*?)\"/';
$len = strlen('data:image/png;base64,');
if(preg_match_all($preg, $str, $arr)){
    foreach($arr[1] as $k => $img){
        file_put_contents('./images/'.$k.'.png',base64_decode(substr($img,$len)));
        //echo substr($img,$len);exit;
    }
} else {
    echo 'no';
}
$str = file_get_contents('_-357038350_97.wxapkg.unpacked/app-wxss.js');
$preg = '/\((data:image.*?)\)/';
$len = strlen('data:image/png;base64,');
if(preg_match_all($preg, $str, $arr)){
    foreach($arr[1] as $k => $img){
        file_put_contents('./images/a2_'.$k.'.png',base64_decode(substr($img,$len)));
        //echo substr($img,$len);exit;
    }
} else {
    echo 'no';
}

wx_unpak.php

<?php
/**
 * 源文件目錄
 * /data/data/com.tencent.mm/MicroMsg/{{一串32位的16進制字符串文件夾}}/appbrand/pkg/
 * /data/data/com.eg.android.AlipayGphone, 在files/nebulaInstallApps/目錄下存儲了所有加載過的小程序
 * [php] /path/to/unpack-wxapkg.php <xxx.wxapkg>
 * php unpak.php _1123949441_351.wxapkg
 **/
function unpack_wxapkg($file, $targetDir)
{
    if (!is_dir($targetDir)){
        mkdir($targetDir);
    }
    echo "Reading file.\n";
    $file = file_get_contents($file);
    $ptr = 18;
    $headerStruct = new StructDef([
        'mask1' => 'ushort',
        'info1' => 'ulong',
        'indexInfoLength' => 'ulong',
        'bodyInfoLength' => 'ushort',
        'mask2' => 'ushort',
        'fileCount' => 'ulong',
    ]);
    echo "Parsing file header...\n";
    $header = $headerStruct->unpack($file);
    // print_r(['header' => $header]);
    $unpackULong = function () use (&$file, &$ptr) {
        $ret = unpack_ulong(substr($file, $ptr, 4));
        $ptr += 4;
        return $ret;
    };
    $unpackUShort = function () use (&$file, &$ptr) {
        $ret = unpack_ushort(substr($file, $ptr, 2));
        $ptr += 2;
        return $ret;
    };
    $unpackStr = function ($len) use (&$file, &$ptr) {
        $ret = substr($file, $ptr, $len);
        $ptr += $len;
        return $ret;
    };
    $fileCount = $header['fileCount'];
    echo "Got $fileCount files.\n";
    $unpackedFiles = [];
    for ($i = 0; $i < $fileCount; $i++) {
        $nameLength = $unpackULong();
        $f = [
            'nameLength' => $nameLength,
            'name' => $unpackStr($nameLength),
            'offset' => $unpackULong(),
            'size' => $unpackULong(),
        ];
        echo "Unpacking file {$f['name']} ({$f['size']}bytes)...\n";
        $f['content'] = substr($file, $f['offset'], $f['size']);
        $unpackedFiles[] = $f;
        $destFile = $targetDir . $f['name'];
        $destDir = dirname($destFile);
        if (!is_dir($destDir)){
            mkdir($destDir, 0777, true);
        }
        file_put_contents($targetDir . $f['name'], $f['content']);
    }
    // print_r(['unpackedFiles' => $unpackedFiles]);
    echo "All done.\n";
}
function unpack_ulong($str)
{
    $x = unpack('N', $str);
    return $x[1];
}
function unpack_ushort($str)
{
    $x = unpack('n', $str);
    return $x[1];
}
class StructDef
{
    protected $def;
    protected $unpackFormat;
    public function __construct($def)
    {
        $this->def = $def;
        $this->unpackFormat = self::convertStructDefToUnpackFormat($def);
    }
    public function unpack($data)
    {
        return unpack($this->unpackFormat, $data);
    }
    protected static function convertStructDefToUnpackFormat($def)
    {
        $defTypeToUnpackType = [
            'byte' => 'C',
            'uchar' => 'C',
            'u8' => 'C',
            'ushort' => 'n',
            'u16' => 'n',
            'ulong' => 'N',
            'u32' => 'N',
        ];
        $ret = [];
        foreach ($def as $key => $type) {
            $ret[] = $defTypeToUnpackType[$type] . $key;
        }
        return implode('/', $ret);
    }
}
$packageFile = $argv[1];
//支持目錄下文件批量解壓
if (is_dir($packageFile)){
    $handle = opendir($packageFile);
    if($handle){
        while(($fl = readdir($handle)) !== false){
            $temp = $packageFile.DIRECTORY_SEPARATOR.$fl;
            //如果不加 $fl!='.' && $fl != '..' 則會造成把$dir的父級目錄也讀取出來
            if(is_file($temp)){
                if($fl!='.' && $fl != '..'){
                    $targetDir = $temp . '.unpacked';
                    unpack_wxapkg($temp, $targetDir);
                }
            }
        }
    } 
}else if (is_file($packageFile)){
    $targetDir = $packageFile . '.unpacked';
    unpack_wxapkg($packageFile, $targetDir);
}else{
    echo <<<HELP
Usage:
  [php] {$argv[0]} <xxx.wxapkg>
  - Unpack the `xxx.wxapkg` to `xxx.wxapkg.unpacked` directory.
HELP;
    exit(1);
}
exit(0);


分享到:
標簽:微信小程序 小程序解包
用戶無頭像

網友整理

注冊時間:

網站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網站吧!
最新入駐小程序

數獨大挑戰2018-06-03

數獨一種數學游戲,玩家需要根據9

答題星2018-06-03

您可以通過答題星輕松地創建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學四六

運動步數有氧達人2018-06-03

記錄運動步數,積累氧氣值。還可偷

每日養生app2018-06-03

每日養生,天天健康

體育訓練成績評定2018-06-03

通用課目體育訓練成績評定