Coder Social home page Coder Social logo

JavaScript混淆安全加固 about blog HOT 2 OPEN

yacan8 avatar yacan8 commented on July 22, 2024
JavaScript混淆安全加固

from blog.

Comments (2)

yangmin4052 avatar yangmin4052 commented on July 22, 2024

这里代码自检的写法是不是有问题啊,代码运行时才能获取到toString的结果,不同的打包机制也会影响toString的结果

from blog.

yacan8 avatar yacan8 commented on July 22, 2024

这里代码自检的写法是不是有问题啊,代码运行时才能获取到toString的结果,不同的打包机制也会影响toString的结果

实现细节上注意一下就可以,例如手动实现打包插件,设定函数abc,然后在插件打包时增加一层函数名为abc的闭包,同时对函数体本身进行离线的计算签名,注入到打包代码里,如下

源码

var onlineSign = calc_sign(abc.toString());
if (onlineSign !== offlineSign) {
    // do something
}

插件代码:

function transform(code) {
  var closureCode = `function abc() {${code} }`
  var offlineSign = calc_sign(closureCode);
  return `var offlineSign = '${offlineSign}';
      (${closureCode})();
  `;
}

打包打包后的代码

var offlineSign = '离线计算出的签名'
(function abc() {
    var onlineSign = calc_sign(abc.toString());
    if (onlineSign !== offlineSign) {
        // do something
    }
})();

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.