Duke Grabowski LDT
LDT
The game Duke Grabowski: Mighty Swashbuckler uses the LDT files to store subtitle data. The files are actually just regular text encoded as little-endian UTF-16 (UTF-16-LE) but with no byte order mark (BOM). However, the files are also encrypted with a simple cipher, likely to thwart casual analysis or modification.
Text Structure
The text inside of the file contains a sequence of subtitles with no line breaks but delimited with the marker <!>. Each subtitle is formatted as such:
Timestamp<!>Duration<!>Subtitle 1<!>Subtitle 2<!>
The timestamp and duration fields are floating point numbers representing seconds.
Cipher
The LDT files are encrypted with a simple cipher. The key to decrypt all of the files is hardcoded in the game's C# binary.
To decrypt the file, process each byte by subtracting successive values from the key:
For i in 0 .. length(encrypted_LDT) decrypted_LDT[i] = encrypted_LDT[i] - (key[i MOD length(key)])
Recovering the Key
To recover the encryption key, either:
- Decompile the C# game binary.
- Perform cryptanalysis on an LDT file by exploiting the knowledge that many of the odd characters in the plaintext are 0 (since most of the characters are in the ASCII range) and that the delimiter "<!>" occurs frequently in the plaintext.