Difference between revisions of "MUX"

From Mania Tech Wiki
Jump to navigation Jump to search
(CPlugFileOggVorbis)
 
m
Line 1: Line 1:
'''.mux files''' are encrypted .ogg files and are typically used for custom track music. They use a simple, custom stream cipher based on a 16-byte key (a very long key is generated from the 16-byte key, and then every byte of the input file is xor'd with the corresponding byte in the long key).
+
'''.mux files''' are encrypted .ogg files and are typically used for custom track music. They use a simple, custom stream cipher based on a 16-byte key: a very long key is generated from the 16-byte key, and then every byte of the input file is xor'd with the corresponding byte in the long key.
  
 
== File layout ==
 
== File layout ==
Line 12: Line 12:
 
First, the 16-byte decryption key is determined as follows:
 
First, the 16-byte decryption key is determined as follows:
  
  key = md5(pack(keySalt) + "Hello,hack3r!")         // Hello, d3veloper:)
+
  key = md5(pack(keySalt) + "Hello,hack3r!")   // Hello, d3veloper :)
  
 
where pack() returns the bytes of its argument in little endian order, and the string is encoded as ASCII.
 
where pack() returns the bytes of its argument in little endian order, and the string is encoded as ASCII.

Revision as of 09:07, 13 June 2017

.mux files are encrypted .ogg files and are typically used for custom track music. They use a simple, custom stream cipher based on a 16-byte key: a very long key is generated from the 16-byte key, and then every byte of the input file is xor'd with the corresponding byte in the long key.

File layout

byte magic[9] = "NadeoFile"
byte version = 1
int32 keySalt
byte data[]

Decryption

First, the 16-byte decryption key is determined as follows:

key = md5(pack(keySalt) + "Hello,hack3r!")    // Hello, d3veloper :)

where pack() returns the bytes of its argument in little endian order, and the string is encoded as ASCII. Then, the data is decrypted as follows:

void Decrypt(byte[] data)
{
    for (int i = 0; i < data.Length; i++)
    {
        data[i] ^= GetKeyStreamByte(i);
    }
}

byte GetKeyStreamByte(int pos)
{
    return rol(key[pos % 16], (pos / 17) % 8);
}

byte rol(byte input, int amount)
{
    return (byte)((input << amount) | (input >> (8 - amount)));
}