1、参数m加密
2、定位到加密的地方
3、window.q(t1,t2)函数利用的是webassembly组件提供函数,所以需要解析出目标文件main.wasm
4、下载main.wasm文件到本地,利用第三方库pywasm解析,pip install pywasm.
代码:
'''
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;
};
'''
###python重现该加密函数
import time
import math
import random
import pywasm
import requests
def encrypt_M():
t1 = int(int(time.time()) / 2)
t2 = int(int(time.time()) / 2 - math.floor(random.random() * 50 + 1))
print(t1, t2)
vm = pywasm.load('./main1.wasm')
r = vm.exec("encode", [t1, t2])
m = "{}|{}|{}".format(r, t1, t2)
return m
sum = 0
for page in range(1, 6):
m = encrypt_M()
api_url = "http://match.yuanrenxue.com/api/match/15?m={}&page={}".format(m, page)
headers = {
"User-Agent": "yuanrenxue.project",
}
response = requests.get(api_url, headers=headers)
data = response.json().get('data')
for v in data:
sum = sum + v.get("value")
print(sum)
######219388