zoukankan      html  css  js  c++  java
  • js逆向分析之acorn和escodegen的使用

    替换之前的d形如

    d("77696669")
    

    执行代码

    const fs = require('fs');
    const acorn = require('acorn');
    const walk = require("acorn-walk")
    const escodegen = require('escodegen');
    
    function d(b) {
        var a, c = "";
        for (a = 0; a < b.length; a += 2) c += String.fromCharCode(parseInt(b.slice(a, a + 2), 16));
        return c
    }
    
    const content = fs.readFileSync('m301650.js');
    const ast = acorn.parse(content);
    walk.simple(ast, {
        CallExpression(node) {
            if (node.callee.name === 'd' && node.arguments[0].type === 'Literal') {
                node.type = 'Literal';
                node.value = d(node.arguments[0].value);
            }
        }
    });
    const decodedContent = escodegen.generate(ast);
    fs.writeFileSync('m301650.decoded.js', decodedContent);
    

    替换之后的

    就是一个字符串

    script
    
  • 相关阅读:
    自定义一个运行时异常
    对象的知识点正确解释
    decimal模块
    B+树
    Web框架系列之Tornado
    初识git
    Mysql表的操作
    MySQl创建用户和授权
    MySql安装和基本管理
    为什么用Mysql?
  • 原文地址:https://www.cnblogs.com/c-x-a/p/12012665.html
Copyright © 2011-2022 走看看