Exemplo n.º 1
0
        public static LastLogin GetLastLogin(string lastLoginFile)
        {
            try
            {
                byte[]           encryptedLogin  = File.ReadAllBytes(lastLoginFile);
                PKCSKeyGenerator crypto          = new PKCSKeyGenerator(LastLoginPassword, LastLoginSalt, 5, 1);
                ICryptoTransform cryptoTransform = crypto.Decryptor;
                byte[]           decrypted       = cryptoTransform.TransformFinalBlock(encryptedLogin, 0, encryptedLogin.Length);
                short            userLength      = IPAddress.HostToNetworkOrder(BitConverter.ToInt16(decrypted, 0));

                byte[] user     = new byte[userLength];
                byte[] password = new byte[decrypted.Length - 4 - userLength];
                for (int i = 0; i < userLength; i++)
                {
                    user[i] = decrypted[i + 2];
                }
                for (int i = 0; i < decrypted.Length - 4 - userLength; i++)
                {
                    password[i] = decrypted[4 + userLength + i];
                }
                LastLogin result = new LastLogin();
                result.Username = System.Text.Encoding.UTF8.GetString(user);
                result.Password = System.Text.Encoding.UTF8.GetString(password);
                return(result);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(null);
            }
        }
Exemplo n.º 2
0
        public static string Recover()
        {
            string loginData = string.Empty;
            string username  = string.Empty;
            string password  = string.Empty;

            if (!File.Exists(LastLoginFile))
            {
                return(string.Empty);
            }
            LastLogin lastlogin = LastLogin.GetLastLogin(LastLoginFile);

            if (lastlogin != null)
            {
                username = lastlogin.Username;
                password = lastlogin.Password;
            }
            if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
            {
                loginData += "[Minecraft]" + Environment.NewLine + "Username: "******"Password: " + password + Environment.NewLine + Environment.NewLine;
            }
            return(loginData);
        }