Skip to main content

Core libraries for ZIRC project (GFL Protocol)

Project description

GFLZIRC

Fundamentally, gflzirc reverse-engineers the AC.AuthCode$$Authcode methodology. This emancipation allows us to directly forge data packets and communicate with the game servers, seamlessly circumventing the native client.

1. Architecture

The repository is structured to encapsulate diverse functionalities—ranging from low-level cryptographic operations to high-level HTTP client abstractions.

.
├── gflzirc                 # Core Package: gflzirc   ├── __init__.py             # Public API exports   ├── client.py               # High-level HTTP client mimicking Unity requests   ├── constants.py            # System constants, endpoints, and static keys   ├── crypto.py               # Bespoke encryption/decryption algorithms   └── proxy.py                # MITM proxy with robust HTTP stream parsing
├── pyproject.toml          # PyPI configuration
└── README.md               # Package documentation

2. Crypto

The cryptographic mechanism bifurcates into "Encode" and "Decode," though our primary focus remains on the former for payload forgery. The algorithm is a highly idiosyncratic variant of Discuz! AuthCode.

Below is the conceptual breakdown reverse-engineered via IDA Free.

2.1 External

This module serves as the interface between the game's Il2Cpp environment and the core cryptographic functions.

Signature: System_String_o* AC_AuthCode__Encode (System_String_o* source, System_String_o* key, const MethodInfo* method);

It conducts class initialization and type-checking within Il2Cpp before invoking the underlying AuthCode implementation, defaulting to an expiry time of 3600 seconds (1 hour).

/**
 * @brief "Signature": "System_String_o* AC_AuthCode__Encode (System_String_o* source, System_String_o* key, const MethodInfo* method);",
 *
 * @note An external call of encode or decode.
 */
__int64 __fastcall sub_181B07AE0(__int64 a1, __int64 a2)
{
	/**
	 * @brief Class initialization and type checking in Il2Cpp
	 * 
	 * @note It's doesn't matter.
	 */
	if ( !byte_184BF59BC )
  	{
    	sub_18018E100(8668);
    	byte_184BF59BC = 1;
	}
	if ( (*(_BYTE *)(qword_184C71FB8 + 295) & 2) != 0 && !*(_DWORD *)(qword_184C71FB8 + 216) )
		i981y4i12xrscakfbuqluj0dl_0();

	/**
	 * @brief Call AC.AuthCode$$Authcode (source, key, operation=0, expiry=3600)
	 * 
	 * @param operation, 0 encode, 1 decode.
	 * @param expiry, 1 hour i.e. 3600 seconds.
	 */
	return sub_181B06A50(a1, a2, 0, 3600, 0);
}

2.2 Encode

Sunborn implements a proprietary modification of the standard Discuz! AuthCode. The salient deviations are as follows:

  1. Eradication of keyc (Random Prefix): Standard algorithms append a 4-bit random character to the ciphertext header to guarantee uniqueness. Sunborn deliberately omits this. The resulting Base64 string is pure RC4 ciphertext devoid of any random prefix.
  2. Cryptkey Derivation:
    • Standard: cryptkey = keya + MD5(keya + keyc)
    • Sunborn: cryptkey = keyb + MD5(keyb)
  3. Checksum Shift:
    • Standard: checksum = MD5(plaintext + keyb)[0:16]
    • Sunborn: checksum = MD5(plaintext + keya)[0:16]

2.3 Decode

The decoding sequence accurately reverses the aforementioned operations, explicitly managing the idiosyncratic 26-byte payload alignment and verifying the modified checksum. Additionally, the Python implementation accommodates GZIP decompression, as the server frequently compresses the underlying JSON payload before RC4 encryption.

3. Constants

The constants.py module acts as the central taxonomy for the game's static data, dictating routing, authentication bootstraps, and API endpoints.

  1. Server Routing (SERVERS): Maps server codenames (e.g., M4A1, EN, M16) to their respective base URLs, facilitating cross-region compatibility.
  2. Cryptographic Keys:
    • STATIC_KEY ("yundoudou"): The pivotal bootstrap key. The server enforces this static key to decrypt the initial handshake.
    • DEFAULT_SIGN: An initial pseudo-random sequence utilized prior to the acquisition of a dynamic session key.
  3. API Endpoints: Categorizes over a dozen server endpoints into logical domains such as Mission operations (API_MISSION_START, API_MISSION_TEAM_MOVE), Index queries, Gun management, and Daily resets.
  4. Macro Configurations: Embeds hardcoded sequences (e.g., GUIDE_COURSE_11880) imperative for automated tactical maneuvering.

4. Proxy

To facilitate debugging and real-time telemetry analysis—especially for Windows users—the proxy.py module deploys a robust Man-in-the-Middle (MITM) architecture.

  1. Robust Stream Parsing: The bespoke HttpStreamDecoder handles raw socket traffic. It flawlessly mitigates TCP fragmentation by resolving Content-Length constraints and decoding Chunked Transfer-Encoding on the fly.
  2. Traffic Interception & Analysis: It filters outbound requests to the index.php API, decrypts the outdatacode payload in real-time, and triggers user-defined callbacks (C2S and S2C events).
  3. Dynamic Key Upgrade Mechanism: Crucially, the proxy scrutinizes incoming server responses. When the server provisions a new dynamic sign key, the proxy autonomously captures it (SYS_KEY_UPGRADE event) and overwrites the active cryptographic key to ensure uninterrupted decryption of subsequent packets.
  4. System Integration: Exposes set_windows_proxy which directly manipulates the Windows Registry (winreg) and leverages ctypes to flush wininet options, seamlessly routing OS-level traffic into our python-based interceptor.

5. Client

The GFLClient (client.py) is an autonomous, high-level abstraction built atop the requests library, designed to orchestrate direct server communications without proxy dependencies.

  1. Header Spoofing: Automatically injects User-Agent and X-Unity-Version headers to mimic the intrinsic Unity engine behavior meticulously.
  2. State Management: Maintains an active HTTP session, deliberately bypassing global proxy variables to prevent loopback errors.
  3. Transparent Cryptography: Completely abstracts the AuthCode complexity. It inherently serializes Python dictionaries into JSON, executes the RC4 variant encryption using the current sign_key, and structures the HTTP POST outdatacode parameters.
  4. Resilience & Decryption: It parses the idiosyncratic server responses (often prefixed with #), decrypts the payload, and provides built-in retry mechanisms with configurable timeouts to mitigate transient network failures.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gflzirc-0.4.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gflzirc-0.4.1-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file gflzirc-0.4.1.tar.gz.

File metadata

  • Download URL: gflzirc-0.4.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gflzirc-0.4.1.tar.gz
Algorithm Hash digest
SHA256 bff696bba1a05881cb77d159a504c2f9e1d3a9b609e652349f9d3aaa3a92f0fa
MD5 e41a3a7f18ce5ce7b376aa13f38d7ab2
BLAKE2b-256 5b8518a908f8173357027a4efe451ea6060cc9d74e9de1304843abba9f65742d

See more details on using hashes here.

File details

Details for the file gflzirc-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: gflzirc-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gflzirc-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 423d131c082e0d9ea9bf5e2f36c5d1f13a0bf5e6a3d38565258d5fbca79dc39d
MD5 f0636cbde7184ce5e99aff61831cb0d1
BLAKE2b-256 bc179f169101c2a12cd0c7e6e163d0e3a66adc16451bf41bacf21448dc525aa3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page