ARC4 Decryption Succeeding on SMSG_AUTH_RESPONSE but Failing on SMSG_CHAR_ENUM

Abstract: Fix ARC4 decryption failure on SMSG_CHAR_ENUM by ensuring ciphertext slicing excludes the unencrypted length header to prevent byte desynchronization.

Created: 2026-08-05 by

ARC4 decryption fails on SMSG_CHAR_ENUM because the packet length header is consumed during parsing but not excluded from the ciphertext passed to the cipher. This causes a byte desynchronization where the stream cipher starts at an offset one byte too late, corrupting the character list while leaving earlier packets like SMSG_AUTH_RESPONSE intact.

The Root Cause: Header Consumption vs. Ciphertext Offset

In AzerothCore and World of Warcraft private server emulation, network packets follow a specific binary structure. The standard format for most client-to-server or server-to-client messages includes a two-byte opcode followed by a variable-length payload. However, the critical detail often missed in custom Python clients is how the length is handled relative to the encryption boundary. When you receive data from the socket, it typically arrives as a raw byte stream. For a packet like SMSG_AUTH_RESPONSE, the structure might look like this:
  1. Opcode (2 bytes): Identifies the message type.
  2. Length (2 bytes): Specifies the size of the encrypted payload that follows.
  3. Ciphertext (N bytes): The actual encrypted data.
The error occurs when your code reads the first four bytes (opcode + length) to determine what kind of packet it is. If you then pass the remaining buffer directly to the ARC4 (RC4) decryption function without accounting for the fact that the length field itself is unencrypted, you are effectively skipping the correct number of bytes only if the length field is part of the plaintext. In WoW protocol, the length field is usually sent in plaintext, but the *encryption* starts immediately after the length field. If your decryption routine consumes the length bytes but the cipher state was initialized based on the full packet including those bytes, or if you skip them incorrectly, the RC4 keystream becomes misaligned. Since SMSG_AUTH_RESPONSE is small and simple, minor offsets might not cause total failure, but SMSG_CHAR_ENUM contains a large array of character structures. Even a single-byte shift in the RC4 stream will result in garbled output for the entire remainder of the packet, causing the parser to fail completely.

Correcting the Decryption Logic

To fix this, you must ensure that the RC4 cipher is initialized with the key derived from the session, and that the input to the decrypt method consists *only* of the bytes between the end of the length header and the end of the packet. Here is the correct approach using pycryptodome:
from Crypto.Cipher import ARC4
import struct

def decrypt_wow_packet(key, raw_data):
    # 1. Parse the header
    # Assuming little-endian format common in WoW
    opcode = struct.unpack_from('

The critical line here is ciphertext = raw_data[start_offset:start_offset + length]. Many developers mistakenly slice raw_data[4:] assuming the rest of the buffer is always the payload. However, if there is trailing garbage or if the packet is fragmented, relying on the explicit length field is safer. More importantly, verify that the key used for SMSG_AUTH_RESPONSE is identical to the one used for SMSG_CHAR_ENUM. If the session key changes mid-stream due to a re-keying event, you must update the cipher instance.

Debugging Byte Alignment

If the above logic still results in corruption, you need to verify the byte alignment visually. Print the first 16 bytes of the decrypted plaintext for both packets. For SMSG_AUTH_RESPONSE, you should see valid structure headers or known constants. For SMSG_CHAR_ENUM, you expect to see a series of character records. Each character record in AzerothCore typically starts with a uint32 GUID. If your decrypted output shows random gibberish instead of sequential integers or recognizable ASCII strings for names, your keystream is off. You can also test the hypothesis by manually shifting the decryption start point. Try decrypting with start_offset = 5 or start_offset = 3. If start_offset = 3 yields readable text, it means the length field was actually 1 byte in your specific build, or the opcode was larger. However, in standard AzerothCore builds, the 4-byte header (2 opcode + 2 length) is the norm. Another common pitfall is endianness. Ensure that struct.unpack_from('), the length will be interpreted incorrectly, leading to slicing errors that mimic decryption failures.

Session Key Management

Ensure that the key used for decryption is derived correctly from the Diffie-Hellman exchange performed during authentication. If you are storing the key in a global variable, make sure it is updated if the server sends a new key via SMSG_AUTH_SESSION_CHANGED. Stale keys will cause immediate decryption failures on subsequent packets. For more details on handling cryptographic keys in similar environments, you might find How to Decrypt Private Key in Java: A Comprehensive Guide useful, although the principles of key management remain consistent across languages.

Conclusion

The failure on SMSG_CHAR_ENUM is almost certainly a parsing artifact rather than a cryptographic flaw. By strictly separating the header parsing from the ciphertext extraction and ensuring the RC4 cipher receives exactly the bytes defined by the length field, you will restore synchronization. Always validate the first few bytes of the decrypted payload to confirm structural integrity before attempting to parse complex structures like character enums.

Frequently Asked Questions

Why does SMSG_AUTH_RESPONSE work but SMSG_CHAR_ENUM fail?

Smaller packets like authentication responses are less sensitive to minor byte offsets because the payload is short and may contain repetitive or null-filled data that appears "valid" even when corrupted. Larger payloads like character enums expose the bit-flipping errors caused by RC4 desynchronization immediately, resulting in unreadable garbage data.

Do I need to reset the RC4 cipher for every packet?

Yes, unless the protocol specifies a continuous stream cipher mode. In World of Warcraft, each packet is typically encrypted independently with the same session key. You must create a new ARC4.new(key) instance for each packet decryption to ensure the keystream starts from the beginning (index 0) for every new message.

What if my decrypted data looks like random noise?

Random noise indicates a complete mismatch between the encryption key and the decryption key, or a severe byte offset issue. Verify that the key you are passing to ARC4.new() is the exact byte sequence generated during the DH key exchange, not a hex string or a truncated version of it.

Can I use AES instead of ARC4 for AzerothCore?

No, standard AzerothCore implementations for classic expansions (Vanilla, TBC, WotLK) use ARC4 (RC4) for packet encryption. Using AES would require modifying the server source code to support a different encryption suite, which breaks compatibility with official WoW clients and most existing addons.

How do I handle fragmented TCP packets?

TCP guarantees in-order delivery but does not guarantee message boundaries. You must implement a buffer that accumulates incoming bytes until a complete packet header (opcode + length) is present. Only then should you check if the full payload length is available before attempting to decrypt and parse the packet.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More