@walkerch/wxecho 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Xinhai Chang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,209 @@
1
+ <div align="center">
2
+
3
+ # WxEcho
4
+
5
+ **macOS Native Chat History Export Tool**
6
+
7
+ [English](./README_en.md) · [中文](./README_zh.md)
8
+
9
+ ---
10
+
11
+ <p align="center">
12
+ <img src="https://raw.githubusercontent.com/chang-xinhai/WxEcho/main/landing/public/screenshot.png" alt="WxEcho Screenshot" width="800" />
13
+ </p>
14
+
15
+ <p align="center">
16
+ <img src="https://img.shields.io/badge/macOS-11%2B-blue?style=flat-square&logo=apple" />
17
+ <img src="https://img.shields.io/badge/Platform-Apple%20Silicon-blue?style=flat-square" />
18
+ <img src="https://img.shields.io/badge/License-MIT-green?style=flat-square" />
19
+ <img src="https://img.shields.io/badge/Python-3.8%2B-yellow?style=flat-square&logo=python" />
20
+ <img src="https://img.shields.io/badge/Node.js-npm-orange?style=flat-square&logo=npm" />
21
+ </p>
22
+
23
+ > ⚠️ **DISCLAIMER**: This tool is intended for personal backup and educational purposes only. Using it may violate the Terms of Service of the messaging platform in question. The author is not responsible for any account suspension, data loss, or legal consequences resulting from the use of this software. Use at your own risk.
24
+
25
+ </div>
26
+
27
+ ---
28
+
29
+ <h2 align="center">✨ Features</h2>
30
+
31
+ <div align="center">
32
+
33
+ | Feature | Description |
34
+ |---------|-------------|
35
+ | 🔑 **Key Extraction** | Extract encryption keys directly from running process memory |
36
+ | 🔓 **Database Decryption** | Decrypt SQLCipher 4 (AES-256-CBC) encrypted databases |
37
+ | 📤 **Multi-format Export** | Export to TXT / CSV / JSON formats |
38
+ | 🔍 **Fuzzy Search** | Search contacts by nickname or remarks |
39
+ | 💬 **Group Chat Support** | Full support for group conversations |
40
+ | 🍎 **Native macOS** | Built with Mach VM API, runs natively on Apple Silicon & Intel |
41
+
42
+ </div>
43
+
44
+ ---
45
+
46
+ <h2 align="center">🚀 Quick Start</h2>
47
+
48
+ ### Prerequisites
49
+
50
+ <div align="center">
51
+
52
+ - macOS 11+ on **Apple Silicon** (M1/M2/M3/M4...)
53
+ - Desktop app 4.x (logged in, chat history synced)
54
+ - Xcode Command Line Tools: `xcode-select --install`
55
+ - Python 3.8+: `pip install pycryptodome`
56
+
57
+ </div>
58
+
59
+ ### Installation
60
+
61
+ ```bash
62
+ npm install -g @walkerch/wxecho
63
+ ```
64
+
65
+ Or manually:
66
+
67
+ ```bash
68
+ git clone https://github.com/chang-xinhai/WxEcho.git
69
+ cd WxEcho
70
+ npm install && npm run build
71
+ ```
72
+
73
+ ### Usage
74
+
75
+ ```bash
76
+ # Step 1: Re-sign the app
77
+ sudo codesign --force --deep --sign - /Applications/WeChat.app
78
+
79
+ # Re-open and log in
80
+
81
+ # Step 2: Extract Keys
82
+ sudo wxecho keys
83
+
84
+ # Step 3: Decrypt Databases
85
+ wxecho decrypt
86
+
87
+ # Step 4: Export Chat History
88
+ wxecho export -l # List all conversations
89
+ wxecho export -n "John Doe" # Export by name
90
+ ```
91
+
92
+ ---
93
+
94
+ <h2 align="center">⚙️ How It Works</h2>
95
+
96
+ <div align="center">
97
+
98
+ ```
99
+ Running App Process ──key extraction──▶ keys.json ──decrypt──▶ plaintext SQLite ──export──▶ TXT/CSV/JSON
100
+ (SQLCipher 4) (AES-256-CBC) (.db files) (chat history)
101
+ ```
102
+
103
+ The app uses [WCDB](https://github.com/nicklockwood/wcdb) (based on SQLCipher 4) with per-database AES-256 keys cached in process memory, stored as `x'<64hex_key><32hex_salt>'`.
104
+
105
+ </div>
106
+
107
+ ---
108
+
109
+ <h2 align="center">📋 CLI Commands</h2>
110
+
111
+ <div align="center">
112
+
113
+ | Command | Description |
114
+ |---------|-------------|
115
+ | `wxecho keys` | Extract database keys from running process (requires sudo) |
116
+ | `wxecho decrypt` | Decrypt local databases |
117
+ | `wxecho export [options]` | Export chat history |
118
+ | `wxecho doctor` | Check environment dependencies |
119
+
120
+ ### export Options
121
+
122
+ | Option | Description |
123
+ |--------|-------------|
124
+ | `-l, --list` | List all conversations |
125
+ | `-n, --name <name>` | Search contacts by nickname or remark |
126
+ | `-u, --username <wxid>` | Match by exact username |
127
+ | `-o, --output <dir>` | Specify output directory |
128
+ | `--top <n>` | List top N conversations (default: 20) |
129
+ | `--my-wxid <wxid>` | Your own user ID (auto-detected if omitted) |
130
+
131
+ </div>
132
+
133
+ ---
134
+
135
+ <h2 align="center">📁 Database Structure</h2>
136
+
137
+ <div align="center">
138
+
139
+ Decrypted databases in `py/decrypted/`:
140
+
141
+ </div>
142
+
143
+ ```
144
+ decrypted/
145
+ ├── contact/contact.db # Contacts
146
+ ├── session/session.db # Conversation list
147
+ ├── message/message_0.db # Chat messages (sharded)
148
+ ├── message/message_fts.db # Full-text search
149
+ ├── message/media_0.db # Voice messages
150
+ ├── sns/sns.db # Moments
151
+ ├── favorite/favorite.db # Favorites
152
+ └── ...
153
+ ```
154
+
155
+ <div align="center">
156
+
157
+ Messages for each contact/group are stored in tables named `Msg_<md5(username)>`.
158
+
159
+ </div>
160
+
161
+ ---
162
+
163
+ <h2 align="center">❓ FAQ</h2>
164
+
165
+ **Q: `task_for_pid failed` — what to do?**
166
+ Make sure: (1) running with `sudo`; (2) the app has been re-signed; (3) the app is running and logged in.
167
+
168
+ **Q: Does this work after an app update?**
169
+ Updates restore the original code signature. Re-run the re-sign step.
170
+
171
+ **Q: Why do some messages show `[Compressed Content]`?**
172
+ Some messages use zstd compression. Most text messages are unaffected.
173
+
174
+ **Q: How do I export images/videos/audio?**
175
+ This tool exports text records only. Media files are in `xwechat_files/.../Message/`, correlate via `message_resource.db`.
176
+
177
+ **Q: Are group chats supported?**
178
+ Yes. Export works the same way. Messages show sender's actual nickname/remark.
179
+
180
+ ---
181
+
182
+ <h2 align="center">🔗 Related Projects</h2>
183
+
184
+ <div align="center">
185
+
186
+ | Project | Description |
187
+ |---------|-------------|
188
+ | [ydotdog/wechat-export-macos](https://github.com/ydotdog/wechat-export-macos) | Reference project |
189
+ | [L1en2407/wechat-decrypt](https://github.com/L1en2407/wechat-decrypt) | C memory scanner |
190
+ | [Thearas/wechat-db-decrypt-macos](https://github.com/Thearas/wechat-db-decrypt-macos) | lldb key extraction |
191
+ | [ylytdeng/wechat-decrypt](https://github.com/ylytdeng/wechat-decrypt) | Original memory search |
192
+
193
+ </div>
194
+
195
+ ---
196
+
197
+ <h2 align="center">📜 License</h2>
198
+
199
+ <div align="center">
200
+
201
+ MIT License
202
+
203
+ </div>
204
+
205
+ ---
206
+
207
+ <p align="center">
208
+ Made with ❤️ by <a href="https://github.com/chang-xinhai">chang-xinhai</a>
209
+ </p>
package/bin/wxecho ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env bash
2
+ # wxecho CLI launcher
3
+
4
+ # Find the script directory
5
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
6
+ ROOT_DIR="$(dirname "$SCRIPT_DIR")"
7
+
8
+ # Try npm global prefix approach (most reliable for global installs)
9
+ if NPM_PREFIX=$(npm prefix -g 2>/dev/null); then
10
+ if [ -f "$NPM_PREFIX/lib/node_modules/wxecho/dist/cli.js" ]; then
11
+ exec node "$NPM_PREFIX/lib/node_modules/wxecho/dist/cli.js" "$@"
12
+ fi
13
+ fi
14
+
15
+ # For local development, check if pre-built dist exists
16
+ if [ -f "$ROOT_DIR/dist/cli.js" ]; then
17
+ exec node "$ROOT_DIR/dist/cli.js" "$@"
18
+ fi
19
+
20
+ # Fallback: use npx tsx to run TypeScript directly
21
+ exec npx tsx "$ROOT_DIR/src/cli.ts" "$@"