赞
踩
进行翻页请求抓包,发现加密参数为m
打上xhr断点
调试堆栈,发现m加密代码位置在9431行 r.m = n[e(528)](btoa, p_s),p_s为时间戳,n[e(528)]鼠标选中放在上面显示为一个函数,m是通过n[e(528)]这个函数传入btoa和时间戳加密生成的,到此分析完毕。
先执行下面代码,打开猿人学第16题界面
# -*- coding:utf-8 -*- from selenium import webdriver from flask import Flask, request options = webdriver.ChromeOptions() options.add_argument("--disable-blink-features=AutomationControlled") options.add_experimental_option("excludeSwitches", ["enable-automation"]) driver = webdriver.Chrome(options=options, executable_path='chromedriver') driver.maximize_window() url = 'http://match.yuanrenxue.com/match/16' driver.get(url) app = Flask(__name__) app.debug = False def get_encrypt_data(timestamp): js = """return get_m(btoa, "{}");""".format(timestamp) decrypt_data = driver.execute_script(js) return decrypt_data @app.route('/get_m', methods=['GET']) def douban(): timestamp = request.args.get("timestamp") m = get_encrypt_data(timestamp) return m if __name__ == '__main__': app.run()
然后打开控制台,打下断点,如上面第一步骤中所示位置,后在控制台输入get_m = n[e(528)],使n[e(528)]赋值给get_m这个函数,然后过掉断点,关闭控制台即可。现在selenium就能够执行get_m这个函数了,
# -*- coding:utf-8 -*- import requests import time def get_m(timestamp): url = 'http://127.0.0.1:5000/get_m?timestamp={}'.format(timestamp) resp = requests.get(url=url) m = resp.text return m headers = {"User-Agent": "yuanrenxue.project"} sums = 0 for i in range(1, 6): timestamp = str(int(time.time() * 1000)) m = get_m(timestamp) url = f"http://match.yuanrenxue.com/api/match/16?page={i}&m={m}&t={timestamp}" response = requests.get(url=url, headers=headers).json() for data_dict in response["data"]: sums += data_dict["value"] print(sums)
总结:当别人还在还原混淆代码、扣代码的时候,结果我们已经计算出来了,不用关心其中的任何加密逻辑,是不是非常高效。而且思路代码非常固定,只需几分钟就可以搞定
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。