OGG Memes

Thanks OGG for repeating the two bytes i needed, elsewhere in the file ;)
This commit is contained in:
Bluzume 2021-08-11 00:24:25 +12:00
parent ca87e8f3e9
commit 4ec1857de1
2 changed files with 39 additions and 5 deletions

Binary file not shown.

View File

@ -131,10 +131,13 @@ namespace RMDEC
private static byte[] guessKey(string path) // Incase you think your smart
{
bool useOgg = false;
string[] mzPngs = Directory.GetFiles(path, "*._png", SearchOption.AllDirectories);
string[] mvPngs = Directory.GetFiles(path, "*.rpgmvp", SearchOption.AllDirectories);
string[] mzM4as = Directory.GetFiles(path, "*._m4a", SearchOption.AllDirectories);
string[] mvM4as = Directory.GetFiles(path, "*.rpgmvm", SearchOption.AllDirectories);
string[] mzOggs = Directory.GetFiles(path, "*._ogg", SearchOption.AllDirectories);
string[] mvOggs = Directory.GetFiles(path, "*.rpgmvo", SearchOption.AllDirectories);
List<string> files = new List<string>();
files.AddRange(mzPngs);
@ -144,7 +147,23 @@ namespace RMDEC
files.AddRange(mvM4as);
if (files.Count <= 0)
return new byte[0x10];
{
if(mzOggs.Length > 0 || mvOggs.Length > 0) // still encryted audio?
{
files.AddRange(mzOggs);
files.AddRange(mvOggs);
useOgg = true;
}
else
{
return new byte[0x10];
}
}
byte[] pngHeader = new byte[0x10] { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52 };
byte[] m4aHeader = new byte[0x10] { 0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x41, 0x20, 0x00, 0x00, 0x00, 0x00 };
byte[] oggHeader = new byte[0x10] { 0x4F, 0x67, 0x67, 0x53, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF };
Random rng = new Random();
int index = rng.Next(0, files.Count);
@ -154,12 +173,16 @@ namespace RMDEC
FileStream fs = File.OpenRead(file);
fs.Seek(0x10, SeekOrigin.Begin);
fs.Read(encryptedHeader, 0x00, 0x10);
if (useOgg)
{
fs.Seek(0x58, SeekOrigin.Begin);
oggHeader[0x0E] = (byte)fs.ReadByte();
oggHeader[0x0F] = (byte)fs.ReadByte();
}
fs.Close();
string filetype = Path.GetExtension(file).ToLower();
byte[] pngHeader = new byte[0x10] { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52 };
byte[] m4aHeader = new byte[0x10] { 0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x41, 0x20, 0x00, 0x00, 0x00, 0x00 };
if (filetype == "._png" || filetype == ".rpgmvp") {
byte[] key = RMProject.Xor(encryptedHeader, pngHeader);
if(!tryKey(path, key))
@ -183,7 +206,18 @@ namespace RMDEC
return key;
}
}
// OGG Header is not 0x10 bytes unfortunately.
else if (filetype == "._ogg" || filetype == ".rpgmvo")
{
byte[] key = RMProject.Xor(encryptedHeader, oggHeader);
if (!tryKey(path, key))
{
throw new Exception("Cannot find key (ITS TOO STRONG!)");
}
else
{
return key;
}
}
throw new Exception("Cannot find key (ITS TOO STRONG!)");
}