李恒道 发表于 2022-10-20 14:52:36

【文艺复兴】JS混淆分析实战某大学Mooc(二)解密/合并字符串

# 前文
上节我们处理了内存爆破问题
然后直接提取出来解密字符串
![图片.png](data/attachment/forum/202210/20/144732qduh5moskpedcohc.png)
然后写一下解密字符串代码
```javascript
traverse(ast, {
CallExpression(path) {
    if (path.node.callee?.name === "b") {
      if (path.node.arguments.length !== 2) {
      return;
      }
      let first = path.node.arguments.value;
      let second = path.node.arguments.value;
      let str_node = types.stringLiteral(ob_func.crp_name(first, second));
      path.replaceInline(str_node);
    }
},
});
```
可以看到已经解开了
![图片.png](data/attachment/forum/202210/20/144825m391pd6b7ki73917.png)
但是字符串还是来回拼接的
所以我们用ast给组合一下
这里直接多循环生成几次代码就好了
之所以反复parse是因为实践多次操作会导致操作乱七八糟的错误问题(不明
所以我们反复循环解析再设置
代码很简单,循环一下就ok
```javascript
traverse(ast, {
    BinaryExpression(path) {
      if (path.node.operator === "+") {
      let left = path.node.left;
      let right = path.node.right;
      if (left.type === "StringLiteral" && right.type === "StringLiteral") {
          let str_node = types.stringLiteral(left.value + right.value);
          path.replaceInline(str_node);
      }
      }
    },
});
```

![图片.png](data/attachment/forum/202210/20/144858hco03uapo03jduoi.png)
可以看到这时候已经具备一定的可读性了
![图片.png](data/attachment/forum/202210/20/145206vfh88hhbyyh59d8y.png)
# 结语
撒花~

王一之 发表于 2022-10-21 11:20:40

曲高和寡 呜呜呜
页: [1]
查看完整版本: 【文艺复兴】JS混淆分析实战某大学Mooc(二)解密/合并字符串