您的位置:首页 > 新闻 > 资讯 > 【困难】 猿人学web第一届 第15题 备周则意怠,常见则不疑

【困难】 猿人学web第一届 第15题 备周则意怠,常见则不疑

2025/4/16 13:07:07 来源:https://blog.csdn.net/m0_69843492/article/details/141788338  浏览:    关键词:【困难】 猿人学web第一届 第15题 备周则意怠,常见则不疑

数据接口分析

数据接口 https://match.yuanrenxue.cn/api/match/15
请求时需要携带 page 页码,m为加密参数
cookie中没有加密信息,携带 SessionId请求即可在这里插入图片描述

加密参数还原

查看数据接口对应的 requests 栈
在这里插入图片描述
m参数 是通过 window.m() 方法执行后得到的
在这里插入图片描述

打上断点,查看 window.m() 方法执行了什么

instance = results.instance;
window.q = instance.exports.encode;
window.m = function (){t1 = parseInt(Date.parse(new Date())/1000/2);t2 = parseInt(Date.parse(new Date())/1000/2 - Math.floor(Math.random() * (50) + 1));return window.q(t1, t2).toString() + '|' + t1 + '|' + t2;
};

window.q = instance.exports.encode;

在这里插入图片描述

window.q 是请求 wasm 文件编译成的,可以在 python 调用 wasm 文件

# 首先将 wasm 二进制的文件保存到本地
import requests
response = requests.get('https://match.yuanrenxue.cn/static/match/match15/main.wasm').content
open('15.wasm', 'wb').write(response)

调用

def get_m():t1 = int((int(time.time()) * 1000) / 1000 / 2)t2 = int((int(time.time()) * 1000) / 1000 / 2 - random.randint(10, 60))result = pywasm.load('15.wasm')results = result.exec("encode", [t1, t2])return f'{results}|{t1}|{t2}'

python 代码

import requests
import pywasm
import random
import timeheaders = {"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
}
cookies = {"sessionid": "你的sessionId",
}def get_m():t1 = int((int(time.time()) * 1000) / 1000 / 2)t2 = int((int(time.time()) * 1000) / 1000 / 2 - random.randint(10, 60))result = pywasm.load('15.wasm')results = result.exec("encode", [t1, t2])return f'{results}|{t1}|{t2}'def get_math15(page):url = "https://match.yuanrenxue.cn/api/match/15"params = {"m": get_m(),"page": f"{page}"}response = requests.get(url, headers=headers, cookies=cookies, params=params)return response.json()['data']if __name__ == '__main__':nums = 0for page_ in range(1, 6):nums_list = get_math15(page_)for num in nums_list:nums += num['value']print('page: ', page_, 'nums: ', nums)

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com