当前位置:   article > 正文

js逆向不用扣代码系列(2)—3分钟快速破解猿人学第16题(webpack初体验)_猿人学pythonjs逆向闯关第16题解法

猿人学pythonjs逆向闯关第16题解法
网址:http://match.yuanrenxue.com/match/16

在这里插入图片描述

1.加密参数分析

进行翻页请求抓包,发现加密参数为m
在这里插入图片描述
打上xhr断点
在这里插入图片描述
调试堆栈,发现m加密代码位置在9431行 r.m = n[e(528)](btoa, p_s),p_s为时间戳,n[e(528)]鼠标选中放在上面显示为一个函数,m是通过n[e(528)]这个函数传入btoa和时间戳加密生成的,到此分析完毕。
在这里插入图片描述

2.利用selenium执行javascript,并用flask做服务端接口

先执行下面代码,打开猿人学第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()
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35

然后打开控制台,打下断点,如上面第一步骤中所示位置,后在控制台输入get_m = n[e(528)],使n[e(528)]赋值给get_m这个函数,然后过掉断点,关闭控制台即可。现在selenium就能够执行get_m这个函数了,
在这里插入图片描述

3.发送请求,获取结果
# -*- 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)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

总结:当别人还在还原混淆代码、扣代码的时候,结果我们已经计算出来了,不用关心其中的任何加密逻辑,是不是非常高效。而且思路代码非常固定,只需几分钟就可以搞定

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/89917
推荐阅读
相关标签
  

闽ICP备14008679号