Difference between revisions of "MOGG File Format"
m (the games do actually call it an OggMap from what I can see) |
m (clarifying that v17 algorithm is basically v16 with one tiny difference, also that DCS uses v11(courtesy Cisco)) |
||
(9 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
MOGG files are often used in Harmonix games | MOGG files are a form of audio file often used in Harmonix games across all platforms aside from PS2 and DS, from [[Guitar Hero 2]] (Xbox 360) and onwards. They are an extension of the [https://xiph.org/vorbis/ OGG Vorbis] container with an extra header prepending it, to assist with streaming and seeking. Additionally, starting with [[Rock Band (game)|Rock Band]], MOGG containers provide AES encryption. | ||
==Structure== | ==Structure== | ||
Line 21: | Line 19: | ||
|Integer (LE) | |Integer (LE) | ||
|4 bytes | |4 bytes | ||
|Length of the MOGG header / offset in the file where the OGG begins. | |Length of the MOGG header / offset in the file where the OGG begins, represented by a count of 8-byte blocks. | ||
|- | |- | ||
|Map Version | |Map Version | ||
Line 36: | Line 34: | ||
|Integer (LE) | |Integer (LE) | ||
|4 bytes | |4 bytes | ||
|The number of entries in the | |The number of entries in the OggMap. | ||
|- | |- | ||
|OggMap | |OggMap | ||
|[[# | |[[#OggMap]] Array | ||
|sizeof( | |sizeof(OggMap) * Entry Count | ||
|A lookup table to help the game stream the OGG file from disk. | |A lookup table to help the game stream the OGG file from disk. | ||
|- | |- | ||
|AES | |AES IV | ||
|Byte Array | |Byte Array | ||
|16 bytes | |16 bytes | ||
| | |The initialisation vector used for decrypting the OGG file. ''Only present on MOGG version 11 / 0xB.'' | ||
|} | |} | ||
<!-- TODO: 0xC through 0x10 use different header i think? --> | |||
=== | ===OggMap=== | ||
To help the game seek in an OGG file (rewinding after pausing, practice mode, etc), a lookup table is used to locate the byte offset in the file to look for a sample. | To help the game seek in an OGG file (rewinding after pausing, practice mode, etc), a lookup table is used to locate the byte offset in the file to look for a sample. | ||
Line 74: | Line 73: | ||
===OGG File=== | ===OGG File=== | ||
After the header, there is a regular OGG Vorbis format file, usually containing multiple tracks. The tracks corresponding to instruments are defined in the [[songs.dta]] file. This is where encryption starts if the version is 0xB or higher. | |||
==Encryption== | ==Encryption== | ||
Starting with [[Rock Band (game)|Rock Band]], MOGG files used for songs are encrypted with a 128-bit AES cipher in ECB mode with an externally-managed counter. Each "generation" of MOGG files changes either the encryption keys or exact scheme used, or both. There is also an additional bit-shuffling obfuscation step prior to encryption or after decryption. Rock Band games that support a given version of encryption also support all earlier versions. | |||
{| class="wikitable" | {| class="wikitable" | ||
Line 87: | Line 86: | ||
|10 / 0xA | |10 / 0xA | ||
|Unencrypted. Lacks key in MOGG header. | |Unencrypted. Lacks key in MOGG header. | ||
|Used in [[Guitar Hero 2]] (Xbox 360) | |Used for unimportant MOGGs, such as sound effects, and in [[Guitar Hero 2]] (Xbox 360) for songs. | ||
|- | |- | ||
|11 / 0xB | |11 / 0xB | ||
|Encryption is done with a static key | |Encryption is done with a static key in the game binary, using the value in MOGG header as the IV. | ||
|Used in [[Rock Band (game)|Rock Band]] on-disc and DLC songs. | |Used in [[Rock Band (game)|Rock Band]] on-disc and DLC songs. Also used in [[Dance Central Spotlight]]. | ||
|- | |- | ||
|12 / 0xC | |12 / 0xC | ||
| rowspan=2 | The true decryption key is derived through a custom algorithm. Changes the format of the header. Treated as exactly the same by all games that support at least this version of encryption. | | rowspan=2 | The true decryption key is derived through a custom algorithm. Changes the format of the header. Treated as exactly the same by all games that support at least this version of encryption. | ||
|Used in [[Rock Band 2]] on-disc songs. | |Used in [[Rock Band 2]] on-disc songs. Support was added to Rock Band 1 in a title update. <!-- TODO: which title update? --> | ||
|- | |- | ||
|13 / 0xD | |13 / 0xD | ||
| | |Not used officially<!-- check? -->, but used in songs encrypted by C3 CON Tools. | ||
|- | |- | ||
|14 / 0xE | |14 / 0xE | ||
| rowspan=3 | Increases the complexity of the key derivation step. | | rowspan=3 | Increases the complexity of the key derivation step. | ||
|Used in [[Rock Band 2]] DLC songs. | |Used in [[Rock Band 2]] DLC songs, as well as on-disc and DLC songs for the Dance Central series prior to Dance Central VR. <!-- TODO: do DC games support other versions? --> | ||
|- | |- | ||
|15 / 0xF | |15 / 0xF | ||
|Used in Rock Band Network. | |Used in the [[Rock Band Network]]. Support was added to Rock Band 2 in a title update. <!-- TODO: which title update? what about Wii RBN? --> | ||
|- | |- | ||
|16 / 0x10 | |16 / 0x10 | ||
|Used in [[Rock Band 3]], [[Rock Band 4]] and [[Rock Band VR]] on-disc and DLC until November 2018. | |Used in [[Rock Band 3]], [[Rock Band 4]] and [[Rock Band VR]] on-disc songs, and DLC until November 2018. | ||
|- | |- | ||
|17 / 0x11 | |17 / 0x11 | ||
|A new value is added in the header and a new set of keys are used | |A new value is added in the header and a new set of keys are used, but otherwise the same as 0x10, except that the revealed key from one step in the algorithm is no longer ASCII. | ||
|Used in [[Rock Band 4]] DLC after November 2018, | |Used in [[Rock Band 4]] DLC and other Harmonix games released after November 2018, such as DropMix, Dance Central VR, Audica, and Fuser. The non-RB games each have their own keyset, and only support their own variant of 0x11, as well as unencrypted 0xA. | ||
|} | |} | ||
<!-- TODO: Make sure the games and descriptions are correct. --> | |||
[[The Beatles: Rock Band]] used version 16/0x10 alongside a custom white-box crypto algorithm by Cloakware in order to protect the original keys. | |||
== Platform Differences == | |||
For performance(?) reasons, the Wii versions of the Rock Band games opt to not use MOGG files for songs, instead using the [[BIK File Format]] with an added encryption layer. Encrypted MOGG files are still used in DLC song preview audios. | |||
On the Xbox 360, starting with [[Rock Band 2]], release builds of the game obfuscate the encryption keys for version 0xC behind the console's native hypervisor encryption functions (XeKeys). This was likely to prevent those with development kits from reverse engineering the new algorithm, as it in theory changes the way a non-retail hypervisor derives keys. | |||
On the PlayStation 3, MOGG files are decoded with the help of the SPUs, and the VorbisReader class was heavily changed to accomodate that. Due to a logic error in their new code, any unencrypted (0xA) MOGG will not play back as it will perpetually read the first block of the file. | |||
==Tools== | ==Tools== | ||
Several tools are available for working with MOGG files (creation/extraction, encryption, etc) | Several tools are available for working with MOGG files (creation/extraction, encryption/decryption, etc) | ||
* [ | * [https://github.com/mtolly/onyx Onyx Music Game Toolkit] | ||
* [[Magma]] | * [[Magma]] | ||
* [[ArkTool]] | * [[ArkTool]] | ||
* [ | * [https://github.com/trojannemo/Nautilus Nautilus] | ||
* [https://www.audacityteam.org/ Audacity] ( | * [https://www.audacityteam.org/ Audacity] (While not supporting MOGG files, if the MOGG header is smaller than 0x1000 bytes, it will read the contained OGG Vorbis file.) | ||
==References== | ==References== | ||
* [https://rockband.scorehero.com/forum/viewtopic.php?p=85805#85805 xorloser's ScoreHero post] | * [https://rockband.scorehero.com/forum/viewtopic.php?p=85805#85805 xorloser's ScoreHero post] | ||
* [https://github.com/mtolly/onyxite-customs/blob/master/haskell/src/ | * [https://github.com/mtolly/onyxite-customs/blob/master/haskell/packages/onyx-lib/src/Onyx/Harmonix/MOGG.chs Onyx Toolkit Source Code] | ||
* [https://github.com/mtolly/ogg2mogg/blob/master/main.c ogg2mogg Source Code] | * [https://github.com/mtolly/ogg2mogg/blob/master/main.c ogg2mogg Source Code] | ||
* [https://web.archive.org/web/20201204045811/https://maxton.xyz/blog/2020/08/28/breaking-beatles-xenia "Breaking Beatles" - maxton - Archived on 4th December 2020] | * [https://web.archive.org/web/20201204045811/https://maxton.xyz/blog/2020/08/28/breaking-beatles-xenia "Breaking Beatles" - maxton - Archived on 4th December 2020] |
Latest revision as of 16:40, 17 September 2024
MOGG files are a form of audio file often used in Harmonix games across all platforms aside from PS2 and DS, from Guitar Hero 2 (Xbox 360) and onwards. They are an extension of the OGG Vorbis container with an extra header prepending it, to assist with streaming and seeking. Additionally, starting with Rock Band, MOGG containers provide AES encryption.
Structure
MOGG Header
Name | Type | Size | Function |
---|---|---|---|
Version | Integer (LE) | 4 bytes | Version of the MOGG file. Related to encryption (10 / 0xA = unencrypted) |
Header Size | Integer (LE) | 4 bytes | Length of the MOGG header / offset in the file where the OGG begins, represented by a count of 8-byte blocks. |
Map Version | Integer (LE) | 4 bytes | Version of the MOGG map. (usually 16 / 0x10) |
Seek Interval | Integer (LE) | 4 bytes | The interval between samples in the sample table. (Usually 20000 / 0x4E20) |
Entry Count | Integer (LE) | 4 bytes | The number of entries in the OggMap. |
OggMap | #OggMap Array | sizeof(OggMap) * Entry Count | A lookup table to help the game stream the OGG file from disk. |
AES IV | Byte Array | 16 bytes | The initialisation vector used for decrypting the OGG file. Only present on MOGG version 11 / 0xB. |
OggMap
To help the game seek in an OGG file (rewinding after pausing, practice mode, etc), a lookup table is used to locate the byte offset in the file to look for a sample.
When the game wants to seek to sample N, it looks up entry (N / Seek Interval) in the table, that gives a byte offset and sample offset. It then seeks the file over to the byte offset and skips (N - Sample Offset) samples.
Name | Type | Size | Function |
---|---|---|---|
Byte Offset | Integer (LE) | 4 bytes | Offset into the file that the entry starts. |
Sample | Integer (LE) | 4 bytes | The sample in the OGG stream that corresponds to the byte offset. |
OGG File
After the header, there is a regular OGG Vorbis format file, usually containing multiple tracks. The tracks corresponding to instruments are defined in the songs.dta file. This is where encryption starts if the version is 0xB or higher.
Encryption
Starting with Rock Band, MOGG files used for songs are encrypted with a 128-bit AES cipher in ECB mode with an externally-managed counter. Each "generation" of MOGG files changes either the encryption keys or exact scheme used, or both. There is also an additional bit-shuffling obfuscation step prior to encryption or after decryption. Rock Band games that support a given version of encryption also support all earlier versions.
Generation | Info | Games |
---|---|---|
10 / 0xA | Unencrypted. Lacks key in MOGG header. | Used for unimportant MOGGs, such as sound effects, and in Guitar Hero 2 (Xbox 360) for songs. |
11 / 0xB | Encryption is done with a static key in the game binary, using the value in MOGG header as the IV. | Used in Rock Band on-disc and DLC songs. Also used in Dance Central Spotlight. |
12 / 0xC | The true decryption key is derived through a custom algorithm. Changes the format of the header. Treated as exactly the same by all games that support at least this version of encryption. | Used in Rock Band 2 on-disc songs. Support was added to Rock Band 1 in a title update. |
13 / 0xD | Not used officially, but used in songs encrypted by C3 CON Tools. | |
14 / 0xE | Increases the complexity of the key derivation step. | Used in Rock Band 2 DLC songs, as well as on-disc and DLC songs for the Dance Central series prior to Dance Central VR. |
15 / 0xF | Used in the Rock Band Network. Support was added to Rock Band 2 in a title update. | |
16 / 0x10 | Used in Rock Band 3, Rock Band 4 and Rock Band VR on-disc songs, and DLC until November 2018. | |
17 / 0x11 | A new value is added in the header and a new set of keys are used, but otherwise the same as 0x10, except that the revealed key from one step in the algorithm is no longer ASCII. | Used in Rock Band 4 DLC and other Harmonix games released after November 2018, such as DropMix, Dance Central VR, Audica, and Fuser. The non-RB games each have their own keyset, and only support their own variant of 0x11, as well as unencrypted 0xA. |
The Beatles: Rock Band used version 16/0x10 alongside a custom white-box crypto algorithm by Cloakware in order to protect the original keys.
Platform Differences
For performance(?) reasons, the Wii versions of the Rock Band games opt to not use MOGG files for songs, instead using the BIK File Format with an added encryption layer. Encrypted MOGG files are still used in DLC song preview audios.
On the Xbox 360, starting with Rock Band 2, release builds of the game obfuscate the encryption keys for version 0xC behind the console's native hypervisor encryption functions (XeKeys). This was likely to prevent those with development kits from reverse engineering the new algorithm, as it in theory changes the way a non-retail hypervisor derives keys.
On the PlayStation 3, MOGG files are decoded with the help of the SPUs, and the VorbisReader class was heavily changed to accomodate that. Due to a logic error in their new code, any unencrypted (0xA) MOGG will not play back as it will perpetually read the first block of the file.
Tools
Several tools are available for working with MOGG files (creation/extraction, encryption/decryption, etc)
- Onyx Music Game Toolkit
- Magma
- ArkTool
- Nautilus
- Audacity (While not supporting MOGG files, if the MOGG header is smaller than 0x1000 bytes, it will read the contained OGG Vorbis file.)