Fixed NTLM hash input validation

This commit is contained in:
Michael Grafnetter 2018-08-06 23:56:22 +02:00
parent 7ca42f8f7d
commit 331d9abbab
2 changed files with 11 additions and 9 deletions

View File

@ -20,12 +20,5 @@ namespace DSInternals.Common.Test
string actualHash = NTHash.ComputeHash(pwd.CurrentPassword.ToSecureString()).ToHex(false); string actualHash = NTHash.ComputeHash(pwd.CurrentPassword.ToSecureString()).ToHex(false);
Assert.AreEqual(expectedHash, actualHash); Assert.AreEqual(expectedHash, actualHash);
} }
[TestMethod]
public void ManagedPassword_Vector2()
{
// Test PreviousPassword
throw new AssertInconclusiveException();
}
} }
} }

View File

@ -14,7 +14,7 @@ namespace DSInternals.Common.Interop
internal const int LMHashNumBits = 128; internal const int LMHashNumBits = 128;
internal const int LMHashNumBytes = NTHashNumBits / 8; internal const int LMHashNumBytes = NTHashNumBits / 8;
internal const int LMPasswordMaxChars = 14; internal const int LMPasswordMaxChars = 14;
internal const int NTPasswordMaxChars = 127; internal const int NTPasswordMaxChars = 128;
private const int MaxRegistryKeyClassSize = 256; private const int MaxRegistryKeyClassSize = 256;
private const string Advapi = "advapi32.dll"; private const string Advapi = "advapi32.dll";
@ -197,7 +197,16 @@ namespace DSInternals.Common.Interop
} }
[DllImport(CryptDll, CharSet = CharSet.Auto, SetLastError = true)] [DllImport(CryptDll, CharSet = CharSet.Auto, SetLastError = true)]
internal static extern NtStatus CDLocateCSystem(KerberosKeyType type, out KerberosCryptoSystem cryptoSystem); private static extern NtStatus CDLocateCSystem(KerberosKeyType type, out IntPtr cryptoSystem);
internal static NtStatus CDLocateCSystem(KerberosKeyType type, out KerberosCryptoSystem cryptoSystem)
{
IntPtr cryptoSystemPtr;
NtStatus status = CDLocateCSystem(type, out cryptoSystemPtr);
cryptoSystem = (status == NtStatus.Success) ? (KerberosCryptoSystem)Marshal.PtrToStructure(cryptoSystemPtr, typeof(KerberosCryptoSystem)) : null;
return status;
}
/// <summary> /// <summary>
/// Creates a subkey under HKEY_USERS or HKEY_LOCAL_MACHINE and loads the data from the specified registry hive into that subkey. /// Creates a subkey under HKEY_USERS or HKEY_LOCAL_MACHINE and loads the data from the specified registry hive into that subkey.