public static bool NTLMv1ResponseTest() { byte[] challenge = new byte[] { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }; byte[] response = NTAuthentication.ComputeNTLMv1Response(challenge, "Password"); byte[] expected = { 0x67, 0xc4, 0x30, 0x11, 0xf3, 0x02, 0x98, 0xa2, 0xad, 0x35, 0xec, 0xe6, 0x4f, 0x16, 0x33, 0x1c, 0x44, 0xbd, 0xbe, 0xd9, 0x27, 0x84, 0x1f, 0x94 }; bool success = ByteUtils.AreByteArraysEqual(response, expected); return(success); }
public bool IsPasswordEmpty(byte[] lmResponse, byte[] ntlmResponse) { // Special case for anonymous authentication // Windows NT4 SP6 will send 1 null byte OEMPassword and 0 bytes UnicodePassword for anonymous authentication if (lmResponse.Length == 0 || ByteUtils.AreByteArraysEqual(lmResponse, new byte[] { 0x00 }) || ntlmResponse.Length == 0) { return(true); } byte[] emptyPasswordLMv1Response = NTAuthentication.ComputeLMv1Response(m_serverChallenge, String.Empty); if (ByteUtils.AreByteArraysEqual(emptyPasswordLMv1Response, lmResponse)) { return(true); } byte[] emptyPasswordNTLMv1Response = NTAuthentication.ComputeNTLMv1Response(m_serverChallenge, String.Empty); if (ByteUtils.AreByteArraysEqual(emptyPasswordNTLMv1Response, ntlmResponse)) { return(true); } return(false); }
/// <summary> /// LM v1 / NTLM v1 /// </summary> public User AuthenticateV1(string accountNameToAuth, byte[] serverChallenge, byte[] lmResponse, byte[] ntlmResponse) { for (int index = 0; index < this.Count; index++) { string accountName = this[index].AccountName; string password = this[index].Password; if (String.Equals(accountName, accountNameToAuth, StringComparison.InvariantCultureIgnoreCase)) { byte[] expectedLMResponse = NTAuthentication.ComputeLMv1Response(serverChallenge, password); if (ByteUtils.AreByteArraysEqual(expectedLMResponse, lmResponse)) { return(this[index]); } byte[] expectedNTLMResponse = NTAuthentication.ComputeNTLMv1Response(serverChallenge, password); if (ByteUtils.AreByteArraysEqual(expectedNTLMResponse, ntlmResponse)) { return(this[index]); } } } return(null); }