protocol-reverse
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseProtocol Reverse Engineering
Protocol Reverse Engineering
ACTION REQUIRED(读完后立刻执行)
ACTION REQUIRED (Execute Immediately After Reading)
- : 读取
NOW— 确认授权与常规操作边界../field-journal/precedent-reverse.md - : 确认任务是否为协议/流量/序列化格式逆向(非纯 Web 参数签名 → 转
NOW)js-reverse/ - : 若有目标网络交互 →
NOW完成 scope;../scripts/case-init.ps1未 granted 禁止对目标 ACTauth - : 读取
NEXT;缺工具 bootstrap(tshark/wireshark 等可能需手动)../tool-index.md - : 进入工作流 Phase 1,产出帧布局或消息字典草稿
ACT
- : Read
NOW— Confirm authorization and regular operation boundaries../field-journal/precedent-reverse.md - : Confirm whether the task is protocol/traffic/serialization format reverse engineering (not pure Web parameter signature → redirect to
NOW)js-reverse/ - : If there is target network interaction → Complete scope with
NOW; No ACT on target if../scripts/case-init.ps1is not grantedauth - : Read
NEXT; Bootstrap missing tools (tshark/wireshark etc. may require manual setup)../tool-index.md - : Enter Phase 1 of the workflow, produce draft frame layout or message dictionary
ACT
适用场景
Applicable Scenarios
- 自定义 TCP/UDP 二进制协议
- Protobuf / gRPC / FlatBuffers / MessagePack
- WebSocket / MQTT / 私有 RPC
- PCAP / PCAPNG 还原字段与状态机
- 客户端-服务端校验、序列号、加密帧头
- Custom TCP/UDP binary protocols
- Protobuf / gRPC / FlatBuffers / MessagePack
- WebSocket / MQTT / Private RPC
- PCAP / PCAPNG field and state machine recovery
- Client-server verification, serial numbers, encrypted frame headers
不走本 skill
Not Applicable to This Skill
| 情况 | 去哪 |
|---|---|
| 仅 HTTP 参数签名 / JS 加密 | |
| 仅 TLS 证书问题 | |
| 固件内协议栈深挖 + 仿真 | |
| Scenario | Redirect To |
|---|---|
| Only HTTP parameter signature / JS encryption | |
| Only TLS certificate issues | |
| In-depth firmware protocol stack + emulation | |
工作流
Workflow
Phase 1 — 采集与分诊
Phase 1 — Collection and Triage
text
□ 拿到样本:PCAP / 代理导出 / 客户端日志 / 二进制
□ 标记方向:C→S / S→C;是否有握手、心跳、重连
□ 固定头?魔数?长度字段?TLV?定长?
□ 是否压缩(zlib/gzip/lz4)或加密(AES/ChaCha 帧内)
□ tshark -r cap.pcap -T fields -e frame.number -e ip.src -e tcp.payloadtext
□ Obtain samples: PCAP / proxy exports / client logs / binaries
□ Mark direction: C→S / S→C; Check for handshake, heartbeat, reconnection
□ Fixed header? Magic number? Length field? TLV? Fixed-length?
□ Compressed (zlib/gzip/lz4) or encrypted (AES/ChaCha in-frame)?
□ tshark -r cap.pcap -T fields -e frame.number -e ip.src -e tcp.payloadPhase 2 — 帧布局还原
Phase 2 — Frame Layout Restoration
text
□ 对齐多个同类消息,找不变字节 / 自增序列号
□ 长度字段:大端/小端、含头/不含头
□ 校验:CRC16/32、checksum、HMAC 位置
□ 画出状态机:Connect → Auth → Ready → Request/Response → Close
□ 工具:Wireshark 自定义 dissector 草稿 / ImHex / 010 Editor 模板 / Kaitai Structtext
□ Align multiple similar messages to find invariant bytes / auto-increment serial numbers
□ Length field: big-endian/little-endian, includes header/excludes header
□ Verification: CRC16/32, checksum, HMAC position
□ Draw state machine: Connect → Auth → Ready → Request/Response → Close
□ Tools: Wireshark custom dissector draft / ImHex / 010 Editor template / Kaitai StructPhase 3 — 序列化与加密
Phase 3 — Serialization and Encryption
text
□ Protobuf:.proto 恢复(blackboxprotobuf / pbtk / protoc --decode_raw)
□ gRPC:HTTP/2 headers + protobuf body
□ 加密:找密钥派生(客户端 so/dll/JS)→ 联合 ida-reverse / js-reverse / apk-reverse
□ 重放:仅在授权 scope 内;先无害字段再敏感操作text
□ Protobuf: .proto recovery (blackboxprotobuf / pbtk / protoc --decode_raw)
□ gRPC: HTTP/2 headers + protobuf body
□ Encryption: Find key derivation (client so/dll/JS) → Collaborate with ida-reverse / js-reverse / apk-reverse
□ Replay: Only within authorized scope; Test harmless fields first then sensitive operationsPhase 4 — 产物
Phase 4 — Deliverables
text
MUST 产出:
- 消息类型表(name / opcode / fields)
- 至少 1 条可复现的解码命令或脚本
- Evidence:原始 hex 摘录 + 解码结果(脱敏)text
MUST produce:
- Message type table (name / opcode / fields)
- At least 1 reproducible decoding command or script
- Evidence: Excerpt of raw hex + decoded results (desensitized)工具链
Toolchain
| 工具 | 必需 | 用途 | 自举 |
|---|---|---|---|
| tshark / Wireshark | 强烈建议 | PCAP 解析 | 手动 / winget |
| Python3 | 是 | 解码脚本 | 系统 |
| blackboxprotobuf | 可选 | 未知 protobuf | pip |
| ImHex / 010 | 可选 | 结构模板 | 手动 |
| IDA / r2 / Ghidra | 按需 | 客户端序列化函数 | 见对应 skill |
| Tool | Required | Purpose | Bootstrap |
|---|---|---|---|
| tshark / Wireshark | Highly Recommended | PCAP parsing | Manual / winget |
| Python3 | Yes | Decoding scripts | System-provided |
| blackboxprotobuf | Optional | Unknown protobuf analysis | pip |
| ImHex / 010 | Optional | Structure templates | Manual |
| IDA / r2 / Ghidra | As Needed | Client serialization functions | See corresponding skill |
参考
References
- — 帧布局与 Protobuf 速查
references/protocol-workflow.md - 相关:
../ida-reverse/../js-reverse/../firmware-pentest/../pentest-tools/
- — Quick reference for frame layout and Protobuf
references/protocol-workflow.md - Related:
../ida-reverse/../js-reverse/../firmware-pentest/../pentest-tools/
路由上下文
Routing Context
上游: R21 ·
下游: 需客户端算法 →/;需利用重放 → /
同级:(C2 协议)、(流量取证)
MASTER-ROUTINGrouting.md下游: 需客户端算法 →
ida-reversejs-reversepentest-toolsapi-security同级:
malware-analysisdigital-forensicsUpstream: R21 ·
Downstream: Client algorithm required →/; Replay exploitation required → /
Peer: (C2 protocols), (traffic forensics)
MASTER-ROUTINGrouting.mdDownstream: Client algorithm required →
ida-reversejs-reversepentest-toolsapi-securityPeer:
malware-analysisdigital-forensics任务完成自检
Task Completion Self-Check
- 是否还原了消息布局或状态机(而非只贴 hex)?
- 是否有可复现解码命令?
- 是否遵守 scope / 脱敏?
- 是否回写 field-journal / 报告 Checklist?
- Has the message layout or state machine been restored (instead of just pasting hex)?
- Is there a reproducible decoding command?
- Have scope / desensitization rules been followed?
- Has the field-journal / report Checklist been updated?