常用JS Hook代码

滲透逆向 · 昨天 · 3 人浏览
// Hook eval
(function() {
    var _eval = eval; 
    eval = function() {
        console.log("eval被调用");
        debugger;
        let result = _eval.apply(this, arguments);
        console.log("eval调用结束:::",result);
        return result;
    };
})();

// Hook JSON.stringify
(function() {
    var _JSON_stringify = JSON.stringify;
    JSON.stringify = function() {
        console.log("JSON.stringify被调用:::", arguments);
        debugger;
        let result = _JSON_stringify.apply(this, arguments);
        console.log("JSON.stringify调用结束::::", result);
        return result;
    };
})();

// Hook JSON.parse
(function() {
    var _JSON_parse = JSON.parse;
    JSON.parse = function() {
        console.log("JSON.parse被调用:::", arguments);
        debugger;
        let result = _JSON_parse.apply(this, arguments);
        console.log("JSON.parse调用结束::::", result);
        return result;
    };
})();

// Hook cookie
(function () {
  var v = "";
  Object.defineProperty(document, "cookie", {
    get: function () {
      return v;
    },
    set: function (value) {
      console.log("Cookie设置值:", value);
      debugger;
      v = value;
      return value;
    },
  });
})();

// Hook header
(function (){
  var _setRequestHeader = window.XMLHttpRequest.prototype.setRequestHeader
  window.XMLHttpRequest.prototype.setRequestHeader = function (header, value) {
    if (header.toUpperCase() === 'X-Requested-With'.toUpperCase()) {
      debugger
    }
    return _setRequestHeader.apply(this, arguments)
  }
})()

// ban掉debugger
setInterval = function(){};
setTimeout = function(){};
本站立足于美利堅合衆國,請讀者自覺遵守當地法律!如有違規,本站不承擔任何法律責任! This site is based in the United States of America, readers are requested to abide by local laws! If there are any violations, this site does not bear any legal responsibility! Theme Jasmine by Kent Liao