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

JS逆向|猿人学逆向反混淆练习平台第13题加密分析

关注它,不迷路。

  • 本文章中所有内容仅供学习交流,不可用于任何商业用途和非法用途,否则后果自负,如有侵权,请联系作者立即删除!

一.题目地址

https://match.yuanrenxue.cn/match/13

二.抓包分析

先打开控制台,然后再打开上面的网站,查看数据所在的页面:

发现每次请求数据页,都会先请求下面这个url:

https://match.yuanrenxue.cn/api2/13

才看数据,发现是一段js代码:

控制台运行:

原来是设置了cookie,那就很简单了。直接交给AI吧。

三.编写Python代码

import jsonimport refrom typing import Tuple import requests BASE_URL = "https://match.yuanrenxue.cn"MATCH_URL = f"{BASE_URL}/match/13"API2_URL = f"{BASE_URL}/api2/13"QUESTION_URL = f"{BASE_URL}/api/question/13"SESSIONID = "XXXXXX"USER_AGENT = "yuanrenxue" FALSE_TEXT = "false"TRUE_TEXT = "true"OBJECT_TEXT = "[object Object]" def _replace_indexed_token(expression: str, pattern: str, alphabet: str) -> str: def repl(match: re.Match[str]) -> str: index = int(match.group(1)) try: char = alphabet[index] except IndexError as exc: raise ValueError(f"Unexpected token index {index} for {alphabet!r}") from exc return f"('{char}')" return re.sub(pattern, repl, expression) def decode_cookie_assignment(js_code: str) -> Tuple[str, str]: script = js_code.strip() prefix = "document.cookie=" if not script.startswith(prefix): raise ValueError(f"Unexpected /api2/13 response: {script[:80]!r}") expression = script[len(prefix) :] if expression.endswith(";"): expression = expression[:-1] expression = expression.replace('\\"', '"') expression = re.sub(r"\s+", "", expression) expression = _replace_indexed_token( expression, r"\(\(\[\]\+!\[\]\)\[(\d+)\]\)", FALSE_TEXT, ) expression = _replace_indexed_token( expression, r"\(\(\[\]\+\!\!\[\]\)\[(\d+)\]\)", TRUE_TEXT, ) expression = _replace_indexed_token( expression, r'\(\(\{\}\+""\)\[(\d+)\]\)', OBJECT_TEXT, ) pieces = re.findall(r"\('([^']*)'\)", expression) if not pieces: raise ValueError(f"Unable to decode cookie expression: {expression[:120]!r}") assignment = "".join(pieces) if "=" not in assignment: raise ValueError(f"Decoded assignment is invalid: {assignment!r}") name, remainder = assignment.split("=", 1) value = remainder.split(";", 1)[0] return name, value def build_session() -> requests.Session: session = requests.Session() session.cookies.set("sessionid", SESSIONID, domain="match.yuanrenxue.cn", path="/") session.headers.update( { "User-Agent": USER_AGENT, "Referer": MATCH_URL, "X-Requested-With": "XMLHttpRequest", } ) return session def fetch_page(session: requests.Session, page: int) -> list[int]: api2_response = session.get( API2_URL, headers={"Accept": "*/*"}, timeout=10, ) api2_response.raise_for_status() cookie_name, cookie_value = decode_cookie_assignment(api2_response.text) session.cookies.set(cookie_name, cookie_value, domain="match.yuanrenxue.cn", path="/") print (cookie_name,cookie_value) question_response = session.get( QUESTION_URL, params={"page": page, "pageSize": 10, "kw": ""}, headers={"Accept": "application/json, text/javascript, */*; q=0.01"}, timeout=10, ) question_response.raise_for_status() payload = question_response.json() if "data" not in payload or not isinstance(payload["data"], list): raise ValueError(f"Unexpected question payload: {payload!r}") return payload["data"] def main() -> None: session = build_session() all_numbers: list[int] = [] page_results: dict[int, list[int]] = {} for page in range(1, 6): numbers = fetch_page(session, page) page_results[page] = numbers all_numbers.extend(numbers) print(f"page {page}: {json.dumps(numbers, ensure_ascii=False)}") print(f"sum: {sum(all_numbers)}") if __name__ == "__main__": main()

运行结果:

今天的分享就到这里,感谢阅读。

欢迎加入知识星球,学习更多AST和爬虫技巧。

http://www.jsqmd.com/news/643452/

相关文章:

  • Gemma-3-12b-it API封装教程:FastAPI接口开发与图文请求适配
  • OpenClaw人人养虾:openclaw logs
  • 亚洲美女-造相Z-Turbo创意工坊案例:独立艺术家用其生成NFT系列《东方十二时辰》
  • 2026奇点大会多模态翻译系统深度拆解(语音-文本-图像三模态联合推理引擎首次公开)
  • 【仅限首批读者】AIAgent隐私合规自检工具包(含12项自动扫描规则+OWASP AI-Top10映射矩阵)限时开放下载
  • 可灵会员邀请码6B3CRST3TFBL
  • Qwen3-32B长文本处理实战:128K上下文,轻松分析整本电子书
  • Java的java.util.random.RandomGenerator随机数算法实现细节
  • 196.删除重复的电子邮箱
  • MiniCPM-o-4.5-nvidia-FlagOS构建智能知识库:结合向量数据库实现精准问答
  • Nanbeige4.1-3B应用场景:制造业设备维修手册QA系统,支持PDF/图片OCR混合输入
  • 单细胞蛋白组Abseq联合流式技术,深度解锁肿瘤与感染免疫差异奥秘
  • PySide6多线程避坑指南:手把手教你用QMutex和QWaitCondition安全地暂停与恢复线程
  • Canvas Quest提示词安全与内容过滤配置教程
  • 终极Windows优化指南:3分钟用Win11Debloat释放系统性能
  • HarmonyOS 6学习:弹窗生命周期管理与异常处理实战
  • 4月15日成都地区宝钢产无缝钢管(8163-20#;外径42-630mm)现货报价 - 四川盛世钢联营销中心
  • 文墨共鸣实操手册:基于阿里达摩院StructBERT的古风AI应用落地
  • Rust的#[track_caller]:在panic信息中记录调用位置
  • 为什么说2026是AIAgent向AGI跃迁的关键窗口期?SITS2026圆桌闭门纪要首度流出(含时间锚点+技术拐点)
  • Go语言如何遍历目录文件_Go语言filepath.Walk教程【实战】
  • Qwen3-4B-Instruct-2507入门指南:一键启动vLLM服务,Chainlit轻松对话
  • Qwen2-VL-2B-Instruct部署教程:CUDA自动检测+6GB显存最低配置实测指南
  • 基于ThinkPHP与Uniapp的跨平台设备巡检系统源码解析与实战部署
  • 揭秘AIAgent模仿学习的隐式策略蒸馏:如何用1/10标注数据复现专家级行为?
  • LVGL项目片内FLASH告急?手把手教你将图片字库搬到外部SD卡/SDRAM(附V4/V5工具避坑)
  • Z-Image-GGUF批量生成与管理系统开发(Java + MySQL)
  • 5分钟快速部署Clawdbot+Qwen3:32B:开箱即用的本地AI对话系统
  • Cursor-Free-VIP技术深度解析:多维度设备指纹重置与AI编程助手访问控制机制
  • 深度解析Display Driver Uninstaller:Windows显卡驱动彻底清理的技术实现与实践指南