Difference between revisions of "MOGG File Format"

From Milo Modding Wiki
Jump to navigation Jump to search
(added more information about the seek table. thanks Onyxite! (hopefully corrected some encryption information, too))
m (clarifying that v17 algorithm is basically v16 with one tiny difference, also that DCS uses v11(courtesy Cisco))
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
MOGG files are often used in Harmonix games for all platforms except for PS2 and DS. They are an extension of the [https://xiph.org/vorbis/ OGG Vorbis] container with an extra header prepending it, and almost all official MOGGs starting with [[Rock Band (game)|Rock Band]] shipped on-disk and as DLC are encrypted.
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.
 
The version value in the MOGG header is used to indicate which encryption key and format should be used for decryption.


==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 MOGG header.
|The number of entries in the OggMap.
|-
|-
|Sample Table
|OggMap
|[[#MOGG Sample Entry]] Array
|[[#OggMap]] Array
|sizeof(MOGG Entry) * Entry Count
|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 Key
|AES IV
|Byte Array
|Byte Array
|16 bytes
|16 bytes
|An AES key used to encrypt the file. ''Only present if MOGG version is >= 11 / 0xB.''
|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? -->


===MOGG Sample Entry===
===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===


Past this point is a regular (optionally encrypted) OGG Vorbis format file containing multiple tracks. The tracks corresponding to instruments are defined in the [[songs.dta]] 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==


At its core, files are encrypted with a 128-bit AES EBC cipher. Each "generation" of MOGG files changes the encryption keys and scheme used. For legal reasons this wiki can not document any keys themselves, or any explicit details about 0x11 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. Uses key in MOGG header as IV.
|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
|The true decryption key is derived through a custom algorithm. Changes the format of the header.
| 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
|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.
| rowspan=2 | 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 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 for a more complex key derivation step.
|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, as well as Fuser.
|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.
|}
|}


Keys in [[Rock Band 2]] (Xbox 360) and later are additionally protected behind the console's native XeKeys functions (XeKeysAesCbc). This was likely to prevent those with development kits from reverse engineering the new algorithm, as XeKeys uses different keys depending on the console's key vault.
<!-- 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.


TODO: is 13/0xD ever used? Validate if the games and descriptions are correct.
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.


[[The Beatles: Rock Band]] used version 16/0x10 behind a Cloakware's white-box crypto algorithm in order to protect the original keyset.
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)


* [[Onyx Music Game Toolkit]]
* [https://github.com/mtolly/onyx Onyx Music Game Toolkit]
* [[Magma]]
* [[Magma]]
* [[ArkTool]]
* [[ArkTool]]
* [[C3 CON Tools]]
* [https://github.com/trojannemo/Nautilus Nautilus]
* [https://www.audacityteam.org/ Audacity] (supports reading smaller unencrypted MOGG files if the header is small)
* [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/MoggDecrypt.chs Onyx Toolkit Source Code]
* [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)

References