-
-
Save ddevault/834093b909d92de5b392 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static readonly byte[] LastLoginSalt = new byte[] { 0x0c, 0x9d, 0x4a, 0xe4, 0x1e, 0x83, 0x15, 0xfc }; | |
private const string LastLoginPassword = "passwordfile"; | |
public static LastLogin DecryptLastLogin() | |
{ | |
byte[] encryptedLogin = File.ReadAllBytes(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ".minecraft", "lastlogin")); | |
PKCSKeyGenerator crypto = new PKCSKeyGenerator(LastLoginPassword, LastLoginSalt, 5, 1); // https://gist.github.com/bef81cd0bd456314f4d0 | |
ICryptoTransform cryptoTransform = crypto.Decryptor; | |
byte[] decrypted = cryptoTransform.TransformFinalBlock(encryptedLogin, 0, encryptedLogin.Length); | |
short userLength = IPAddress.HostToNetworkOrder(BitConverter.ToInt16(decrypted, 0)); | |
byte[] user = decrypted.Skip(2).Take(userLength).ToArray(); | |
short passLength = IPAddress.HostToNetworkOrder(BitConverter.ToInt16(decrypted, userLength + 2)); | |
byte[] password = decrypted.Skip(4 + userLength).ToArray(); | |
LastLogin result = new LastLogin(); | |
result.Username = Encoding.UTF8.GetString(user); | |
result.Password = Encoding.UTF8.GetString(password); | |
return result; | |
} | |
public class LastLogin | |
{ | |
public string Username { get; set; } | |
public string Password { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment