-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_wechat_parser.py
More file actions
71 lines (59 loc) · 2 KB
/
run_wechat_parser.py
File metadata and controls
71 lines (59 loc) · 2 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""Run mitmproxy with WeChat article parser addon.
This script starts mitmproxy in local redirect mode targeting WeChatAppEx.exe
and loads the article parser addon.
"""
import subprocess
import sys
from pathlib import Path
def main():
"""Start mitmproxy with the addon."""
# Ensure output directory exists
output_dir = Path("output")
output_dir.mkdir(exist_ok=True)
# Path to addon
addon_path = Path("src/addons/wechat_article_parser.py")
if not addon_path.exists():
print(f"✗ Addon not found: {addon_path}")
return 1
print("=" * 70)
print("WeChat Article Parser")
print("=" * 70)
print()
print("Starting mitmproxy to intercept WeChat traffic...")
print(f"Addon: {addon_path}")
print(f"Output: {output_dir.absolute()}")
print()
print("Steps:")
print("1. Wait for mitmproxy to start")
print("2. Open WeChat desktop app")
print("3. Send public account history URL to File Transfer Assistant")
print("4. Click the link to open in WeChat")
print("5. Articles will be automatically extracted and saved")
print()
print("Press Ctrl+C to stop")
print("=" * 70)
print()
# Build command with SSL options
cmd = [
"mitmdump",
"--mode", "local:WeChatAppEx.exe",
"-s", str(addon_path),
"--set", "console_eventlog_verbosity=info",
"--set", "ssl_insecure=true", # Ignore SSL certificate errors
"--set", "upstream_cert=false" # Don't verify upstream certificates
]
try:
# Run mitmproxy
subprocess.run(cmd, check=True)
except KeyboardInterrupt:
print("\n\n✓ Stopped by user")
return 0
except subprocess.CalledProcessError as e:
print(f"\n✗ mitmproxy exited with error: {e}")
return 1
except FileNotFoundError:
print("\n✗ mitmdump not found. Please install mitmproxy:")
print(" pip install mitmproxy")
return 1
if __name__ == '__main__':
sys.exit(main())