最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JavaScript中隱藏eval關(guān)鍵字的多種方法

 更新時間:2025年10月30日 08:23:20   作者:w2sfot  
本文介紹了JavaScript中隱藏eval關(guān)鍵字的多種方法,從簡單的字符串拼接和Function構(gòu)造函數(shù),到使用字符編碼動態(tài)生成字符串,這些技術(shù)通過層層包裝,使原始eval調(diào)用在代碼審計中難以被發(fā)現(xiàn),需要的朋友可以參考下

引言

本文介紹了JavaScript中隱藏eval關(guān)鍵字的多種方法,從簡單的字符串拼接和Function構(gòu)造函數(shù),到使用字符編碼動態(tài)生成字符串。更復(fù)雜的方案包括通過JS混淆工具(如JShaman)將代碼轉(zhuǎn)換為難以辨識的格式,甚至模擬虛擬機執(zhí)行字節(jié)碼來重構(gòu)eval。這些技術(shù)通過層層包裝,使原始eval調(diào)用在代碼審計中難以被發(fā)現(xiàn)。

JavaScript中隱藏eval關(guān)鍵字的技巧

某些情況下,我們在進(jìn)行JS編程時,可能想要用eval執(zhí)行一些特殊的代碼,但想不想讓他人輕易看出是使用了eval。那么,就得想辦法隱藏eval關(guān)鍵字了。

簡單的隱藏方法

// 方法1:使用字符串分割
const ev = "ev";
const al = "al";
const hiddenEval = window[ev + al];

// 使用
hiddenEval('console.log("隱藏的eval執(zhí)行")');

// 方法2:通過Function構(gòu)造函數(shù)
const executeCode = new Function('code', 'return eval(code)');
executeCode('2 + 2'); // 返回4

復(fù)雜的隱藏方法

// 使用字符編碼
const encodedEval = () => {
    const chars = [101, 118, 97, 108];
    const str = String.fromCharCode(...chars);
    return window[str];
};

const myEval = encodedEval();

更更更復(fù)雜的隱藏方法

如果還想隱藏的更深,可以再用JShaman進(jìn)行JS代碼混淆加密,上面代碼會變成:

const encodedEval = () => {
  const _0x35ea38 = {
    "\u006d\u004f\u0067\u006c\u0048": function (_0x55d02e, _0x5cdb2b) {
      return _0x55d02e ^ _0x5cdb2b;
    },
    "\u0076\u006a\u0048\u0044\u0073": function (_0x4c98c3, _0xa2b4f0) {
      return _0x4c98c3 ^ _0xa2b4f0;
    }
  };
  const _0x2cd5ff = [0x47a4d ^ 0x47a28, _0x35ea38["\u006d\u004f\u0067\u006c\u0048"](0xd8290, 0xd82e6), _0x35ea38['vjHDs'](0xb9759, 0xb9738), _0x35ea38["\u0076\u006a\u0048\u0044\u0073"](0x7b450, 0x7b43c)];

  const _0x3d45d7 = String['fromCharCode'](..._0x2cd5ff);

  return window[_0x3d45d7];
};

const myEval = encodedEval();

或:

function _0x927a(opcode) {
  var op = {
    push: 32,
    add: 33,
    sub: 34,
    mul: 35,
    div: 36,
    pop: 37,
    xor: 38
  };
  var stack = [];
  var ip = -1;
  var sp = -1;

  while (ip < opcode.length) {
    ip++;

    switch (opcode[ip]) {
      case op.push:
        {
          ip++;
          stack.push(opcode[ip]);
          sp++;
          break;
        }

      case op.add:
        {
          stack.push(stack[sp - 1] + stack[sp]);
          sp++;
          break;
        }

      case op.sub:
        {
          stack.push(stack[sp - 1] - stack[sp]);
          sp++;
          break;
        }

      case op.mul:
        {
          stack.push(stack[sp - 1] * stack[sp]);
          sp++;
          break;
        }

      case op.div:
        {
          stack.push(stack[sp - 1] / stack[sp]);
          sp++;
          break;
        }

      case op.xor:
        {
          stack.push(stack[sp - 1] ^ stack[sp]);
          sp++;
          break;
        }

      case op.pop:
        {
          return stack[sp];
        }
    }
  }
}

const encodedEval = () => {
  const chars = [_0x927a([32, 865932, 32, 866025, 38, 37]), _0x927a([32, 625917, 32, 625803, 38, 37]), _0x927a([32, 750963, 32, 750866, 38, 37]), _0x927a([32, 753540, 32, 753640, 38, 37])];
  const str = String['\x66\x72\x6f\x6d\x43\x68\x61\x72\x43\x6f\x64\x65'](...chars);
  return window[str];
};

const myEval = encodedEval();

怎么樣,還能找到eval關(guān)鍵字嗎?

到此這篇關(guān)于JavaScript中隱藏eval關(guān)鍵字的多種方法的文章就介紹到這了,更多相關(guān)JavaScript隱藏eval關(guān)鍵字內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

宁夏| 武清区| 宁乡县| 深圳市| 仙游县| 恭城| 东阿县| 宁国市| 新丰县| 富源县| 石景山区| 洱源县| 南乐县| 呼玛县| 武义县| 道真| 祁东县| 体育| 林周县| 长葛市| 古浪县| 临沧市| 泸州市| 上林县| 五寨县| 额济纳旗| 浠水县| 赤城县| 疏勒县| 云南省| 威宁| 册亨县| 沧州市| 沾化县| 巴塘县| 浏阳市| 垦利县| 阿勒泰市| 湘乡市| 枣庄市| 新建县|