JS逆向-补环境之同花顺cookie中的v参数 前言该文章为学习使用严禁用于商业用途和非法用途否则由此产生的一切后果均与作者无关如有侵权请私信联系作者删除~需求目标网站aHR0cDovL3EuMTBqcWthLmNvbS5jbi8正文对于cookie反爬虫我们可以使用hook控制台输入(function(){Object.defineProperty(document,cookie,{set:function(val){if(val.indexOf(v)!-1){debugger;}console.log(Hook捕获到cookie设置-,val);returnval;}});})();通过调用堆栈进入到D方法可以看到n就是我们的v参数进入rt.update()方法转到D()方法上这个就是v的生成方法我们把整个JS代码整个复制下来JS生成的cookie必须采用document.cookie 去复制打印一下cookie的值在浏览器跑一下是可以跑通的证明代码没问题本地跑一下第一次跑补 document {}第二次跑补 window global第三次跑此处下断点调试一下p d 是一个head它是获取这个head所以我们应该是要补这个得环境我们在浏览器输出一下看看它返回得是一个数组JS给方法传参会存储在一个arguments里面我们也可以用个arguments接收一下让它自动吐出来我们可以把这个方法重写一下第四次跑这里同上第五次跑这里先给它一个空的方法看看第六次跑断点调试可知 s[201] 是plugins把环境补上第七次跑运行没有报错但是也没有生成对应的值。所以需要找一下有没有用try方法try特别多我们可以先从入口文件开始找起找到o方法打印一下异常看是否能捕获到断点调试可知是调用了documentElement的addBehavior属性所以我们补一个空对象就可以了第八次跑报了一个length这个我们可以上代理让它自动吐环境windownewProxy(window,{set(target,property,value,receiver){console.log(设置属性set window,property,typeofvalue);returnReflect.set(...arguments);},get(target,property,receiver){console.log(获取属性get window,property,typeoftarget[property]);returntarget[property]}});documentnewProxy(document,{set(target,property,value,receiver){console.log(设置属性set document,property,typeofvalue);returnReflect.set(...arguments);},get(target,property,receiver){console.log(获取属性get document,property,typeoftarget[property]);returntarget[property]}});navigatornewProxy(navigator,{set(target,property,value,receiver){console.log(设置属性set navigator,property,typeofvalue);returnReflect.set(...arguments);},get(target,property,receiver){console.log(获取属性get navigator,property,typeoftarget[property]);returntarget[property]}});locationnewProxy(location,{set(target,property,value,receiver){console.log(设置属性set location,property,typeofvalue);returnReflect.set(...arguments);},get(target,property,receiver){console.log(获取属性get location,property,typeoftarget[property]);returntarget[property]}});补一个navigator userAgent第九次跑这里补一个空的方法就可以了navigator.javaEnabled null_funcion第十次跑获取属性get location href undefinedTypeError: Cannot read properties of undefined (reading ‘split’)补 href:‘http://q.10jqka.com.cn/’第十一次跑获取属性get location protocol undefinedTypeError: Cannot read properties of undefined (reading ‘split’)补 protocol:‘http:’第十二次跑获取属性get location hostname undefined获取属性get location host undefined同上第十三次跑获取属性get window XMLHttpRequest undefined获取属性get window ActiveXObject undefined设置属性set window CHAMELEON_CALLBACK functionReferenceError: Element is not defined补 window.XMLHttpRequest null_funcionwindow.ActiveXObject null_funcion第十四次跑ReferenceError: Element is not defined定位一下报错的位置补一个空对象Element {prototype:{}}终于终于终于结果出来了但又有一个新问题程序貌似陷入了循环不结束也不报错冷静分析一下这里应该是用了setInterval()方法这是一个定时执行的方法可以全局搜一下那么我们可以用这个方法失效即重新定义方法让方法置空setInterval function(){}再跑一下结果出来了~~最后附上需要补的环境document{documentElement:{}};windowglobal;navigator{plugins:{},userAgent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36}head{}div{}location{href:http://q.10jqka.com.cn/,protocol:http:,hostname:q.10jqka.com.cn,host:q.10jqka.com.cn}Element{prototype:{}}null_funcionfunction(){console.log(arguments)}getElementsByTagNamefunction(val){if(valhead){return[head]}}createElementfunction(val){if(valdiv){returndiv}}addEventListenernull_funcion// 事件监听window.XMLHttpRequestnull_funcion window.ActiveXObjectnull_funcion navigator.javaEnablednull_funcion document.addEventListeneraddEventListener document.createElementcreateElement document.getElementsByTagNamegetElementsByTagNamesetIntervalfunction(){}最后欢迎联系作者交流更多