文档章节

反编译wxapkg过程记录

dhlsoft
 dhlsoft
发布于 2018/01/18 16:35
字数 2687
阅读 3490
收藏 2

wxapkg解包工具有很多,文本附上python3的解包工具,其他可以上github上搜索

# 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()

 

解包出来的文件路径

-\pages  每个页面的wxss样式文件

-app-config.json  页面配置的汇总(app.json+各个页面的配置文件)

-app-service.js 源码js的汇总   直接格式化看就行

-page-frame.html wxml文件的汇总

主要处理page-frame.html文件,需要修改里面的部分代码,修改代码如下:

添加wxml 输出方法:

function forwxml(raw){
    var str="";
    for(var i in raw){
        if(i=="tag"){
            if(raw[i]!="virtual"){
                str+="<"+raw[i];
            }
            if(raw["wx:for-items"]!=undefined){
                str+=" wx:for-items=\""+raw["wx:for-items"]+"\"";
            }
            if(raw["wx:key"]!=undefined){
                str+=" wx:key=\""+raw["wx:key"]+"\"";
            }
            if(raw["attr"]!=undefined){
                for(var j in raw["attr"]){
                    str+=" "+j+"=\""+raw["attr"][j]+"\"";
                }
            }
            if(raw[i]!="virtual"){
                str+=">";
            }
            if(raw["children"]!=undefined){
                
                for(var k in raw["children"]){
                    if(typeof(raw["children"][k])=="object"){
                        str+=forwxml(raw["children"][k]);
                    }else{
                        str+=raw["children"][k];
                    }
                }
            }
            if(raw[i]!="virtual"){
                str+="</"+raw[i]+">";
            }
        }
    }
    return str;
}

修改如下的方法:

 function _v(k) {
          if (typeof(k) != 'undefined') return {
            tag: 'block',
            'wx:for-items': k,
            children: []
          };
          return {
            tag: 'virtual',
            children: []
          };
        }

 

function _n(tag) {
          $gwxc++;
          if ($gwxc >= 16000) {
            throw 'Dom limit exceeded, please check if there\'s any mistake you\'ve made.'
          };
          return {
            tag: 'wx-' + tag,
            attr: {},
            children: [],
            n: [],
            raw: {},
            generics: {}
          }
        }
       function $gwrt(should_pass_type_info) {
          function ArithmeticEv(ops, e, s, g, o) {
            var _f = false;
            var rop = ops[0][1];
            var _a, _b, _c, _d, _aa, _bb;
            switch (rop) {
            case '?:':
              _a = rev(ops[1], e, s, g, o, _f);
              _c = should_pass_type_info && (wh.hn(_a) === 'h');
              _d = wh.rv(_a) ? rev(ops[2], e, s, g, o, _f) : rev(ops[3], e, s, g, o, _f);
              _d = _c && wh.hn(_d) === 'n' ? wh.nh(_d, 'c') : _d;
              //return _d;
              if (typeof(_a) != "boolean" && typeof(_a) != "number" && _a != "") {
                _a = _a.replace("{{", "").replace("}}", "");
              }
              return "{{" + _a + "?'" + rev(ops[2], e, s, g, o) + "':'" + rev(ops[3], e, s, g, o) + "'}}";

              break;
            case '&&':
              _a = rev(ops[1], e, s, g, o, _f);
              _c = should_pass_type_info && (wh.hn(_a) === 'h');
              _d = wh.rv(_a) ? rev(ops[2], e, s, g, o, _f) : wh.rv(_a);
              _d = _c && wh.hn(_d) === 'n' ? wh.nh(_d, 'c') : _d;
              //return _d;

              if (typeof(_a) != "boolean" && typeof(_a) != "number" && _a != "") {
                _a = _a.replace("{{", "").replace("}}", "");
              }
              _b = rev(ops[2], e, s, g, o);
              if (typeof(_b) != "boolean" && typeof(_b) != "number" && _b != "") {
                _b = _b.replace("{{", "").replace("}}", "");
              }
              return _a + "&&" + _b;

              break;
            case '||':
              _a = rev(ops[1], e, s, g, o, _f);
              _c = should_pass_type_info && (wh.hn(_a) === 'h');
              _d = wh.rv(_a) ? wh.rv(_a) : rev(ops[2], e, s, g, o, _f);
              _d = _c && wh.hn(_d) === 'n' ? wh.nh(_d, 'c') : _d;
              //return _d;
              if (typeof(_a) != "boolean" && typeof(_a) != "number" && _a != "") {
                _a = _a.replace("{{", "").replace("}}", "");
              }
              _b = rev(ops[2], e, s, g, o);
              if (typeof(_b) != "boolean" && typeof(_b) != "number" && _b != "") {
                _b = _b.replace("{{", "").replace("}}", "");
              }
              return _a + "||" + _b;

              break;
            case '+':
            case '*':
            case '/':
            case '%':
            case '|':
            case '^':
            case '&':
            case '===':
            case '==':
            case '!=':
            case '!==':
            case '>=':
            case '<=':
            case '>':
            case '<':
            case '<<':
            case '>>':
              _a = rev(ops[1], e, s, g, o, _f);
              if (typeof(_a) != "boolean" && typeof(_a) != "number" && _a != "") {
                _a = _a.replace("{{", "").replace("}}", "");
              }
              _b = rev(ops[2], e, s, g, o, _f);
              if (typeof(_b) != "boolean" && typeof(_b) != "number" && _b != "") {
                _b = _b.replace("{{", "").replace("}}", "");
              }
              _c = should_pass_type_info && (wh.hn(_a) === 'h' || wh.hn(_b) === 'h');
              switch (rop) {
              case '+':
                _d = wh.rv(_a) + wh.rv(_b);
                break;
              case '*':
                _d = wh.rv(_a) * wh.rv(_b);
                break;
              case '/':
                _d = wh.rv(_a) / wh.rv(_b);
                break;
              case '%':
                _d = wh.rv(_a) % wh.rv(_b);
                break;
              case '|':
                _d = wh.rv(_a) | wh.rv(_b);
                break;
              case '^':
                _d = wh.rv(_a) ^ wh.rv(_b);
                break;
              case '&':
                _d = wh.rv(_a) & wh.rv(_b);
                break;
              case '===':
                _d = wh.rv(_a) === wh.rv(_b);
                break;
              case '==':
                _d = wh.rv(_a) == wh.rv(_b);
                break;
              case '!=':
                _d = wh.rv(_a) != wh.rv(_b);
                break;
              case '!==':
                _d = wh.rv(_a) !== wh.rv(_b);
                break;
              case '>=':
                _d = wh.rv(_a) >= wh.rv(_b);
                break;
              case '<=':
                _d = wh.rv(_a) <= wh.rv(_b);
                break;
              case '>':
                _d = wh.rv(_a) > wh.rv(_b);
                break;
              case '<':
                _d = wh.rv(_a) < wh.rv(_b);
                break;
              case '<<':
                _d = wh.rv(_a) << wh.rv(_b);
                break;
              case '>>':
                _d = wh.rv(_a) >> wh.rv(_b);
                break;
              default:
                break;
              }
              //return _c ? wh.nh( _d, "c" ) : _d;
              return "" + _a + rop + _b + "";
              break;
            case '-':
              _a = ops.length === 3 ? rev(ops[1], e, s, g, o, _f) : 0;
              _b = ops.length === 3 ? rev(ops[2], e, s, g, o, _f) : rev(ops[1], e, s, g, o, _f);
              _c = should_pass_type_info && (wh.hn(_a) === 'h' || wh.hn(_b) === 'h');
              _d = _c ? wh.rv(_a) - wh.rv(_b) : _a - _b;
              //return _c ? wh.nh( _d, "c" ) : _d;
              return "" + _a + rop + _b + "";
              break;
            case '!':
              _a = rev(ops[1], e, s, g, o, _f);
              if (typeof(_a) != "boolean" && typeof(_a) != "number" && _a != "") {
                _a = _a.replace("{{", "").replace("}}", "");
              }
              _c = should_pass_type_info && (wh.hn(_a) == 'h');
              _d = !wh.rv(_a);
              //return _c ? wh.nh( _d, "c" ) : _d;
              return "" + rop + _a + "";

            case '~':
              _a = rev(ops[1], e, s, g, o, _f);
              if (typeof(_a) != "boolean" && typeof(_a) != "number" && _a != "") {
                _a = _a.replace("{{", "").replace("}}", "");
              }
              _c = should_pass_type_info && (wh.hn(_a) == 'h');
              _d = ~wh.rv(_a);
              //return _c ? wh.nh( _d, "c" ) : _d;
              return "" + rop + _a + "";

            default:
              $gwn('unrecognized op' + rop);
            }
          }
          function rev(ops, e, s, g, o, newap) {
            var op = ops[0];
            var _f = false;
            if (typeof newap !== "undefined") o.ap = newap;
            if (typeof(op) === 'object') {
              var vop = op[0];
              var _a, _aa, _b, _bb, _c, _d, _s, _e, _ta, _tb, _td;
              switch (vop) {
              case 2:
                return ArithmeticEv(ops, e, s, g, o);
                break;
              case 4:
                return rev(ops[1], e, s, g, o, _f);
                break;
              case 5:
                switch (ops.length) {
                case 2:
                  _a = rev(ops[1], e, s, g, o, _f);
                  return should_pass_type_info ? [_a] : [wh.rv(_a)];
                  return [_a];
                  break;
                case 1:
                  return [];
                  break;
                default:
                  _a = rev(ops[1], e, s, g, o, _f);
                  _b = rev(ops[2], e, s, g, o, _f);
                  _a.push(should_pass_type_info ? _b: wh.rv(_b));
                  return _a;
                  break;
                }
                break;
              case 6:
                _a = rev(ops[1], e, s, g, o);

                if (typeof(_a) != "boolean" && typeof(_a) != "number" && _a != "") {
                  _a = _a.replace("{{", "").replace("}}", "");
                }
                _b = rev(ops[2], e, s, g, o);
                if (typeof(_b) != "boolean" && typeof(_b) != "number" && _b != "") {
                  _b = _b.replace("{{", "").replace("}}", "");
                }
                if (typeof(_b) == "number") {
                  return "{{" + _a + "[" + _b + "]}}";
                }
                return "{{" + _a + "." + _b + "}}";

                var ap = o.ap;
                _ta = wh.hn(_a) === 'h';
                _aa = _ta ? wh.rv(_a) : _a;
                o.is_affected |= _ta;
                if (should_pass_type_info) {
                  if (_aa === null || typeof(_aa) === 'undefined') {
                    return _ta ? wh.nh(undefined, 'e') : undefined;
                  }
                  _b = rev(ops[2], e, s, g, o, _f);
                  _tb = wh.hn(_b) === 'h';
                  _bb = _tb ? wh.rv(_b) : _b;
                  o.ap = ap;
                  o.is_affected |= _tb;
                  if (_bb === null || typeof(_bb) === 'undefined' || _bb === "__proto__" || _bb === "prototype" || _bb === "caller") {
                    return (_ta || _tb) ? wh.nh(undefined, 'e') : undefined;
                  }
                  _d = _aa[_bb];
                  if (typeof _d === 'function' && !ap) _d = undefined;
                  _td = wh.hn(_d) === 'h';
                  o.is_affected |= _td;
                  return (_ta || _tb) ? (_td ? _d: wh.nh(_d, 'e')) : _d;
                } else {
                  if (_aa === null || typeof(_aa) === 'undefined') {
                    return undefined;
                  }
                  _b = rev(ops[2], e, s, g, o, _f);
                  _tb = wh.hn(_b) === 'h';
                  _bb = _tb ? wh.rv(_b) : _b;
                  o.ap = ap;
                  o.is_affected |= _tb;
                  if (_bb === null || typeof(_bb) === 'undefined' || _bb === "__proto__" || _bb === "prototype" || _bb === "caller") {
                    return undefined;
                  }
                  _d = _aa[_bb];
                  if (typeof _d === 'function' && !ap) _d = undefined;
                  _td = wh.hn(_d) === 'h';
                  o.is_affected |= _td;
                  return _td ? wh.rv(_d) : _d;
                }
              case 7:
                switch (ops[1][0]) {
                case 11:
                  o.is_affected |= wh.hn(g) === 'h';
                  return g;
                case 3:
                  _s = wh.rv(s);
                  _e = wh.rv(e);
                  _b = ops[1][1];
                  if (g && g.f && g.f.hasOwnProperty(_b)) {
                    _a = g.f;
                    o.ap = true;
                  } else {
                    _a = _s && _s.hasOwnProperty(_b) ? s: (_e && _e.hasOwnProperty(_b) ? e: undefined);
                  }
                  if (should_pass_type_info) {
                    if (_a) {
                      _ta = wh.hn(_a) === 'h';
                      _aa = _ta ? wh.rv(_a) : _a;
                      _d = _aa[_b];
                      _td = wh.hn(_d) === 'h';
                      o.is_affected |= _ta || _td;
                      _d = _ta && !_td ? wh.nh(_d, 'e') : _d;
                      return _d;
                    }
                  } else {
                    if (_a) {
                      _ta = wh.hn(_a) === 'h';
                      _aa = _ta ? wh.rv(_a) : _a;
                      _d = _aa[_b];
                      _td = wh.hn(_d) === 'h';
                      o.is_affected |= _ta || _td;
                      //return wh.rv(_d);
                      if (!new RegExp("{{").test(_d)) {
                        return "" + _d + "";
                      }
                      return "" + ops[1][1] + "";

                    }
                  }
                  //return undefined;
                  return "{{" + ops[1][1] + "}}";
                }
                break;
              case 8:
                _a = {};
                _a[ops[1]] = rev(ops[2], e, s, g, o, _f);
                return _a;
                break;
              case 9:
                _a = rev(ops[1], e, s, g, o, _f);
                _b = rev(ops[2], e, s, g, o, _f);
                function merge(_a, _b, _ow) {
                  var ka, _bbk;
                  _ta = wh.hn(_a) === 'h';
                  _tb = wh.hn(_b) === 'h';
                  _aa = wh.rv(_a);
                  _bb = wh.rv(_b);
                  for (var k in _bb) {
                    if (_ow || !_aa.hasOwnProperty(k)) {
                      _aa[k] = should_pass_type_info ? (_tb ? wh.nh(_bb[k], 'e') : _bb[k]) : wh.rv(_bb[k]);
                    }
                  }
                  return _a;
                }
                var _c = _a
                var _ow = true
                if (typeof(ops[1][0]) === "object" && ops[1][0][0] === 10) {
                  _a = _b _b = _c _ow = false
                }
                if (typeof(ops[1][0]) === "object" && ops[1][0][0] === 10) {
                  var _r = {}
                  return merge(merge(_r, _a, _ow), _b, _ow);
                } else return merge(_a, _b, _ow);
                break;
              case 10:
                _a = rev(ops[1], e, s, g, o, _f);
                _a = should_pass_type_info ? _a: wh.rv(_a);
                return _a;
                break;
              case 125:
                var _r;
                _a = rev(ops[1], e, s, g, o);
                if (!o.ap) {
                  return should_pass_type_info && wh.hn(_a) === 'h' ? wh.nh(_r, 'f') : _r;
                }
                var ap = o.ap;
                _b = rev(ops[2], e, s, g, o, _f);
                o.ap = ap;
                _ta = wh.hn(_a) === 'h';
                _tb = _ca(_b);
                _aa = wh.rv(_a);
                _bb = wh.rv(_b);
                snap_bb = $gdc(_bb, "nv_");
                try {
                  _r = typeof _aa === "function" ? $gdc(_aa.apply(null, snap_bb)) : undefined;
                } catch(e) {
                  e.message = e.message.replace(/nv_/g, "");
                  e.stack = e.stack.substring(0, e.stack.indexOf("\n", e.stack.lastIndexOf("at nv_")));
                  e.stack = e.stack.replace(/\snv_/g, " ");
                  e.stack = $gstack(e.stack);
                  if ("undefined" !== typeof debugInfo) e.stack += "\n " + " " + " " + " at " + debugInfo[g.opindex][0] + ":" + debugInfo[g.opindex][1] + ":" + debugInfo[g.opindex][2];
                  throw e;
                }
                return should_pass_type_info && (_tb || _ta) ? wh.nh(_r, 'f') : _r;
              }
            } else {
              if (op === 3 || op === 1) return ops[1];
              else if (op === 11) {
                var _a = '';
                for (var i = 1; i < ops.length; i++) {
                  var xp = wh.rv(rev(ops[i], e, s, g, o, _f));
                  _a += typeof(xp) === 'undefined' ? '': xp;
                }
                return _a;
              }
            }
          }
          return rev;
        }
        gra = $gwrt(true);
        grb = $gwrt(false);
        function TestTest(expr, ops, e, s, g, expect_a, expect_b, expect_affected) {
          {
            var o = {
              is_affected: false
            };
            var a = gra(ops, e, s, g, o);
            if (JSON.stringify(a) != JSON.stringify(expect_a) || o.is_affected != expect_affected) {
              console.warn("A. " + expr + " get result " + JSON.stringify(a) + ", " + o.is_affected + ", but " + JSON.stringify(expect_a) + ", " + expect_affected + " is expected");
            }
          } {
            var o = {
              is_affected: false
            };
            var a = grb(ops, e, s, g, o);
            if (JSON.stringify(a) != JSON.stringify(expect_b) || o.is_affected != expect_affected) {
              console.warn("B. " + expr + " get result " + JSON.stringify(a) + ", " + o.is_affected + ", but " + JSON.stringify(expect_b) + ", " + expect_affected + " is expected");
            }
          }
        }

        function wfor(to_iter, func, env, _s, global, father, itemname, indexname, keyname) {
          console.info(itemname);
          var _n = wh.hn(to_iter) === 'n';
          var scope = wh.rv(_s);
          var has_old_item = scope.hasOwnProperty(itemname);
          var has_old_index = scope.hasOwnProperty(indexname);
          var old_item = scope[itemname];
          var old_index = scope[indexname];
          var full = Object.prototype.toString.call(wh.rv(to_iter));
          var type = full[8];
          if (type === 'N' && full[10] === 'l') type = 'X';
          var _y;
          if (_n) {
            if (type === 'A') {
              var r_iter_item;
              for (var i = 0; i < to_iter.length; i++) {
                scope[itemname] = to_iter[i];
                scope[indexname] = _n ? i: wh.nh(i, 'h');
                r_iter_item = wh.rv(to_iter[i]);
                var key = keyname && r_iter_item ? (keyname === "*this" ? r_iter_item: wh.rv(r_iter_item[keyname])) : undefined;
                _y = _v(key);
                _(father, _y);
                func(env, scope, _y, global);
              }
            } else if (type === 'O') {
              var i = 0;
              var r_iter_item;
              for (var k in to_iter) {
                scope[itemname] = to_iter[k];
                scope[indexname] = _n ? k: wh.nh(k, 'h');
                r_iter_item = wh.rv(to_iter[k]);
                var key = keyname && r_iter_item ? (keyname === "*this" ? r_iter_item: wh.rv(r_iter_item[keyname])) : undefined;
                _y = _v(key);
                _(father, _y);
                func(env, scope, _y, global);
                i++;
              }
            } else if (type === 'S') {
              for (var i = 0; i < 1; i++) {
                scope[itemname] = to_iter;
                scope[indexname] = _n ? i: wh.nh(i, 'h');
                _y = _v(to_iter);
                _y["wx:key"] = keyname _(father, _y);
                func(env, scope, _y, global);
              }
            } else if (type === 'N') {
              for (var i = 0; i < to_iter; i++) {
                scope[itemname] = i;
                scope[indexname] = _n ? i: wh.nh(i, 'h');
                _y = _v(i);
                _(father, _y);
                func(env, scope, _y, global);
              }
            } else {}
          } else {
            var r_to_iter = wh.rv(to_iter);
            var r_iter_item, iter_item;
            if (type === 'A') {
              for (var i = 0; i < r_to_iter.length; i++) {
                iter_item = r_to_iter[i];
                iter_item = wh.hn(iter_item) === 'n' ? wh.nh(iter_item, 'h') : iter_item;
                r_iter_item = wh.rv(iter_item);
                scope[itemname] = iter_item scope[indexname] = _n ? i: wh.nh(i, 'h');
                var key = keyname && r_iter_item ? (keyname === "*this" ? r_iter_item: wh.rv(r_iter_item[keyname])) : undefined;
                _y = _v(key);
                _(father, _y);
                func(env, scope, _y, global);
              }
            } else if (type === 'O') {
              var i = 0;
              for (var k in r_to_iter) {
                iter_item = r_to_iter[k];
                iter_item = wh.hn(iter_item) === 'n' ? wh.nh(iter_item, 'h') : iter_item;
                r_iter_item = wh.rv(iter_item);
                scope[itemname] = iter_item;
                scope[indexname] = _n ? k: wh.nh(k, 'h');
                var key = keyname && r_iter_item ? (keyname === "*this" ? r_iter_item: wh.rv(r_iter_item[keyname])) : undefined;
                _y = _v(key);
                _(father, _y);
                func(env, scope, _y, global);
                i++
              }
            } else if (type === 'S') {
              for (var i = 0; i < r_to_iter.length; i++) {
                iter_item = wh.nh(r_to_iter[i], 'h');
                scope[itemname] = iter_item;
                scope[indexname] = _n ? i: wh.nh(i, 'h');
                _y = _v(to_iter[i] + i);
                _(father, _y);
                func(env, scope, _y, global);
              }
            } else if (type === 'N') {
              for (var i = 0; i < r_to_iter; i++) {
                iter_item = wh.nh(i, 'h');
                scope[itemname] = iter_item;
                scope[indexname] = _n ? i: wh.nh(i, 'h');
                _y = _v(i);
                _(father, _y);
                func(env, scope, _y, global);
              }
            } else {}
          }
          if (has_old_item) {
            scope[itemname] = old_item;
          } else {
            delete scope[itemname];
          }
          if (has_old_index) {
            scope[indexname] = old_index;
          } else {
            delete scope[indexname];
          }
        }

 

修改这个,添加日志输出

       if (path && e_[path]) {
          window.__wxml_comp_version__ = 0.02
          return function(env, dd, global) {
            $gwxc = 0;
            var root = {
              "tag": "wx-page"
            };
            root.children = []
            var main = e_[path].f
            if (typeof global === "undefined") global = {};
            global.f = $gdc(f_[path], "", 1);
            if (typeof(window.__webview_engine_version__) != 'undefined' && window.__webview_engine_version__ + 1e-6 >= 0.02 + 1e-6 && window.__mergeData__) {
              env = window.__mergeData__(env, dd);
            }
            try {
              main(env, {},
              root, global);
              if (typeof(window.__webview_engine_version__) == 'undefined' || window.__webview_engine_version__ + 1e-6 < 0.01 + 1e-6) {
                console.log(forwxml(_ev(root)));
                return _ev(root);
              }
            } catch(err) {
              console.log(err)
            }
            console.log("result:" + root) return root;
          }
        }
      }

修改下面的方法,添加输出,打开网页后,在控制台能看到对应的wxss(查看每个page里面的wxss,替换setCssToHead即可):

function makeup(file, suffix) {
var _n = typeof(file) === "number";
if ( _n && Ca.hasOwnProperty(file)) return "";
if ( _n ) Ca[file] = 1;
var ex = _n ? _C[file] : file;
var res="";
for (var i = ex.length - 1; i >= 0; i--) {
var content = ex[i];
if (typeof(content) === "object")
{
var op = content[0];
if ( op == 0 )
res = transformRPX(content[1]) + "px" + res;
else if ( op == 1)
res = suffix + res;
else if ( op == 2 ) 
res = makeup(content[1], suffix) + res;
}
else
res = content + res
}
console.log(res);
return res;
}

不同小程序可能由于编译上线时间不同,其中的函数及变量也发生了变化

本文针对的window.__wcc_version__='v0.6vv_20171208_cua_xc'的版本,其他版本可以会有一些问题

 

在chrome中打开page-frame.html,在控制台(console)中输入:

    //解析单个wxml
    $gwx("...wxml地址...")();        //例如$gwx("./pages/all/all.wxml")();

wxml地址在page-frame.html文件的 这个位置var x=['./pages/all/all.wxml'];

© 著作权归作者所有

dhlsoft
粉丝 1
博文 30
码字总数 24879
作品 0
沈阳
其他
私信 提问
加载中

评论(1)

OSC_UGpvsV
OSC_UGpvsV
7月底升级此方法已失效了
只需两步获取任何微信小程序源码

第一次在掘金这样高大上的社区写文章,忐忑地敲下我获取小程序源码过程中的经验分享。 最近在学习微信小程序开发,半个月学习下来,很想实战一下踩踩坑,于是就仿写了一个滴滴他们家的青桔单...

行无忌
2018/05/31
0
0
](反编译微信小程序)一键获取微信小程序源码CrackMinApp

下载地址:https://github.com/Cherrison/CrackMinApp 一键获取微信小程序源码, 使用了C#加nodejs制作直接解压在D盘根目录下后就可以使用将小程序文件放到 wxapkg目录下这个目录下有一些demo ...

xiaogg
04/17
115
0
微信小程序“反编译”实战(一):解包

本实践教程将一步步告诉你如何“反编译”获得其它小程序的源代码,包括“解包”和“源码还原”两篇,主要参考了看雪论坛、V2EX、GitHub 等网站上的帖子、教程、工具,在此不胜感激,参考链接...

知识小集
2018/05/08
0
0
微信小程序反编译工具wxappUnpacker使用

1、下载wxappUnpacker,我这里用的是node版还有其他班自己查https://github.com/qwerty472123/wxappUnpacker 2、下载node。js 首先需要知道的是小程序在手机里的文件储存位置 —— 那么这个位...

CatherinePlans
03/27
0
0
解密微信小程序漏洞:可下载任意小游戏源代码,“跳一跳”可改分

雷锋网消息,据 IT 之家 1 月 2 日消息称,“跳一跳”居然可以利用漏洞自己改分数,甚至连微信小程序、小游戏的源代码都可以直接下载,只需要知道appid和版本号,就可以直接构造URL下载后缀为...

李勤
2018/01/02
0
0

没有更多内容

加载失败,请刷新页面

加载更多

Kafka实战(五) - 核心API及适用场景全面解析

1 四个核心API ● Producer API 允许一个应用程序发布一串流式的数据到一个或者多个Kafka topic。 ● Consumer API 允许一个应用程序订阅一个或多个topic ,并且对发布给他们的流式数据进行处...

JavaEdge
22分钟前
5
0
实现线程的第三种方式——Callable & Future

Callable Runnable 封装一个异步运行的任务, 可以把它想象成为一个没有参数和返回值的异步方 法。Callable 与 Runnable 类似, 但是有返回值。Callable 接口是一个参数化的类型, 只有一 个...

ytuan996
今天
8
0
OSChina 周六乱弹 —— 不要摁F了!

Osc乱弹歌单(2019)请戳(这里) 【今日歌曲】 @巴拉迪维 : 朴树写的词曲都给人一种莫名的失落感,不过这首歌他自己却没有唱,换成赵传这种高音阶嘶喊的确很好,低沉但却有力,老男人的呐喊...

小小编辑
今天
10
0
Android Binder机制 - interface_cast和asBinder讲解

研究Android底层代码时,尤其是Binder跨进程通信时,经常会发现interface_cast和asBinder,很容易被这两个函数绕晕,下面来讲解一下: interface_cast 下面根据下述ICameraClient例子进行分析...

天王盖地虎626
昨天
12
0
计算机实现原理专题--存储器的实现(二)

计算机实现原理专题--存储器的实现(一)中描述了一种可以记住输入端变化的装置。现需要对其功能进行扩充,我们将上面的开关定义为置位,下面的开关定义为复位,然后需要增加一个保持位,当保...

FAT_mt
昨天
9
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部