Skip to content

Commit fafabd0

Browse files
Merge pull request #41 from jinwandalaohu66/submission/cookie_2_0_mn37fkak
2 parents 6ba9abe + e07e8f6 commit fafabd0

2 files changed

Lines changed: 116 additions & 2 deletions

File tree

script_library/index.json

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"format_version": 1,
3-
"data_version": 18,
4-
"updated": "2026-03-23T13:08:52.777Z",
3+
"data_version": 19,
4+
"updated": "2026-03-23T13:11:29.200Z",
55
"announcement": null,
66
"categories": [
77
{
@@ -610,6 +610,29 @@
610610
"updated": null,
611611
"status": "active",
612612
"lines": 100
613+
},
614+
{
615+
"id": "cookie_2_0_mn37fkak",
616+
"name": "Cookie解析2.0",
617+
"name_en": "Cookie解析2.0",
618+
"desc": "相比头一个版本这次咱不用复制粘贴进去了麻烦死了😂,仅需把你自己抓到的 Cookie 拷贝,运行脚本 它会自动获取解析,生成文件在本 app文档部分。🐽",
619+
"desc_en": "相比头一个版本这次咱不用复制粘贴进去了麻烦死了😂,仅需把你自己抓到的 Cookie 拷贝,运行脚本 它会自动获取解析,生成文件在本 app文档部分。🐽",
620+
"category": "basic",
621+
"file": "scripts/basic/cookie_2_0_mn37fkak.py",
622+
"thumbnail": null,
623+
"version": 1,
624+
"file_type": "py",
625+
"author": "Silence",
626+
"author_en": "Silence",
627+
"tags": [
628+
"community"
629+
],
630+
"requires": [],
631+
"min_app_version": "1.5.0",
632+
"added": "2026-03-23",
633+
"updated": null,
634+
"status": "active",
635+
"lines": 92
613636
}
614637
]
615638
}
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)