当前位置: 首页 > news >正文

码上爬第八题【协程+ob混淆】

前言:此题cookie中有加密参数s,请求参数m和t也有加密,加密参数的那个js文件被ob混淆了。

  1. 第一步:尝试翻页抓包,观察数据包参数,如图所示:
    在这里插入图片描述
    在这里插入图片描述
  2. 第二步:跟栈找加密位置,如图所示:
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
  3. 第三步:经过第二步的分析,我们已经初步找到m,s,t的加密位置了,现在可以开始扣代码了,如图所示:
    在这里插入图片描述
  4. 第四步:这里我会先把每个值的加密逻辑全部捋一遍,简化我们要写的方法,如图所示:
    在这里插入图片描述
  5. 第五步:有了第四步的get_sign函数后,我们就可以开始补代码了,缺啥补啥,如下:
    在这里插入图片描述

js代码

function toHexString(_0x1ebd7f) {return Array["from"](_0x1ebd7f)["map"](_0xc67c4c => _0xc67c4c["charCodeAt"](0)["toString"](16)["padStart"](2, "0"))["join"]('');
}function mergeGroups(_0x264398) {return _0x264398["flat"]()["join"]('');
}function encryptGroup(_0x555578) {return _0x555578["map"](_0x538aee => {const _0x16263a = _0x538aee["charCodeAt"](0);let _0x1d0d16 = _0x16263a;_0x1d0d16 = _0x1d0d16 << 3 | _0x1d0d16 >>> 5;_0x1d0d16 ^= 90;_0x1d0d16 = _0x1d0d16 << 2 | _0x1d0d16 >>> 6;_0x1d0d16 ^= 63;_0x1d0d16 = _0x1d0d16 % 256;return String["fromCharCode"](_0x1d0d16);});
}function groupMessage(_0x2dffee, _0x79d0b8) {const _0x135e82 = _0x2dffee["split"](''),_0x1d7950 = [];for (let _0x2a5c42 = 0; _0x2a5c42 < _0x135e82["length"]; _0x2a5c42 += _0x79d0b8) {_0x1d7950["push"](_0x135e82["slice"](_0x2a5c42, _0x2a5c42 + _0x79d0b8));}return _0x1d7950;
}function OOOoO(_0x4e90fb) {const _0x1c3852 = 4,_0x1ba87b = groupMessage(_0x4e90fb, _0x1c3852),_0x588ee8 = _0x1ba87b["map"](encryptGroup),_0x391e71 = mergeGroups(_0x588ee8),_0x45845b = toHexString(_0x391e71);return _0x45845b;
}function OOOoOo(_0x240504, _0x8eefdc) {const _0x3a3671 = _0x240504["split"](''),_0x1959d4 = _0x8eefdc["split"](''),_0x582226 = 4;let _0x5ad857 = [];for (let _0x2d33d3 = 0; _0x2d33d3 < _0x3a3671["length"]; _0x2d33d3 += _0x582226) {let _0x38ae5f = _0x3a3671["slice"](_0x2d33d3, _0x2d33d3 + _0x582226);for (let _0x31873b = 0; _0x31873b < _0x38ae5f["length"]; _0x31873b++) {const _0x11057a = _0x38ae5f[_0x31873b]["charCodeAt"](0),_0x1a6269 = _0x1959d4[_0x31873b % _0x1959d4["length"]]["charCodeAt"](0),_0x25c979 = (_0x11057a + _0x1a6269) % 256;_0x38ae5f[_0x31873b] = String["fromCharCode"](_0x25c979);}_0x5ad857 = _0x5ad857["concat"](_0x38ae5f);}const _0x28d8b9 = _0x5ad857["join"](''),_0x36bdd2 = Array["from"](_0x28d8b9)["map"](_0x3c7e7a => _0x3c7e7a["charCodeAt"](0)["toString"](16)["padStart"](2, "0"))["join"]('');return _0x36bdd2;
}function get_sign(page){var time = new Date()["getTime"](),m =OOOoOo("oooooo" + time + page, "oooooo"),t = btoa(time),s = OOOoO("xoxoxoxo" + time);return {'m': m,'t': t,'s': s}
}

py代码

import asyncio, aiohttp, execjsclass AsyncSpider(object):def __init__(self):self.url = 'https://www.mashangpa.com/api/problem-detail/8/data/'self.headers = {'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36'}self.cookies = {'sessionid': '7iz4z3zugx9xbdrm2ykqpfaoswvf7a3o',}self.semaphore = asyncio.Semaphore(3)with open('2.js', 'r', encoding='utf') as f:self.ctx = execjs.compile(f.read())async def fetch_page(self, session, page):async with self.semaphore:sign = self.ctx.call('get_sign', page)data = {'page': f'{page}'}self.headers['m'] = sign['m']self.headers['t'] = sign['t']self.cookies['s'] = sign['s']async with session.post(self.url, headers = self.headers, cookies = self.cookies, json = data, timeout = 10) as res:data = await res.json()return data.get('current_array', [])async def parse_all_pages(self):total_sum = 0async with aiohttp.ClientSession() as session:tasks = [self.fetch_page(session, page) for page in range (1, 21)]results = await asyncio.gather(*tasks)for array in results:if array:total_sum +=sum(array)print(total_sum)if __name__ == '__main__':spider = AsyncSpider()asyncio.run(spider.parse_all_pages())
http://www.dtcms.com/a/331315.html

相关文章:

  • 【Java虚拟机】JVM相关面试题
  • 2025天府杯数学建模C题
  • 2025天府杯数学建模A题分析
  • 智能门锁:安全与便捷的现代家居入口
  • 第1节 从函数到神经网络:AI思路的逆袭之路
  • Mybatis学习笔记(八)
  • VS2022 C++生成和调用DLL动态链接库
  • 小杰python高级(six day)——pandas库
  • 自由学习记录(84)
  • nnDetection在windows系统下使用教程
  • 4.Ansible部署文件到主机
  • Torch -- 卷积学习day2 -- 卷积扩展、数据集、模型
  • Linux软件编程(四)多任务与多进程管理
  • 机械硬盘模块逻辑与工作原理
  • 某处卖600的【独角仙】尾盘十分钟短线 尾盘短线思路 手机电脑通用无未来函数
  • uniapp对接极光消息推送
  • 【CLR via C#(第3版)阅读笔记】类型基础
  • [特殊字符]走进华为,解锁商业传奇密码
  • K8s学习----Namespace:资源隔离与环境管理的核心机制
  • 渲染 opentype 多个字符的文本,并设置文本的渲染开始位置
  • Warm-Flow 1.8.0 重大更新
  • Lua 脚本在 Redis 中的应用
  • vivo Pulsar 万亿级消息处理实践(4)-Ansible运维部署
  • 河南萌新联赛2025第(五)场:信息工程大学补题
  • 飞书文档定时自动同步至百炼知识库
  • ESP32 I2S音频总线学习笔记(六):DIY蓝牙音箱教程
  • CVPR 2025 | 北大团队SLAM3R:单目RGB长视频实时重建,精度效率双杀!
  • 在mysql> 下怎么运行 .sql脚本
  • C#WPF实战出真汁00--项目介绍
  • 极速开发新体验_Vite构建工具详解