Skip to content

Commit 865df28

Browse files
[投稿] 添加脚本: Cookie解析2.0 — by Silence
1 parent 6ba9abe commit 865df28

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# 2026-3-23 by.Silence 推荐使用stream进行抓包Cookie,抓包关键词query,复制curl即可,运行脚本自动解析Cookie。疯狂亏内x_x
2+
import re
3+
import os
4+
import sys
5+
6+
try:
7+
import clipboard
8+
has_clip = True
9+
except:
10+
has_clip = False
11+
12+
def validate_cookie(cookie_str):
13+
if not cookie_str or len(cookie_str) < 20:
14+
return False
15+
16+
keywords = ["PvSessionId", "c_id", "ecs_token"]
17+
match_count = sum(1 for k in keywords if k in cookie_str)
18+
return match_count >= 1
19+
20+
def run_parser():
21+
raw_content = ""
22+
23+
24+
if has_clip:
25+
try:
26+
temp_data = clipboard.get()
27+
if temp_data and len(temp_data.strip()) > 50:
28+
raw_content = temp_data
29+
except:
30+
pass
31+
32+
if not raw_content:
33+
print("系统剪贴板空值或数据长度异常")
34+
print("请手动粘贴抓包原始数据并回车:")
35+
raw_content = sys.stdin.read() if not sys.stdin.isatty() else input()
36+
37+
if not raw_content or len(raw_content.strip()) < 10:
38+
print("终端输入数据校验未通过: 字符过短")
39+
return
40+
41+
42+
43+
url_m = re.search(r"(?i)(https?://[^\s'\"]+)", raw_content)
44+
cookie_m = re.search(r"(?i)Cookie:\s*([^\r\n'\"]+)", raw_content)
45+
ua_m = re.search(r"(?i)User-Agent:\s*([^\r\n'\"]+)", raw_content)
46+
host_m = re.search(r"(?i)Host:\s*([^\r\n'\"]+)", raw_content)
47+
48+
url = url_m.group(1) if url_m else "N/A"
49+
cookie = cookie_m.group(1) if cookie_m else ""
50+
ua = ua_m.group(1) if ua_m else "N/A"
51+
host = host_m.group(1).strip() if host_m else "m.client.10010.com"
52+
53+
54+
if not validate_cookie(cookie):
55+
print("\n[错误] 数据合法性校验失败")
56+
print("原因: 解析出的 Cookie 字段缺失或不符合联通接口特征")
57+
print("请检查抓包目标是否为 queryUserInfoSeven 接口")
58+
return
59+
60+
61+
result_map = {
62+
"URL": url,
63+
"HOST": host,
64+
"USER-AGENT": ua,
65+
"COOKIE": cookie
66+
}
67+
68+
report = [
69+
"RAW DATA PARSE REPORT",
70+
"=" * 40,
71+
f"▷URL : {result_map['URL']}",
72+
f"▷HOST: {result_map['HOST']}",
73+
f"▷USER_AGENT : {result_map['USER-AGENT']}",
74+
"-" * 40,
75+
f"▷COOKIE:\n{result_map['COOKIE']}",
76+
"=" * 40,
77+
"获取成功: 接下来你需要自己手动复制粘贴这些数据到联通小组件里面,即可使用"
78+
]
79+
80+
final_report = "\n".join(report)
81+
82+
try:
83+
with open("Cookie解析结果.txt", "w", encoding="utf-8") as f:
84+
f.write(final_report)
85+
print(final_report)
86+
print(f"\n解析结束,结果已同步至 PythonIDE 文档里面: Cookie解析结果.txt")
87+
except Exception as e:
88+
print(f"磁盘写入异常: {str(e)}")
89+
90+
if __name__ == "__main__":
91+
run_parser()

0 commit comments

Comments
 (0)