Add Test-PasswordQuality SamAccountName Test; Code enhancement

This commit is contained in:
BlueCurby 2023-08-07 21:02:35 +02:00 committed by Michael Grafnetter
parent 9a94fb848a
commit 38956fb101
1 changed files with 5 additions and 3 deletions

View File

@ -473,19 +473,21 @@
private void TestSamAccountNameAsPassword() private void TestSamAccountNameAsPassword()
{ {
string userLowerPassword = this.Account.SamAccountName.ToLower(); string userLowerPassword = this.Account.SamAccountName.ToLower();
string userExactPassword = this.Account.SamAccountName;
byte[] userLowerHash = NTHash.ComputeHash(userLowerPassword); byte[] userLowerHash = NTHash.ComputeHash(userLowerPassword);
byte[] userExactHash = NTHash.ComputeHash(userExactPassword);
if (HashEqualityComparer.GetInstance().Equals(this.Account.NTHash, userLowerHash)) if (HashEqualityComparer.GetInstance().Equals(this.Account.NTHash, userLowerHash))
{ {
// Username Password is lowercase SamAccountName // Username Password is lowercase SamAccountName
this.result.SamAccountNameAsPassword.Add(this.Account.LogonName); this.result.SamAccountNameAsPassword.Add(this.Account.LogonName);
} }
else else
{ {
string userExactPassword = this.Account.SamAccountName;
byte[] userExactHash = NTHash.ComputeHash(userExactPassword);
if (HashEqualityComparer.GetInstance().Equals(this.Account.NTHash, userExactHash)) if (HashEqualityComparer.GetInstance().Equals(this.Account.NTHash, userExactHash))
{ {
// Username Password is exact SamAccountName // Username Password is exact SamAccountName
this.result.SamAccountNameAsPassword.Add(this.Account.LogonName); this.result.SamAccountNameAsPassword.Add(this.Account.LogonName);
} }