336 字
2 分钟
马蜂窝 sn参数

网址: 北京景点介绍,北京旅游景点,北京景点推荐 - 马蜂窝

景点接口: https://www.mafengwo.cn/ajax/router.php

目标参数: _sn

控制台无限debugger#

这个应该是使用了 eval(‘debugger’) 或 setInterval(‘debugger’, sec) 进行的无限debugger, hook这两个方法即可

或者使用油猴插件: user-script/remove-limits/user-script.js at main · HL-Bo/user-script

使用永不在此停留 会导致浏览器特别卡

// 尝试禁用 debugger
// 仅在 eval('debugger') 或 setInterval('debugger', sec) 构造前执行才能阻止
try {
Function.prototype.$rl_constructor = Function.prototype.constructor;
Function.prototype.constructor = function () {
if (arguments && typeof arguments[0] === 'string') {
if ('debugger' === arguments[0]) {
console.debug('Disable an function which may execute debugger');
return;
}
}
return Function.prototype.$rl_constructor.apply(this, arguments);
};
} catch (error) { console.warn(error); } finally { }

定位#

翻页时会调用 router.php 接口, 其中包含_sn参数对接口做了签名

image-20241124215321653

image-20241124220742813

跟栈找调用, 找到这个cA函数, 发现第二次执行标记行时生成的_sn参数

image-20241122112043253

image-20241124220948681

混淆js: js.mafengwo.net/js/hotel/sign/index.js?1631273413

反混淆工具: JS : JavaScript 反混淆 / 反编译 / 解密在线工具 — 吾要是知

image-20241124221606938

插庄记录日志点, 分析逻辑

image-20241124222855869

image-20241122115512708

所以接下来把这个hash函数还原即可, 本来想使用python算法还原的, 但是后面有个方法调用太大一坨js了, 还是把js扣下来执行js更快一点

image-20241122132037618

还原测试与debug一致, 且接口测试可用即通过

image-20241122132145143

马蜂窝 sn参数
https://blog.tiamix.cn/posts/马蜂窝-sn参数/
作者
Tiam
发布于
2024-11-24
许可协议
CC BY-NC-SA 4.0