diff options
| author | Michael <[email protected]> | 2017-02-05 09:16:19 -0500 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-02-05 09:16:19 -0500 |
| commit | b1923154095df7b26d3e5263b5219f38f7c58c38 (patch) | |
| tree | 9ae69ad529ba47c415123b31e884223937944214 /ShiftOS.Server/Program.cs | |
| parent | 865c072d431de49a53b3078d77ffc13b9c1b133d (diff) | |
| download | shiftos_thereturn-b1923154095df7b26d3e5263b5219f38f7c58c38.tar.gz shiftos_thereturn-b1923154095df7b26d3e5263b5219f38f7c58c38.tar.bz2 shiftos_thereturn-b1923154095df7b26d3e5263b5219f38f7c58c38.zip | |
Fix double-hashing issue
Diffstat (limited to 'ShiftOS.Server/Program.cs')
| -rw-r--r-- | ShiftOS.Server/Program.cs | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs index 6a76703..92d672d 100644 --- a/ShiftOS.Server/Program.cs +++ b/ShiftOS.Server/Program.cs @@ -405,11 +405,14 @@ Contents: if(save.Username == args["username"].ToString() && save.Password == hashedPass) { - server.DispatchTo(new Guid(msg.GUID), new NetObject("mud_savefile", new ServerMessage - { - Name = "mud_savefile", - GUID = "server", - Contents = File.ReadAllText(savefile) + if(save.PasswordHashed == true) + save.Password = Encryption.Decrypt(save.Password); + + server.DispatchTo(new Guid(msg.GUID), new NetObject("mud_savefile", new ServerMessage + { + Name = "mud_savefile", + GUID = "server", + Contents = JsonConvert.SerializeObject(save) })); return; } @@ -1281,7 +1284,34 @@ The page you requested at was not found on this multi-user domain." } } + + public static string Decrypt(string cipherText) + { + byte[] cipherTextBytes = Convert.FromBase64String(cipherText); + using (PasswordDeriveBytes password = new PasswordDeriveBytes(GetMacAddress(), null)) + { + byte[] keyBytes = password.GetBytes(keysize / 8); + using (RijndaelManaged symmetricKey = new RijndaelManaged()) + { + symmetricKey.Mode = CipherMode.CBC; + using (ICryptoTransform decryptor = symmetricKey.CreateDecryptor(keyBytes, initVectorBytes)) + { + using (MemoryStream memoryStream = new MemoryStream(cipherTextBytes)) + { + using (CryptoStream cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read)) + { + byte[] plainTextBytes = new byte[cipherTextBytes.Length]; + int decryptedByteCount = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length); + return Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount); + } + } + } + } + } + } } + + } -// Commenting by Carver +// Uncommenting by Michael
\ No newline at end of file |
