feat: 添加多个功能模块和工具脚本
- 新增websocket客户端和服务端实现 - 添加图片压缩工具和快速压缩脚本 - 实现学生信息处理相关API - 添加MQTT客户端和消息处理功能 - 更新.gitignore忽略更多文件类型 - 添加数据库操作工具和示例 - 实现多个测试脚本和工具类
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import json
|
||||
from mitmproxy import http
|
||||
|
||||
TARGET_PREFIX = "http://150.109.18.253"
|
||||
NEW_AUTH_CODE = "VIP30-3716475E"
|
||||
NEW_USER_IDENTIFIER = "4bd05b4b67404d961b89ccdf2cc093e73506697dcf80f6ccb7cb0e671505308e"
|
||||
|
||||
|
||||
def request(flow: http.HTTPFlow) -> None:
|
||||
req = flow.request
|
||||
|
||||
# 只处理 POST 请求
|
||||
if req.method.upper() != "POST":
|
||||
return
|
||||
|
||||
# 只处理指定前缀的 URL
|
||||
if not req.pretty_url.startswith(TARGET_PREFIX):
|
||||
return
|
||||
|
||||
# 优先过滤 JSON 请求
|
||||
content_type = (req.headers.get("Content-Type") or "").lower()
|
||||
if "application/json" not in content_type:
|
||||
return
|
||||
|
||||
# 解析 JSON body
|
||||
try:
|
||||
body_text = req.get_text()
|
||||
data = json.loads(body_text) if body_text else {}
|
||||
except Exception:
|
||||
return
|
||||
|
||||
if not isinstance(data, dict):
|
||||
return
|
||||
|
||||
# 只要 body 中同时含有 auth_code 和 user_identifier 就修改
|
||||
if "auth_code" in data and "user_identifier" in data:
|
||||
data["auth_code"] = NEW_AUTH_CODE
|
||||
data["user_identifier"] = NEW_USER_IDENTIFIER
|
||||
|
||||
# 回写 JSON 到请求体
|
||||
new_body = json.dumps(data, ensure_ascii=False, separators=(",", ":"))
|
||||
req.set_text(new_body)
|
||||
|
||||
|
||||
# mitmdump -s stop.py --mode upstream:http://127.0.0.1:7890
|
||||
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"id": "6ab9b66e",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import wakeonlan\n",
|
||||
"def formatMac(mac:str):\n",
|
||||
" #8C-C5-8C-0F-A9-93\n",
|
||||
" mac = mac.replace('-',':')\n",
|
||||
" return mac\n",
|
||||
" \n",
|
||||
"# wakeonlan.send_magic_packet('8C:C5:8C:0F:A9:93', ip_address=\"192.168.0.89\")\n",
|
||||
"wakeonlan.send_magic_packet(formatMac('80-2B-F9-B5-C6-25'), ip_address=\"192.168.0.100\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "f5473029",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "base",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.12.4"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
Reference in New Issue
Block a user