这个解包只能看个大概
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 夜神教程链接:跳转查看
详细参考:/d/file/titlepic/login =>cd php文件目录 =〉php wx_unpak.php 357038350_91.wxapkg
我主要是想用其中的一些图片,很多图片都被ba64了放到js(app-rvice.js)和样式(app-wxss.js)文件中了;需要我们匹配组装一下
<?php$str = file_get_contents('_-357038350_97.wxapkg.unpacked/app-rvice.js');$preg = '/(data:image.*?)\"/';$len = strlen('data:image/png;ba64,');if(preg_match_all($preg, $str, $arr)){ foreach($arr[1] as $k => $img){ file_put_contents('./images/'.$k.'.png',ba64_decode(substr($img,$len))); //echo substr($img,$len);exit; }} el { echo 'no';}$str = file_get_contents('_-357038350_97.wxapkg.unpacked/app-wxss.js');$preg = '/\((data:image.*?)\)/';$len = strlen('data:image/png;ba64,');if(preg_match_all($preg, $str, $arr)){ foreach($arr[1] as $k => $img){ file_put_contents('./images/a2_'.$k.'.png',ba64_decode(substr($img,$len))); //echo substr($img,$len);exit; }} el { 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 () u (&$file, &$ptr) { $ret = unpack_ulong(substr($file, $ptr, 4)); $ptr += 4; return $ret; }; $unpackushort = function () u (&$file, &$ptr) { $ret = unpack_ushort(substr($file, $ptr, 2)); $ptr += 2; return $ret; }; $unpackstr = function ($len) u (&$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), 'offt' => $unpackulong(), 'size' => $unpackulong(), ]; echo "unpacking fi红枫林le {$f['name']} ({$f['size']}bytes)...\n"; $f['content'] = substr($file, $f['offt'], $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_ulon我要成功g($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 = lf::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)) !== fal){ $temp = $packagefile.directory_parator.$fl; //如果不加 $fl!='.' && $fl != '..' 则会造成把$dir的父级目录也读取出来 if(is_file($temp)){ if($fl!='.' && $fl != '..'){ $targetdir = $temp . '.unpacked'; unpack_wxapkg($temp, $targetdir); } } } } }el if (is_file($packagefile)){ $targetdir = $packagefile . '.unpacked'; unpack_wxapkg($packagefile, $targetdir);}el{ echo <<<helpusage: [php] {$argv[0]} <xxx.wxapkg> - unpack the `xxx.wxapkg` to `xxx.wxapkg.unpacked` directory.help; exit(1);}exit(0);到此这篇关于php微信小程序解包的文章就介绍到这了,更多相关php微信小程序解包内容请搜索www.887551.com以前的文章或继续浏览下面的相关文章希望大家以后多多支持www.887551.com!
本文发布于:2023-04-09 02:29:41,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/b11efe4e9f68b8e1ff2b71d5a163b6fa.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:php微信小程序解包过程实例详解.doc
本文 PDF 下载地址:php微信小程序解包过程实例详解.pdf
| 留言与评论(共有 0 条评论) |