/// <summary> /// Checks a single word (or rather a variation of a word): Encrypts and compares to an entry in the password file /// </summary> /// <param name="userInfo">Username, encrypted password from the password file</param> /// <param name="possiblePassword">Username, encrypted password pair from the password file</param> private void CheckSingleWord(UserInfo userInfo, String possiblePassword) { char[] charArray = possiblePassword.ToCharArray(); byte[] passwordAsBytes = Array.ConvertAll(charArray, PasswordFileHandler.GetConverter()); byte[] encryptedPassword = _messageDigest.ComputeHash(passwordAsBytes); if (CompareBytes(userInfo.EntryptedPassword, encryptedPassword)) //compares byte arrays { _result = new UserInfoClearText(userInfo.Username, possiblePassword); //Console.WriteLine(userInfo.Username + " " + possiblePassword); } }
public void Work() { ConnectTcpWithAutoFlush(out TcpClient ballAndChain, out StreamWriter sw, out StreamReader sr); sw.WriteLine("0"); string message = sr.ReadLine(); while (message != "1029384756") { _dict.Add(message); message = sr.ReadLine(); } while (true) { sw.WriteLine("1"); string password = sr.ReadLine(); sw.WriteLine("Disconnect"); ballAndChain.Close(); if (password == "f**k af" || password is null) { break; } string[] split = password.Split(':'); _userInfo = new UserInfo(split[0], split[1]); RunCracking(); var solvedPassword = !(_result is null) ? _result.Password : "******"; _result = null; ConnectTcpWithAutoFlush(out ballAndChain, out sw, out sr); sw.WriteLine("2"); sw.WriteLine(split[0] + " " + solvedPassword); } }