demo
前端加密
import json
import time
import hashlib
import uuid
from mitmproxy import http
import requests
import requests
def request(flow: http.HTTPFlow) -> None:
if flow.request.pretty_url.startswith("http://192.168.3.18/api/"):
# 提取原始请求体
original_body = flow.request.content.decode('utf-8')
data = {"group": "zzz", "action": "req", "param": original_body}
res = requests.post("http://127.0.0.1:12080/go",data=data)
res_json = json.loads(res.text)["data"]
data_json = json.loads(res_json)
print(data_json)
# 对请求体进行加密处理(这里假设加密方法是简单的哈希)
encrypted_body = data_json["encstr"]
# 替换请求体
flow.request.text = encrypted_body
# 生成 requestId,sign 和 timestamp
request_id = data_json["requestid"]
timestamp = data_json["timestamp"]
sign = data_json["sign"]
# 添加或替换请求头
flow.request.headers["requestId"] = request_id
flow.request.headers["timestamp"] = str(timestamp)
flow.request.headers["sign"] = sign
转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。与我联系email c2VjaW5mby5tQGdtYWlsLmNvbQo=