AST处理switch语句

一个标准的switch语句js模板如下

switch (判断值) {
       case 4:
           console.log(4);
       case 2:
           console.log(2);
       case 1:
           console.log(1);
}

AST结构

        其中 discriminant是swicth判断值,cases是一个数组,里边有每个case是中代码块。具体的cases代码块结构如下:

        其中consequent是一个数组,里边是要执行的语句。test是case后边的具体值。

首先平坦流,有的有解密大数组,有的没有解密数组比如如下语句:

d=[]
function ss() {
  var $_DBIAY = 2;var $_DBIEy = 0;var $_DBICk = 0;var $_DBIBf = [];var $_DBIDW = 15 - 1;
  for (; $_DBIAY !== 10;) {
    switch ($_DBIAY) {
      case 4:
        d.push(4);console.log(4);
        $_DBIBf[($_DBICk + 5) % 15] = [];
        $_DBIAY = 3;
        break;

      case 13:
        d.push(13);console.log(13);
        $_DBIDW -= 1;
        $_DBIAY = 6;
        break;

      case 9:
        d.push(9);console.log(9);
        $_DBIAY = 8;
        break;

      case 8:
        d.push(8);console.log(8);
        $_DBIAY = $_DBIEy < 15 ? 7 : 11;
        break;

      case 12:
        d.push(12);console.log(12);
        $_DBIEy += 1;
        $_DBIAY = 8;
        break;

      case 6:
        d.push(6);console.log(6);
        $_DBIAY = $_DBIDW >= 0 ? 14 : 12;
        break;

      case 1:
        d.push(1);console.log(1);
        $_DBIAY = 5;
        break;

      case 2:
        d.push(2);console.log(2);
        $_DBIAY = 1;
        break;

      case 3:
        d.push(3);console.log(3);
        $_DBICk += 1;
        $_DBIAY = 5;
        break;

      case 14:
        d.push(14);console.log(14);
        $_DBIBf[$_DBIEy][($_DBIDW + 5 * $_DBIEy) % 15] = $_DBIBf[$_DBIDW];
        $_DBIAY = 13;
        break;

      case 5:
        d.push(5);console.log(5);
        $_DBIAY = $_DBICk < 15 ? 4 : 9;
        break;

      case 7:
        d.push(7);console.log(7);
        $_DBIAY = 6;
        break;

      case 11:
        d.push(11);console.log(11);
        return $_DBIBf;
        break;
    }
  }
}

        手动生成一个解密数组,156位。看生成一个数组,一个无限递归除了[0][0]无限循环,其余全是undeniue,因此所有相关的bVnHz.$_DO()[随意数][随意数]:只要两个不同时为零都可以定义为undefined。

        先每个case中加如console(case),得出顺序,然后按顺序还原语句。还原代码如下:

let dd="";
let ee=[2,1,5,4,3,5,4,3,5,4,3,5,4,3,5,4,3,5,4,3,5,4,3,5,4,3,5,4,3,5,4,3,5,4,3,5,4,3,5,4,3,5,4,3,5,4,3,5,9,8,7,6,14,13,6,14,13,6,14,13,6,14,13,6,14,13,6,14,13,6,14,13,6,14,13,6,14,13,6,14,13,6,14,13,6,14,13,6,14,13,6,14,13,6,14,13,6,12,8,7,6,12,8,7,6,12,8,7,6,12,8,7,6,12,8,7,6,12,8,7,6,12,8,7,6,12,8,7,6,12,8,7,6,12,8,7,6,12,8,7,6,12,8,7,6,12,8,7,6,12,8,7,6,12,8,11];
let i=0;
const paramName={
    "AssignmentExpression|ReturnStatement"(path){
        let code =generator(path.node).code;
        dd=dd+code+";";
        console.log(code);
    }
};
for (i=0 ; i<ee.length ; i++){
    const visitor = {
            SwitchCase(path) {
                //console.log(path.node.consequent);
                if(path.node.test.value==ee[i]){
                    console.log(path.node.consequent.length);
                    console.log(path.node.test.value);
                    path.traverse(paramName);
                }
        }
    }
    let ast=parser.parse(jscode);
    traverse(ast,visitor);
}
fs.writeFile('./testfter.js',dd,(err)=>{});

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值