The corpus includes several offline Python and shell tools for validating static RE findings without requiring a live Shaiya server. Each tool maps directly to one or more confirmed findings from the binary analysis — they either reconstruct expected wire bytes, scan existing captures, or validate static hypotheses against known constraints.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ThalissonTMora/shaiya-chat-native-re/llms.txt
Use this file to discover all available pages before exploring further.
All tools work fully offline. No live
ps_game.exe or Game.exe instance is required. Point them at your local binary, fixture, or capture file.Tool Categories
Crypto
tools/crypto/validate_a101_counter.pyValidates HMAC-SHA256 counter derivation for 0xA101 login packets offline, given a captured PRNG seed.Padding
tools/padding/build_pattern_b_packet.pyConstructs Pattern B test packets (guild/trade/area/megaphone) with configurable char[21] tail fill.tools/padding/scan_pattern_b_sends.pyScans the PE binary for memset(21) before SConnection_Send to confirm/deny stack-residue tail behavior.Wire
tools/wire/emit_session_capture.py — emits synthetic session captures from static RE findings.tools/wire/validate_d1_padding.py — validates D1 (char[21] padding) in capture logs.tools/wire/extract_plaintext_opcodes.py — scans binary blobs for chat opcodes.tools/wire/scan_capture_logs.py — scans MITM/session logs for native chat opcodes.ZoneChat & Artifacts
tools/zonechat/parse_cn_string_db.py — parses cn_string.DB, outputs message_id → text mapping.tools/artifacts/find_missing.sh — searches server data directories for missing RE artifacts (D1–D5).Quick-Reference Table
| Tool path | Purpose | Key inputs | Example command |
|---|---|---|---|
tools/crypto/validate_a101_counter.py | Validate HMAC-SHA256 counter from 0xA101 | --hex or --file, optional --prng-hex | python3 tools/crypto/validate_a101_counter.py --hex <hex> |
tools/padding/build_pattern_b_packet.py | Build Pattern B plaintext packet | --opcode, --name, --text, --tail | python3 tools/padding/build_pattern_b_packet.py --opcode guild --name PLAYER --text hello --tail stock |
tools/padding/scan_pattern_b_sends.py | Scan PE for memset(21) before send | PE binary path | python3 tools/padding/scan_pattern_b_sends.py bin/ps_game.exe |
tools/wire/emit_session_capture.py | Emit synthetic session capture log | --name, --text, -o | python3 tools/wire/emit_session_capture.py --name JACKSON --text teste |
tools/wire/validate_d1_padding.py | Validate D1 non-zero tail in captures | Capture log paths | python3 tools/wire/validate_d1_padding.py test/captures/ui_session_20260526_static.log |
tools/wire/extract_plaintext_opcodes.py | Find chat opcodes in binary blobs | --file or --hex, optional --opcodes | python3 tools/wire/extract_plaintext_opcodes.py --file capture.bin |
tools/wire/scan_capture_logs.py | Scan MITM logs for 0x11xx opcodes | Directory or log file path | python3 tools/wire/scan_capture_logs.py /path/to/captures |
tools/zonechat/parse_cn_string_db.py | Parse cn_string.DB to id→text pairs | DB file path, --format, --limit | python3 tools/zonechat/parse_cn_string_db.py test/fixtures/cn_string_stock.db |
tools/artifacts/find_missing.sh | Find missing RE artifacts on disk | One or more root directories | ./tools/artifacts/find_missing.sh /path/to/server/data |
Crypto
validate_a101_counter.py
Recomputes theGame.exe recv-path AES counter material from a captured 0xA101 body. The formula is confirmed from static analysis:
Full counter derivation (with PRNG from breakpoint)
Set a breakpoint at
Crypto_PRNGFill in Game.exe, capture the 128-byte PRNG buffer, then:Padding
build_pattern_b_packet.py
Constructs Pattern B plaintext packets (guild/trade/megaphone/area) with configurable char[21] tail fill. The --tail stock mode uses 0xCC fill to approximate MSVC debug-fill / uninit stack bytes as seen in the static analysis of Chat_BroadcastGuild @ 0x00432530.
guild (0x1104), trade (0x1103), megaphone (0x1108), area (0x1111), admin_guild (0xF104).
scan_pattern_b_sends.py
Scans the PE binary formemset(21) calls immediately before SConnection_Send to confirm or deny that the server zero-fills the char[21] tail. Static analysis of Chat_BroadcastGuild @ 0x00432530 confirms no such memset exists — the tail bytes are uninit stack residue.
Wire
emit_session_capture.py
Emits a syntheticchat_capture_live.log from static RE findings when live x64dbg capture is unavailable. Packets match scan_pattern_b_sends.py + build_pattern_b_packet.py --tail stock (MSVC uninit stack approximation 0xCC). The default output path is test/captures/ui_session_20260526_static.log.
0x1101 normal, TX/RX 0x1102 whisper, and RX Pattern B packets for trade (0x1103), area (0x1111), and guild (0x1104).
validate_d1_padding.py
Validates D1 — thechar[21] name field tail in Pattern B packets — in capture log files. Checks that the tail bytes after the NUL terminator are non-zero (stock static inference) rather than zero-filled (emulator path). Opcodes scanned: 0x1103, 0x1104, 0x1108, 0x1111, 0xF104.
extract_plaintext_opcodes.py
Scans a raw binary blob or decrypted TCP payload dump for Shaiya chat-related opcodes (0x1101–0x110B, 0x1111, 0xA101/0xA102, 0xF10x). Useful after decrypting game traffic to plaintext, or on login socket data before XOR.
0x1104 hit the tool also prints the char[21] name field and the tail bytes after the NUL terminator.
scan_capture_logs.py
Scans ShaiyaServer MITM/session logs and hex dump files for native chat opcodes. Handles both textopcode=0xXXXX markers and raw hex patterns (LE u16 0x1104 → 0411).
Existing captures in
ps_session_redis/captures/ cover the ps_session port (login/session, ~30900) — they contain 0xA101 but not game-channel 0x11xx opcodes. For chat opcodes you need a capture on game port 30800.ZoneChat
parse_cn_string_db.py
Parsesdata/cn_string.DB into ordered (message_id, text) pairs using the exact loader semantics confirmed from ZoneChat_TableLoader @ 0x00408C70. Supports text, tsv, and json output formats.
Artifacts
find_missing.sh
Searches one or more server data directories for missing RE artifacts:cn_string.DB, sysmsg-uni.txt, and any .pcap/.pcapng files. Reports file sizes for found artifacts. See docs/MISSING_ARTIFACTS_SEARCH.md for what to capture in-game.