Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Security;
- using System.Security.Cryptography;
- using System.Text;
- namespace FFIX_Save_Extractor
- {
- class Program
- {
- private static int BlockSizee = 18432 - 462; //This one is tricky, but works!
- static private int slotID = 0;
- static private int saveID = 1;
- //Max slot ID is 10 and max saveID is 15. Therefore max individual saves is 150.
- private static SecureString password = new SecureString();
- private static string Pathe = @""; //Change me if you want to instantly debug your file!
- static void Main(string[] args)
- {
- Console.WriteLine("Welcome to Final Fantasy IX Steam save decoder v1.0!");
- Console.WriteLine("Please enter path to SavedData_ww.dat file, or drag and drop it here:");
- string Path = Pathe.Length != 0 ? Pathe :Console.ReadLine();
- if (Path[0] == '"' && Path[Path.Length - 1] == '"')
- Path = Path.Replace("\"", "");
- Console.WriteLine("Please enter your slotID (e.g. slot1 is 0, slot2 is 1): ");
- slotID = int.Parse(Console.ReadLine());
- Console.WriteLine("Please enter your saveID (e.g. save1 is 0, save2 is 1): ");
- saveID = int.Parse(Console.ReadLine());
- FileStream FS = new FileStream(Path, FileMode.Open);
- BinaryReader br = new BinaryReader(FS);
- FS.Seek((long)(320 - (int)FS.Position), SeekOrigin.Current);
- int num = 153600;
- int num2 = 18432 + slotID * 15 * 18432 + saveID * 18432;
- FS.Seek((long)num, SeekOrigin.Current); //?
- FS.Seek((long)num2, SeekOrigin.Current); //?
- byte[] buffer = br.ReadBytes(GetCipherSize(BlockSizee + 4));
- byte[] result = Decrypt(buffer);
- File.WriteAllBytes(Path + string.Format(".Slot{0}Save{1}", slotID > 9 ? slotID.ToString(): "0" + slotID, saveID > 9 ? saveID.ToString() : "0" + saveID), result);
- FS.Close();
- Console.WriteLine("File {0} decompressed!", Path);
- Console.ReadKey();
- return;
- }
- static public int GetCipherSize(int plainTextSize)
- {
- int num = 16;
- return plainTextSize + num - plainTextSize % num;
- }
- public static byte[] Decrypt(byte[] bytesToBeDecrypted)
- {
- byte[] array = GetPassword();
- byte[] result = null;
- byte[] salt = GetSalt();
- using (MemoryStream memoryStream = new MemoryStream())
- {
- using (RijndaelManaged rijndaelManaged = new RijndaelManaged())
- {
- rijndaelManaged.KeySize = 256;
- rijndaelManaged.BlockSize = 128;
- Rfc2898DeriveBytes rfc2898DeriveBytes = new Rfc2898DeriveBytes(array, salt, 1000);
- rijndaelManaged.Key = rfc2898DeriveBytes.GetBytes(rijndaelManaged.KeySize / 8);
- rijndaelManaged.IV = rfc2898DeriveBytes.GetBytes(rijndaelManaged.BlockSize / 8);
- rijndaelManaged.Mode = CipherMode.CBC;
- CryptoStream cryptoStream = new CryptoStream(memoryStream, rijndaelManaged.CreateDecryptor(), CryptoStreamMode.Write);
- cryptoStream.Write(bytesToBeDecrypted, 0, bytesToBeDecrypted.Length);
- //cryptoStream.Close();
- result = memoryStream.ToArray();
- }
- }
- return result;
- }
- private static byte[] GetPassword()
- {
- string[] array = new string[]
- {
- "67434cd0-1ca3-11e5-9a21-1697f925ec7b",
- "7a5313a0-1ca3-11e5-b939-0800200c9a66"
- };
- string[] array2 = array;
- for (int i = 0; i < array2.Length; i++)
- {
- string text = array2[i];
- for (int j = 0; j < text.Length; j++)
- {
- password.AppendChar(text[j]);
- }
- }
- byte[] bytes = Encoding.UTF8.GetBytes(password.ToString());
- password.Clear();
- return bytes;
- }
- private static byte[] GetSalt()
- {
- return new byte[]
- {
- 3,
- 3,
- 1,
- 4,
- 7,
- 0,
- 9,
- 7
- };
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement