FairplayKD.sys, MTA:SA kernel anti-cheat driver: interface, internals, and security observations
Scope / ethics: Educational reverse engineering and defensive analysis only. No live targets, no bypass instructions, no exploit code. Analyze only systems you own or are authorized to test.
0. Summary
- FairplayKD.sys is a mid-2010s x64 Windows kernel driver shipped as part of Multi Theft Auto: San Andreas Fairplay anti-cheat stack. Our reconstruction of its command surface shows a single device IOCTL (0x22E008) with roughly twenty subcommands.
- That surface combines arbitrary kernel read/write, process/thread open/read/write, and a thread write + resume primitive. Whatever the anti-cheat's intent, this is a substantial local privileged interface.
- Obfuscation is modest: a 7-bit XOR/subtract string cipher plus runtime API resolution through MmGetSystemRoutineAddress. The IOCTL magic/checksum is protocol validation, not authentication.
- The driver also fits the T1068 vulnerable-driver pattern and loads despite HVCI, which makes it BYOVD-relevant outside its game context.
- Our analysis surfaced about a dozen internal inconsistencies that need resolving before the model can be treated as final. Those are collected in §11 and are the main contribution of this write-up.
1. Scope
Our work combined:
1. Static reconstruction of the driver's structure, architecture, command table, tracking model, obfuscation scheme.
2. Sample metadata, version info, hashes, import table, signature chain, and load behavior.
For this write-up we did not include a binary or IDB, so statements about instruction-level behavior are descriptive rather than a line-by-line decompilation. Anything marked confirm in §11 should be treated as an open verification task, not an established fact.
2. Identification
| Field | Value |
|---|---|
| Type | PE64 kernel driver (.sys), AMD64 |
| Product | MTA San Andreas |
| Role | Fairplay anti-cheat kernel component |
| Build tag | fairplay_7 |
| Drop path | C:\ProgramData\MTA San Andreas All\Common\temp\FairplayKD.sys|
| Usermode counterpart | netc.dll, the normal IOCTL caller |
| Threat classification | Vulnerable driver, MITRE T1068; recorded as loading despite HVCI |
3. Build lineage notes
- The binary is a WDK fre (free/build-release) x64 build targeting Win7-era headers.
- The signing certificate is an individual developer cert that expired in 2018. A valid signature therefore does not imply current trustworthiness.
- MTA ships netc.dll, net.dl`, and this driver as closed-source anti-cheat/netcode modules, with reduced-feature modules offered to fork builds. That fits the picture of a real shipping component rather than a lab toy.
4. Architecture overview
netc.dll (usermode, MTA client)
|
| DeviceIoControl(0x22E008) + magic 363 (0x16B) + checksum
v
+--------------------------------------------------------------+
| FairplayKD.sys (Ring 0) |
| |
| DriverEntry |
| |- CheckWindowsVersion -> dword_22E94 (OS ID) |
| |- ReadDeviceInstanceFromRegistry -> g_DeviceInstance |
| |- ResolveKernelRoutines / ResolveAllKernelRoutines |
| |- IoCreateDevice -> \Device\FairplayKD{n} |
| |- IoCreateSymbolicLink-> \DosDevices\FairplayKD{n} |
| |- PsSetCreateProcessNotifyRoutineEx |
| - ObRegisterCallbacks (process + thread) |
| |
| IRP_MJ_DEVICE_CONTROL -> HandleDeviceIoControl |
| - ProcessIoctlCommand (cmd 1, 0x78..0x8F) |
| |
| Process tracking table: 100 x 16 bytes |
| Log buffer: 100 slots, atomic writer guard |
+--------------------------------------------------------------+
|
+-- process-create.notify -> classify / track / maybe block
+-- load-image.notify -> image-load monitoring (cmd 0x85)
+-- Ob pre-callbacks -> handle-create monitoring
We observed support for up to four instances (FairplayKD0–FairplayKD3), with the instance index taken from the registry modulo 4.
5. Initialization
- Version gate: CheckWindowsVersion stores an OS ID in dword_22E94 . The mapping we recovered is 51→XP, 52→Server 2003, 60→Vista, 61→Win7 (primary target), 62→Win8 63→Win8.1, ≥64→unsupported. One boundary statement conflicts with this table, see §11.
- Dynamic resolution: sensitive routines are resolved lazily and cached:
PVOID ResolveXxx(void) {
if (g_pXxx) return g_pXxx;
DecryptName(enc_buf, n); // in-place 7-bit cipher
RtlInitUnicodeString(&us, dec_buf);
g_pXxx = MmGetSystemRoutineAddress(&us);
return g_pXxx;
- Device setup: registry-derived suffix; device object and symbolic link created per instance; teardown via IoDeleteSymbolicLink / IoDeleteDevice and callback removal.
- Auxiliary library: AuxKlibInitialize / AuxKlibQueryModuleInformation for kernel module enumeration.
6. IOCTL interface
Control code: 0x22E008 (decimal 2,285,576).
Input contract we recovered:
1. Header magic 363 (0x16B) at offset 0
2. Per-command minimum input length
3. Checksum validated by ValidateInputBufferChecksum before dispatch.
The exact input/output struct layout and the checksum algorithm are not included here, recovering them is a priority for anyone continuing this work.
-Command table
| Cmd | Dec | Function | Security relevance |
|---|---|---|---|
| `0x01 | 1 | Version handshake, returns `363` | Protocol identity |
| `0x78` | 120 | Copy from arbitrary kernel address to output buffer | **Arbitrary kernel read** |
| `0x79` | 121 | Kernel module base / export info (`ntoskrnl`), when `InputBuffer[2]==1` | Kernel layout disclosure |
| `0x7A` | 122 | Resolve user-supplied routine name via `MmGetSystemRoutineAddress` | Address disclosure / hook checks |
| `0x7C` | 124 | Write to arbitrary kernel address | **Arbitrary kernel write** |
| `0x7E` | 126 | Log status + `CollectProcessTrackingInfo` snapshot | State disclosure, self-verify pointer |
| `0x80` | 128 | Validation ping, input length 32 | Magic/checksum only |
| `0x81` | 129 | Validation ping, input length 12 | Magic/checksum only |
| `0x82` | 130 | Tag process as type 6 (launcher/GTA) manually | Tracking state mutation |
| `0x83` | 131 | Tag process as type 5 (protected/MTA client) manually | Tracking state mutation |
| `0x84` | 132 | Module/system info: `0xBB8` → AuxKlib, else `ZwQuerySystemInformation` | System enumeration |
| `0x85` | 133 | "Monitor memory range", load-image notification | Description implausible, see §11 |
| `0x86` | 134 | `ExEnumHandleTable` over current process → handle array | HWID material |
| `0x87` | 135 | `PsLookupProcessByProcessId` + `ObOpenObjectByPointer` | **Process handle** |
| `0x88` | 136 | Process image name query + checksum | Path disclosure |
| `0x89` | 137 | `WriteMemoryToThread` | **Thread memory write** |
| `0x8A` | 138 | Thread write + `ZwResumeThread` | **Write-and-resume primitive** |
| `0x8B` | 139 | Thread basic/context information queries | Thread state disclosure |
| `0x8C` | 140 | `ReadMemoryFromProcess` (PID-based, multi-thread) | **Cross-process read** |
| `0x8D` | 141 | `PsLookupProcessThreadByCid` | Process/thread object lookup |
| `0x8F` | 143 | `PsLookupThreadByThreadId` | Thread object lookup |
There is a gap at 0x8E, reserved, removed, or not yet identified.
- Dispatch flow
DeviceIoControl -> IRP_MJ_DEVICE_CONTROL -> HandleDeviceIoControl
-> extract stack location: input buffer, output buffer, lengths
-> ProcessIoctlCommand
-> validate magic + length + checksum
-> switch(command)
-> on error: log "Command %d failed (uiParsedVersion:%d)"
-> set IoStatus.Status / Information
-> IoCompleteRequest(..., IO_NO_INCREMENT)
Assessment: a locally reachable kernel interface combining arbitrary kernel R/W with process/thread open/read/write is a high-value privilege surface. Magic + checksum do not mitigate that, both are deterministic and visible to anyone holding the client module. The unresolved question is the **device ACL**: who can actually open \\.\FairplayKD "Only the normal client calls it describes usage, not enforcement.
7. Process tracking model
Table entry (16 bytes)
struct ProcessTableEntry {
HANDLE ProcessHandle; // +0x00, 8 bytes
DWORD ProcessType; // +0x08
BYTE FlagByte; // +0x0C
BYTE Padding[3]; // +0x0D
};
// global table: 100 entries, current count in dword_22FF0Classification map
| Type | Process(es) | Role |
|---|---|---|
| 1 | unclassified | Unknown |
| 2 | `csrss.exe` | CSRSS |
| 3 | `lsass.exe` | LSASS |
| 4 | `svchost.exe` | Service host |
| 5 | MTA client | Protected/user process |
| 6 | `gta_sa.exe`, `proxy_sa.exe` | Launcher/game process |
| 7 | `raidcall.exe` | VoIP |
| 8 | `LVPrcSrv.exe`, `LWEMon.exe` | Peripherals |
| 9 | `Action_x64.bin`, `Action_x86.bin` | Screen recording |
Classification is suffix matching on image names inside ProcessCreationNotifyCallback; process exit removes the entry.
Callback sketch
ProcessCreationNotifyCallback(parent, child, isCreation)
if !isCreation: RemoveProcessFromTable(child); return
type = GetProcessTypeFromTable(child)
if type == 0: type = ClassifyProcessByImageName(child)
if type == 1: allow
else:
UpdateProcessTypeInTable(type, auto)
if parent is type 5 and count(type5) > 1:
log "Launcher %d (%s) creating process %d (%s)"
if type != 1: return non-zero -> BLOCK
As written this would block csrss.exe, lsass.exe, and svchost.exe as well, impossible for a shipping driver. An additional parent/context condition is almost certainly missing from the reconstruction. See §11
8. HWID / serial pipeline
cmd 0x86 -> ExEnumHandleTable(current process) -> array of HANDLE values
cmd 0x7E -> CollectProcessTrackingInfo output:
+0x10 callbacks-registered flag
+0x20 pointer toCollectProcessTrackingInfo (self-verification)
+0x28 count of type-6 processes
+0x2C up to 3 type-6 handles
+0x44 count of type-5 processes
+0x48 up to 3 type-5 handles
netc.dll -> hashes {handles} + {snapshot} + other identifiers -> game serial
The self-verification pointer at +0x20 is a useful integrity hint, usermode can compare it to the expected kernel address, but it is still a value crossing a user/kernel boundary, so it is not a trust root
9. Obfuscation layer
String cipher
decrypted[i] = (((3 - i) ^ (encrypted[i] & 0x7F)) - (i * i)) & 0x7F;- Both input and output are masked to 7 bits, keeping obfuscated names in printable ASCII range for storage in .data.
- The - (i * i) term wraps modulo 128, so long strings cycle. The transform is still invertible per index:
encrypted[i] = ((((decrypted[i] + i*i) & 0x7F) ^ ((3 - i) & 0x7F)) & 0x7F).
- No key and no per-sample variation are evident, this is obfuscation, not cryptography.
# Resolution pattern
Lazy, cached, one resolver per API, all funnelling into MmGetSystemRoutineAddress with a UNICODE_STRING built from the decrypted name.
# API inventory (grouped)
- Process/thread/handle: `PsLookupProcessByProcessId`, `PsLookupProcessThreadByCid`, `PsLookupThreadByThreadId`, `ObOpenObjectByPointer`, `ObGetObjectType`, `ObfDereferenceObject`, `ExEnumHandleTable`, `PsGetCurrentProcessId`, `PsGetCurrentThreadId`
- Callbacks: `PsSetCreateProcessNotifyRoutineEx*` / `PsRemoveCreateProcessNotifyRoutine`, `PsSetLoadImageNotifyRoutine` / `PsRemoveLoadImageNotifyRoutine`, `ObRegisterCallbacks`
- Memory / info: `ZwQuerySystemInformation`, `AuxKlibQueryModuleInformation`, `MmGetSystemRoutineAddress`
- IRP / device: `IoCreateDevice`, `IoCreateSymbolicLink`, `IoDeleteDevice`, `IoDeleteSymbolicLink`, `IoCompleteRequest`
- Thread/resume: `ZwOpenThread`, `ZwCreateThreadEx`, `ZwResumeThread`
- Registry / misc: `ZwOpenKey`, `ZwQueryValueKey`, `ZwClose`
- Internal: `ExfUnblockPushLock` (used on some OS paths)
A key detail is that the sample's import table includes `MmGetSystemRoutineAddress`, `ZwQuerySystemInformation`, `ObfDereferenceObject`, `KeStackAttachProcess`, `KeUnstackDetachProcess`, `MmProbeAndLockPages`, `MmMapLockedPagesSpecifyCache`, `MmUnmapLockedPages`, `MmIsAddressValid`, `PsProcessType`, `PsThreadType`, `PsGetThreadProcessId`, `RtlGetVersion`, `PsGetVersion`, and others. Dynamic resolution hides certain *names*; it does not hide the driver's overall capability profile from triage.
#GetKernelModuleBase anti-hook trick
PVOID GetKernelModuleBase(void) {
PVOID p = (PVOID)ZwTerminateThread; // known export as anchor
for (int page = 0; page < 0x2710; page++) { // up to 0x2710 pages (~40 MB)
p = (PVOID)((ULONG_PTR)p & ~0xFFF);
if (*(USHORT*)p == 0x5A4D) { // 'MZ'
DWORD pe = *(DWORD*)((char*)p + 0x3C);
if (*(DWORD*)((char*)p + pe) == 0x00004550) // 'PE\0\0'
return p;
}
p = (PVOID)((ULONG_PTR)p - 0x1000);
}
return NULL;
}A downward page walk from a known export: align to a page boundary, then validate `e_lfanew` and `PE\0\0` before accepting the base. In a disassembler this stands out via the `0x5A4D` / `0x4550` constants and the `0x1000` decrement loop.
10. Callbacks, logging, path handling
- Process notify: `PsSetCreateProcessNotifyRoutineEx` → classify, update table, potentially block child creation.
- Object callbacks: `ObRegisterCallbacks` on `OB_OPERATION_HANDLE_CREATE` for process and thread objects; pre-callbacks log accesses involving launcher/protected processes and are wrapped in exception handlers (`...caused exception` strings). Access-right stripping is possible in principle but we only confirmed logging.
- Load-image notify: associated with command `0x85` for image-load monitoring, implementation details are questionable, see §11.
- Logging: global `qword_1E2A0`, 100 slots, 2-byte entries, guarded by an atomic increment on `byte_22FF6`; linear free-slot search with slot 0 reused when full; wide-char messages up to 300 chars via `_vsnwprintf`. Strings we recovered include `"Launcher %d (%s) creating process %d (%s)"`, `"TableFullError"`, `"Command %d failed (uiParsedVersion:%d)"`, `"Add"`, `"removing"`.
- Path normalization: `\Device\HarddiskVolumeN\...` → drive letter; `\Windows\System32` → `\WS32`; `\Program Files` → `\PF`
11. Internal consistency checks / points to confirm
These are places where our reconstruction does not hold together cleanly. Treat them as open items rather than settled conclusions.
| # | Point | Issue | What to confirm |
|---|---|---|---|
| 1 | Static import behavior | The import table includes `KeStackAttachProcess`, `MmProbeAndLockPages`, `MmMapLockedPagesSpecifyCache`, `ZwQuerySystemInformation`, `ObfDereferenceObject`, `PsProcessType`, `PsThreadType`, etc. | Treat dynamic resolution as name-hiding, not capability-hiding. |
| 2 | OS gate boundary | The OS gate is inconsistent: one branch ends Win10 support below version 62, another marks ≥64 unsupported. Win10 reports 100 (`0x64`), so `< 64` appears correct. | Dump `CheckWindowsVersion` branches; confirm per-OS cutoffs. |
| 3 | Process blocking | Blocking every non-type-1 child would also block CSRSS, LSASS, and SVCHOST. | Recover the full condition, likely parent type 5, nesting depth, or image path. |
| 4 | Command `0x85` | Cmd `0x85` appears to call `PsSetLoadImageNotifyRoutine(addr)` for every 4-byte-aligned address in a range. That API takes a callback pointer, not a monitored address, and supports only a small fixed number of registrations. | Determine whether a range-tracking structure was confused with callback registration; locate the real callback body. |
| 5 | Log buffer layout | 100 slots × 2 bytes cannot hold 300-character wide messages. Slots are probably indices/flags into a separate pool. | Resolve actual log storage and slot semantics. |
| 6 | Magic + checksum as protection | Both are deterministic and available to anyone with the client module. This is validation, not authentication. The device ACL has not been recovered. | Recover device security descriptor and caller checks. |
| 7 | HWID "cannot be replicated from usermode" | Handle values and tracking snapshots are enumerable or influenceable from userland. Kernel collection raises the bar; it does not make replication impossible. | Verify what is actually hashed on the client side. |
| 8 | Two build timestamps | 2015-12-20 vs 2017-07-15 suggests different builds. | Determine the hash of each artifact; settle lineage. |
| 9 | Notify routine naming | `PsSetCreateProcessNotifyRoutineEx2/3`, Windows exposes `...Ex` and `...Ex2`; an "Ex3" symbol is not standard. | Verify exact symbol; likely a transcription error. |
| 10 | `ExfUnblockPushLock` description | Labeled as "get process object from handle (Win10 v61+)", 6.1 is Win7, and this is an internal pushlock helper, not an object getter. | Verify call site; likely a pattern-scan helper on older paths. |
| 11 | Screen-recorder classification | We could not settle whether type 9 is cheat-classified or monitoring-only. | Decide whether type 9 is monitored, blocked, or both. |
| 12 | Multi-instance / name squatting | Multiple device names provide alternatives; they do not by themselves prevent a squatter from creating a name first. | Analyze device SD and creation ordering. |
12. Closing
Enjoy reading and thank you for being a member of romdump
1 like · 0 dislikes