03 js调试技巧
找数据加密的位置
- 确定要找的参数
- 找到起始位置
- 跟调用堆栈
- 确定加密位置
- xhr 断点 -> xhr提取断点
- dom 断点 -> 定位元素 -> 监听点击事件
demo
04 HOOK技术
<img src="https://gitee.com/kualk/pic-go/raw/master/imgs/image-20250820111125814.png" alt="image-20250820111125814" />
debugger参考文档:https://www.cnblogs.com/liyuanhong/articles/18210072
web接口大全(看不懂js代码的时候搜查):Web API
写好了的hook代码直接用:JavaScript常用的Hook脚本 - 小伟哥哥~ - 博客园
npm源:npm config set registry https://registry.npm.taobao.org
加密的位置:
- 加载html
- 加载js代码
- 用户触发事件(ajax)
- 构造请求对象
- 请求拦截器
- 发送请求
- 返回数据
- 响应拦截器(解密)
- 请求成功的回调
构造debugger
- 定时器
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<h1 id="box"></h1>
<body>
<script>
var ss = document.getElementById('box')
function ff() {
debugger;
}
setInterval(ff,100);
ss.innerHTML = "大家晚上好";
</script>
</body>
</html>- 控制台监测
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
function resize(){
var threshold = 200;
var widthThreshold = window.outerWidth - window.innerWidth > threshold;
var heightThreshold = window.outerHeight - window.innerHeight > threshold;
if(widthThreshold || heightThreshold){
debugger
console.log('控制台打开了')
}
}
setInterval(resize, 100)
</script>
hello
</body>
</html>- 构造器断点
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
function check() {
function doCheck(a) {
(function() {}["constructor"]("debugger")()); //debugger
doCheck(++a);
}
try {
doCheck(0)
} catch(err) {
console.log(err)
}
};
check()
variable = Function("debugger;");
variable();
</script>
hello
</body>
</html>- HOOK跳过构造器debugger代码(异步生成的):
js
var _constructor = constructor;
Function.prototype.constructor = function(s) {
if ( s== "debugger") {
console.log(s);
return null;
}
return _constructor(s);
}跳过debugger
- 不再此处暂停
- 添加条件断点(False,拒绝执行)
- 方法置空(将方法=null,会影响代码逻辑)
- 替换文件(注释debugger,删代码)
- 注入代码(if else跳过debugger的情况)
demo
hanghangcha.com
q.10jqka.com.cn
教学与科研单位 跳过debugger
05 JS调用和扣代码
调用js代码的方法
- 包PyExecJS(同步库)
python
import execjs
print(execjs.get()) # 确保版本为Node.js(V8)
# 出现问题,重装pycharm- 使用进程库subprocess在终端调用js文件执行,捕捉执行结果(异步方法)(调用异步方法,打印结果。才能接收数据)
python
import subprocess
res = subprocess.run(['node', 'test.js'], capture_output=True, text=True)
print(res.stdout.strip()) # stdout:需要将结果输出到控制台- js库express 使用nodejs开发js接口进行调用js代码
shell
npm install express加密算法
分类
哈希算法
- MD5(Message-Digest Algorithm)
- 长度:32位
- 数据:16进制
- SHA
- HMAC
- MD5(Message-Digest Algorithm)
对称加密
非对称加密
安装库
shell
npm install crypto-js拦截器类型
- 请求拦截器
- 发送请求
- 响应拦截器