JS常用脚本
学习目标:
- 整理各类JS逆向常用脚本作为辅助工具
- 整理Github中的优秀工具类
1:cv2识别滑块缺口距离
参考: https://articles.zsxq.com/id_h1r11qakaawv.html
1 2 3 4 5 6 7 8 9 10 11 12 13
| def get_dis(bg,fg): img = cv2.imread(bg) temp = cv2.imread(fg) res = cv2.matchTemplate(img,temp,cv2.TM_CCORR_NORMED) value = cv2.minMaxLoc(res)[2][0] dis = value * 242 / 360 return dis
|
2. 内存漫游
Github地址:https://github.com/JSREI/ast-hook-for-js-RE
该工具主要用于协助JS逆向过程中的快速定位参数加密位置;
视频参考:https://www.bilibili.com/video/BV1so4y1o7qr/?vd_source=a20d3f39da1de08799d5b4b6e48c0a7e
1 2 3 4 5 6 7 8 9
| npm install anyproxy
anyproxy ca http:
node proxy-server.js
|
3.常用的Hook脚本
Hook Json.stringfy
1 2 3 4 5 6 7 8
| (function() { var stringify = JSON.stringify; JSON.stringify = function(params) { console.log("Hook JSON.stringify ——> ", params); debugger; return stringify(params); } })();
|
Hook Json.parse
1 2 3 4 5 6 7 8
| (function() { var parse = JSON.parse; JSON.parse = function(params) { console.log("Hook JSON.parse ——> ", params); debugger; return parse(params); } })();
|
1 2 3 4 5 6 7 8 9
| (function () { var org = window.XMLHttpRequest.prototype.setRequestHeader; window.XMLHttpRequest.prototype.setRequestHeader = function (key, value) { if (key == 'Authorization') { debugger; } return org.apply(this, arguments); }; })();
|
Hook Url
1 2 3 4 5 6 7 8 9
| (function () { var open = window.XMLHttpRequest.prototype.open; window.XMLHttpRequest.prototype.open = function (method, url, async) { if (url.indexOf("login") != 1) { debugger; } return open.apply(this, arguments); }; })();
|
Hook Eval
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| (function() { window.__cr_eval = window.eval; var myeval = function(src) { console.log(src); console.log("=============== eval end ==============="); debugger; return window.__cr_eval(src); } var _myeval = myeval.bind(null); _myeval.toString = window.__cr_eval.toString; Object.defineProperty(window, 'eval', { value: _myeval }); })();
|
Hook Cookie
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| (function () { 'use strict'; var cookieTemp = ''; Object.defineProperty(document, 'cookie', { set: function (val) { if (val.indexOf('__dfp') != -1) { debugger; } console.log('Hook捕获到cookie设置->', val); cookieTemp = val; return val; }, get: function () { return cookieTemp; }, }); })();
(function () { 'use strict'; var org = document.cookie.__lookupSetter__('cookie'); document.__defineSetter__('cookie', function (cookie) { if (cookie.indexOf('__dfp') != -1) { debugger; } org = cookie; }); document.__defineGetter__('cookie', function () { return org; }); })();
|
Hook Function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| (function() { window.__cr_fun = window.Function; var myfun = function() { var args = Array.prototype.slice.call(arguments, 0, -1).join(","), src = arguments[arguments.length - 1]; console.log(src); console.log("=============== Function end ==============="); debugger; return window.__cr_fun.apply(this, arguments); } myfun.toString = function() { return window.__cr_fun + "" } Object.defineProperty(window, 'Function', { value: myfun }); })();
|