Skip to content

Commit e19f14c

Browse files
committed
Add API Services
1 parent 5113e57 commit e19f14c

16 files changed

Lines changed: 2235869 additions & 8 deletions

README.md

Lines changed: 129 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,20 @@
1111
- 🔑 **密钥流生成**:基于 API 响应中的 `decode_key` 种子值生成 131,072 字节的密钥流
1212
- 🔄 **关键步骤**:密钥流必须经过 `reverse()` 操作(这是成功解密的关键)
1313
-**XOR 解密**:对视频前 128 KB 执行 XOR 运算,还原原始 MP4 数据
14-
- 🎯 **多平台支持**:提供在线网页版、命令行工具、图形界面三种使用方式
14+
- 🎯 **多平台支持**:提供在线网页版、命令行工具、图形界面、RESTful API 四种使用方式
1515

16-
**技术栈:** JavaScript (WASM), Python 3.x, tkinter, HTML5
16+
**技术栈:** JavaScript (WASM), Python 3.x, Node.js, tkinter, HTML5, Docker
1717

1818
## ✨ 特性
1919

2020
-**浏览器内一键解密** - 无需安装任何软件,直接在网页中完成解密
2121
-**完全本地处理** - 视频数据不离开您的设备,100% 保护隐私
22+
-**RESTful API 服务** - Docker 容器化部署,支持远程调用和批量处理
23+
-**本地优先架构** - API 服务内置 WASM 文件,优先使用本地加载(速度更快,离线可用)
24+
-**智能降级机制** - 本地文件加载失败时自动切换到微信 CDN,确保服务可用性
2225
- ✅ 使用微信官方 WASM 模块(保证 100% 兼容性)
2326
- ✅ 支持完整视频解密(文件大小无限制)
24-
-提供三种使用方式:在线网页版、命令行版、图形界面版
27+
-提供四种使用方式:在线网页版、命令行版、图形界面版、API 服务
2528
- ✅ 专业级日志输出 - Hex Dump、MP4 分析、XOR 运算展示
2629
- ✅ 实时进度显示和性能统计
2730
- ✅ 包含示例文件和详细技术文档
@@ -32,6 +35,7 @@
3235

3336
- **仅浏览器内解密**:现代浏览器 (Chrome/Edge/Safari/Firefox) - 无需其他依赖
3437
- **Python 工具**:Python 3.x(仅用于 CLI/GUI 工具)
38+
- **API 服务**:Node.js 16+ 或 Docker(仅用于 RESTful API)
3539

3640
### 方式一:在线网页版(⭐ 最推荐 - 零安装)
3741

@@ -51,6 +55,8 @@ open http://localhost:8888/index.html
5155

5256
<img src="screenshots/Index.png" alt="在线解密工具界面" width="600">
5357

58+
**在线工具界面**
59+
5460
**🎬 一键解密模式**(最简单):
5561

5662
1. **输入 decode_key**
@@ -127,22 +133,137 @@ python3 decrypt_wechat_video_cli.py -i encrypted.mp4 -k keystream.txt -o decrypt
127133
python3 decrypt_wechat_video_cli.py --help
128134
```
129135

136+
### 方式四:RESTful API 服务(推荐批量处理和集成使用)
137+
138+
适合需要远程调用、批量处理或集成到其他系统的场景。
139+
140+
#### 🐳 使用 Docker(推荐)
141+
142+
```bash
143+
# 进入 API 服务目录
144+
cd api-service
145+
146+
# 使用 Docker Compose 启动
147+
docker-compose up -d
148+
149+
# 查看服务状态
150+
docker-compose ps
151+
152+
# 查看日志
153+
docker-compose logs -f
154+
```
155+
156+
#### 📦 或直接使用 Node.js
157+
158+
```bash
159+
# 进入 API 服务目录
160+
cd api-service
161+
162+
# 安装依赖
163+
npm install
164+
165+
# 启动服务
166+
npm start
167+
168+
# 开发模式(自动重启)
169+
npm run dev
170+
```
171+
172+
#### 📸 API 服务界面
173+
174+
<img src="screenshots/API.png" alt="API 服务交互式文档" width="600">
175+
176+
**API 服务交互式文档页面**
177+
178+
#### 🔌 API 调用示例
179+
180+
**完整解密视频:**
181+
```bash
182+
curl -X POST http://localhost:3000/api/decrypt \
183+
-F "video=@encrypted.mp4" \
184+
-F "decode_key=2136343393" \
185+
-o decrypted.mp4
186+
```
187+
188+
**生成密钥流:**
189+
```bash
190+
curl -X POST http://localhost:3000/api/keystream \
191+
-H "Content-Type: application/json" \
192+
-d '{"decode_key": "2136343393"}'
193+
```
194+
195+
**查看完整 API 文档:**
196+
```bash
197+
# 浏览器访问文档页面
198+
open http://localhost:3000
199+
200+
# 或获取 JSON 格式的服务信息
201+
curl http://localhost:3000/api/info
202+
```
203+
204+
#### ✨ API 服务特性
205+
206+
访问 `http://localhost:3000` 将显示一个漂亮的交互式文档页面,包含:
207+
208+
- 🎨 **美观界面** - 渐变色设计、代码高亮、响应式布局
209+
- 📊 **实时状态** - WASM 模块健康检查和服务信息
210+
- 🔌 **完整文档** - 所有 API 端点的详细说明和参数
211+
- 💡 **代码示例** - Python、JavaScript/Node.js 等多种语言
212+
-**本地优先** - 内置 WASM 文件,优先使用本地加载(速度更快)
213+
- 🛡️ **智能降级** - 本地文件加载失败时自动切换到微信 CDN
214+
- 🐳 **容器化** - Docker 镜像包含完整 WASM 文件,开箱即用
215+
- 🔒 **离线可用** - 即使没有网络也能正常工作
216+
217+
**Python 调用示例:**
218+
```python
219+
import requests
220+
221+
# 解密视频
222+
url = 'http://localhost:3000/api/decrypt'
223+
files = {'video': open('encrypted.mp4', 'rb')}
224+
data = {'decode_key': '2136343393'}
225+
226+
response = requests.post(url, files=files, data=data)
227+
228+
if response.status_code == 200:
229+
with open('decrypted.mp4', 'wb') as f:
230+
f.write(response.content)
231+
print('✅ 解密成功')
232+
```
233+
234+
📚 详细文档请查看:[api-service/README.md](api-service/README.md)
235+
130236
## 📁 文件说明
131237

132238
```
133239
WeChat-Channels-Video-File-Decryption/
134240
├── index.html # 🌐 在线一键解密工具(⭐ 推荐)
135241
├── decrypt_wechat_video_cli.py # 💻 命令行解密工具
136242
├── decrypt_wechat_video_gui.py # 🖥️ 图形界面解密工具
243+
├── api-service/ # 🚀 RESTful API 服务
244+
│ ├── server.js # Express API 服务器
245+
│ ├── worker.html # RPC Worker (浏览器 WASM 执行)
246+
│ ├── docs.html # 交互式 API 文档页面
247+
│ ├── wechat_files/ # 内置 WASM 文件(本地优先加载)
248+
│ │ ├── wasm_video_decode.wasm # Isaac64 WASM 模块(3.8 MB)
249+
│ │ ├── wasm_video_decode.js # WASM 加载器(175 KB)
250+
│ │ └── ... # 其他 WASM 相关文件
251+
│ ├── package.json # 依赖配置
252+
│ ├── Dockerfile # Docker 构建文件
253+
│ ├── docker-compose.yml # Docker Compose 配置
254+
│ └── README.md # API 服务文档
137255
├── wx_response.json # 📋 API 响应示例(包含 decode_key)
138256
├── wx_encrypted.mp4 # 🔒 示例加密文件
139257
├── wx_decrypted.mp4 # ✅ 示例解密文件
140258
├── screenshots/ # 📸 项目截图
141-
│ └── Index.png # 在线工具截图
142-
├── wechat_files/ # 📦 微信官方 WASM 模块
143-
│ ├── wasm_video_decode.wasm # Isaac64 WASM 模块
144-
│ ├── wasm_video_decode.js # WASM 加载器
145-
│ └── ...
259+
│ ├── Index.png # 在线工具截图
260+
│ └── API.png # API 服务文档截图
261+
├── wechat_files/ # 📦 微信官方 WASM 模块(供 index.html 使用)
262+
│ ├── wasm_video_decode.wasm # Isaac64 WASM 模块
263+
│ ├── wasm_video_decode.js # WASM 加载器
264+
│ ├── wasm_video_decode_fallback.js # 降级版本
265+
│ ├── worker_release.js # Worker 脚本
266+
│ └── wasm_video_decode.wat # WASM 文本格式(调试用)
146267
├── LICENSE # 📄 MIT 许可证
147268
└── README.md # 📖 本文件
148269
```

api-service/.dockerignore

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Dependencies
2+
node_modules
3+
npm-debug.log
4+
yarn-error.log
5+
6+
# Git
7+
.git
8+
.gitignore
9+
10+
# Docker
11+
Dockerfile
12+
docker-compose.yml
13+
.dockerignore
14+
15+
# Documentation
16+
README.md
17+
*.md
18+
19+
# IDE
20+
.vscode
21+
.idea
22+
*.swp
23+
*.swo
24+
*~
25+
26+
# OS
27+
.DS_Store
28+
Thumbs.db
29+
30+
# Testing
31+
test
32+
tests
33+
*.test.js
34+
*.spec.js
35+
36+
# Logs
37+
logs
38+
*.log
39+
40+
# Environment
41+
.env
42+
.env.*
43+
44+
# Temporary files
45+
tmp
46+
temp
47+
*.tmp

api-service/.gitignore

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Dependencies
2+
node_modules/
3+
package-lock.json
4+
5+
# Logs
6+
logs/
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Environment variables
19+
.env
20+
.env.local
21+
.env.*.local
22+
23+
# IDE
24+
.vscode/
25+
.idea/
26+
*.swp
27+
*.swo
28+
*~
29+
*.sublime-project
30+
*.sublime-workspace
31+
32+
# OS
33+
.DS_Store
34+
.DS_Store?
35+
._*
36+
.Spotlight-V100
37+
.Trashes
38+
ehthumbs.db
39+
Thumbs.db
40+
41+
# Temporary files
42+
tmp/
43+
temp/
44+
*.tmp
45+
46+
# Uploaded files (if any)
47+
uploads/
48+
49+
# Build output
50+
dist/
51+
build/

api-service/Dockerfile

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# ==========================================
2+
# Stage 1: Build Stage
3+
# ==========================================
4+
FROM node:18-bullseye-slim AS builder
5+
6+
WORKDIR /app
7+
8+
# Install system dependencies required for Playwright
9+
RUN apt-get update && apt-get install -y \
10+
wget \
11+
ca-certificates \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
# Copy package files
15+
COPY package*.json ./
16+
17+
# Install dependencies
18+
RUN npm install
19+
20+
# Install Playwright Chromium browser and system dependencies
21+
RUN npx playwright install chromium --with-deps
22+
23+
# ==========================================
24+
# Stage 2: Production Stage
25+
# ==========================================
26+
FROM node:18-bullseye-slim
27+
28+
WORKDIR /app
29+
30+
# Install runtime dependencies for Chromium
31+
RUN apt-get update && apt-get install -y \
32+
# Chromium dependencies
33+
libnss3 \
34+
libnspr4 \
35+
libatk1.0-0 \
36+
libatk-bridge2.0-0 \
37+
libcups2 \
38+
libdrm2 \
39+
libdbus-1-3 \
40+
libxkbcommon0 \
41+
libxcomposite1 \
42+
libxdamage1 \
43+
libxfixes3 \
44+
libxrandr2 \
45+
libgbm1 \
46+
libpango-1.0-0 \
47+
libcairo2 \
48+
libasound2 \
49+
libatspi2.0-0 \
50+
# Fonts
51+
fonts-liberation \
52+
fonts-noto-color-emoji \
53+
# Clean up
54+
&& rm -rf /var/lib/apt/lists/*
55+
56+
# Copy node_modules from builder
57+
COPY --from=builder /app/node_modules ./node_modules
58+
59+
# Copy Playwright browsers to a shared location
60+
COPY --from=builder /root/.cache/ms-playwright /ms-playwright
61+
62+
# Copy application files
63+
COPY server.js .
64+
COPY worker.html .
65+
COPY docs.html .
66+
COPY wechat_files ./wechat_files
67+
68+
# Create non-root user for security
69+
RUN groupadd -r playwright && \
70+
useradd -r -g playwright -G audio,video playwright && \
71+
mkdir -p /home/playwright && \
72+
chown -R playwright:playwright /home/playwright && \
73+
chown -R playwright:playwright /app && \
74+
chown -R playwright:playwright /ms-playwright
75+
76+
# Set Playwright browsers path
77+
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
78+
79+
# Switch to non-root user
80+
USER playwright
81+
82+
# Expose port
83+
EXPOSE 3000
84+
85+
# Health check
86+
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
87+
CMD node -e "require('http').get('http://localhost:3000/health', (r) => { process.exit(r.statusCode === 200 ? 0 : 1); }).on('error', () => process.exit(1));"
88+
89+
# Start server
90+
CMD ["node", "server.js"]

0 commit comments

Comments
 (0)