35-JS VMP技术介绍

认识js vmp

js vmp其实就是一个微型解释器,然后传入一串很长的字符串或者指令集映射为原生 JS 逻辑然后进行加密,也是相混淆一样对代码进行保护的作用,他总体代码如下:

javascript 复制代码
// 1. VM核心
function VM() {
  this.stack = [];
  this.ip = 0;
  this.run = function(bytecode) {
    while (this.ip < bytecode.length) {
      const op = bytecode[this.ip];
      switch(op) {
        case 0x01: this.stack.push(bytecode[++this.ip]); this.ip++; break;
        case 0x02: 
          const a = this.stack.pop();
          const b = this.stack.pop();
          this.stack.push(a + b);
          this.ip++;
          break;
      }
    }
    return this.stack.pop();
  };
}

// 2. 字节码(业务逻辑:输入值+10)
function genBytecode(input) {
  return [0x01, input, 0x01, 10, 0x02];
}

// 3. 沙箱
const sandbox = { Math: { random: () => Math.random() } };

// 4. 桥接层
function bridge(input) {
  antiDebug(); // 先执行反逆向
  const bytecode = genBytecode(Number(input));
  const vm = new VM();
  return vm.run(bytecode);
}

// 5. 反逆向层
function antiDebug() {
  if (window.outerHeight - window.innerHeight > 200) {
    throw new Error("禁止调试!");
  }
}

// 测试调用
try {
  console.log(bridge(20)); // 输出30
} catch (e) {
  console.log(e.message);
}

当我们遇到长字符串然后有个大循环里面还有switch case 语句(或 if 嵌套)时很可能就是JS vmp,给大家看一个典型的jsvmp的例子(X日头条):

解决办法:当你有很强的js代码阅读能力时可以跟下来然后扣代码或者纯算,要不就直接全扣然后补环境

小结

本文到此结束,JS VMP本人理解其实就是混淆加强版,看不懂就去全扣补环境就行,加油加油

相关推荐
嫂子的姐夫5 小时前
32-字体反爬
爬虫·逆向
有代理ip10 小时前
网络爬虫工具核心知识:概念、应用、优化及常见问题解答
爬虫
拍客圈10 小时前
宝塔UA爬虫黑名单
爬虫
嫂子的姐夫10 小时前
34-自动化补环境和jsdom补环境
爬虫·python·逆向
cch891810 小时前
PHP爬虫框架大比拼
开发语言·爬虫·php
ZC跨境爬虫11 小时前
Playwright模拟鼠标滚轮实战:从原理到百度图片_豆瓣电影爬取
爬虫·python·计算机外设
ZC跨境爬虫1 天前
极验滑动验证码自动化实战:背景提取、缺口定位与Playwright滑动模拟
前端·爬虫·python·自动化
ZC跨境爬虫1 天前
极验滑动验证码自动化实战(ddddocr免费方案):本地缺口识别与Playwright滑动模拟
前端·爬虫·python·自动化
后藤十八里1 天前
极验4消消乐验证码逆向笔记
笔记·爬虫·python