fork(6) download
  1. /*
  2.   Simple Fallout Shelter saved game decrypt/encrypt
  3.   Author: superkhung@vnsecurity.net
  4. Usage: FOSDecrypt.exe input_file
  5.   File will decrypt if it's encrypted and vice versa
  6.   Use any json editor to edit saved data
  7. */
  8.  
  9. using System;
  10. using System.IO;
  11. using System.Text;
  12. using System.Security.Cryptography;
  13. using System.Text.RegularExpressions;
  14.  
  15. public static class FalloutShelterDecrypt
  16. {
  17. private const string initVector = "tu89geji340t89u2";
  18. private const string passPhrase = "UGxheWVy";
  19. private const int keysize = 256;
  20.  
  21. public static bool IsBase64String (this string s)
  22. {
  23. s = s.Trim ();
  24. return (s.Length % 4 == 0) && Regex.IsMatch (s, @"^[a-zA-Z0-9\+/]*={0,3}$", RegexOptions.None);
  25.  
  26. }
  27.  
  28. public static string Encrypt (string Text)
  29. {
  30. byte[] initVectorBytes = Encoding.UTF8.GetBytes (initVector);
  31. byte[] plainTextBytes = Encoding.UTF8.GetBytes (Text);
  32. Rfc2898DeriveBytes password = new Rfc2898DeriveBytes (passPhrase, initVectorBytes);
  33. byte[] keyBytes = password.GetBytes (keysize / 8);
  34. RijndaelManaged symmetricKey = new RijndaelManaged ();
  35. symmetricKey.Mode = CipherMode.CBC;
  36. ICryptoTransform encryptor = symmetricKey.CreateEncryptor (keyBytes, initVectorBytes);
  37. MemoryStream memoryStream = new MemoryStream ();
  38. CryptoStream cryptoStream = new CryptoStream (memoryStream, encryptor, CryptoStreamMode.Write);
  39. cryptoStream.Write (plainTextBytes, 0, plainTextBytes.Length);
  40. cryptoStream.FlushFinalBlock ();
  41. byte[] Encrypted = memoryStream.ToArray ();
  42. memoryStream.Close ();
  43. cryptoStream.Close ();
  44. return Convert.ToBase64String (Encrypted);
  45. }
  46.  
  47. public static string Decrypt (string EncryptedText)
  48. {
  49. byte[] initVectorBytes = Encoding.ASCII.GetBytes (initVector);
  50. byte[] DeEncryptedText = Convert.FromBase64String (EncryptedText);
  51. Rfc2898DeriveBytes password = new Rfc2898DeriveBytes (passPhrase, initVectorBytes);
  52. byte[] keyBytes = password.GetBytes (keysize / 8);
  53. RijndaelManaged symmetricKey = new RijndaelManaged ();
  54. symmetricKey.Mode = CipherMode.CBC;
  55. ICryptoTransform decryptor = symmetricKey.CreateDecryptor (keyBytes, initVectorBytes);
  56. MemoryStream memoryStream = new MemoryStream (DeEncryptedText);
  57. CryptoStream cryptoStream = new CryptoStream (memoryStream, decryptor, CryptoStreamMode.Read);
  58. byte[] plainTextBytes = new byte[DeEncryptedText.Length];
  59. int decryptedByteCount = cryptoStream.Read (plainTextBytes, 0, plainTextBytes.Length);
  60. memoryStream.Close ();
  61. cryptoStream.Close ();
  62. return Encoding.UTF8.GetString (plainTextBytes, 0, decryptedByteCount);
  63. }
  64.  
  65. static void Main (string[] args)
  66. {
  67. if (args.Length < 1) {
  68. Console.WriteLine ("Usage: FOSDecrypt.exe input_file");
  69. }
  70.  
  71. String data = File.ReadAllText (args [0]);
  72.  
  73. if (IsBase64String (data)) {
  74. File.WriteAllText (args [0], Decrypt (data));
  75. } else {
  76. File.WriteAllText (args [0], Encrypt (data));
  77. }
  78. }
  79. }
Runtime error #stdin #stdout #stderr 0.04s 26976KB
stdin
Standard input is empty
stdout
Usage: FOSDecrypt.exe input_file
stderr
Unhandled Exception:
System.IndexOutOfRangeException: Array index is out of range.
  at FalloutShelterDecrypt.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.IndexOutOfRangeException: Array index is out of range.
  at FalloutShelterDecrypt.Main (System.String[] args) [0x00000] in <filename unknown>:0