Renamed Version to NTLMVersion

This commit is contained in:
Tal Aloni 2017-02-15 13:37:23 +02:00
parent 457d978f70
commit d45efdcaa8
9 changed files with 22 additions and 19 deletions

View file

@ -27,7 +27,7 @@ namespace SMBLibrary.Authentication
public string WorkStation; public string WorkStation;
public byte[] EncryptedRandomSessionKey; public byte[] EncryptedRandomSessionKey;
public NegotiateFlags NegotiateFlags; public NegotiateFlags NegotiateFlags;
public Version Version; public NTLMVersion Version;
// 16-byte MIC field is omitted for Windows NT / 2000 / XP / Server 2003 // 16-byte MIC field is omitted for Windows NT / 2000 / XP / Server 2003
public AuthenticateMessage() public AuthenticateMessage()
@ -53,7 +53,7 @@ namespace SMBLibrary.Authentication
NegotiateFlags = (NegotiateFlags)LittleEndianConverter.ToUInt32(buffer, 60); NegotiateFlags = (NegotiateFlags)LittleEndianConverter.ToUInt32(buffer, 60);
if ((NegotiateFlags & NegotiateFlags.Version) > 0) if ((NegotiateFlags & NegotiateFlags.Version) > 0)
{ {
Version = new Version(buffer, 64); Version = new NTLMVersion(buffer, 64);
} }
} }

View file

@ -23,7 +23,7 @@ namespace SMBLibrary.Authentication
public byte[] ServerChallenge; // 8 bytes public byte[] ServerChallenge; // 8 bytes
// Reserved - 8 bytes // Reserved - 8 bytes
public byte[] TargetInfo; // sequence of AV_PAIR structures public byte[] TargetInfo; // sequence of AV_PAIR structures
public Version Version; public NTLMVersion Version;
public ChallengeMessage() public ChallengeMessage()
{ {
@ -42,7 +42,7 @@ namespace SMBLibrary.Authentication
TargetInfo = AuthenticationMessageUtils.ReadBufferPointer(buffer, 40); TargetInfo = AuthenticationMessageUtils.ReadBufferPointer(buffer, 40);
if ((NegotiateFlags & NegotiateFlags.Version) > 0) if ((NegotiateFlags & NegotiateFlags.Version) > 0)
{ {
Version = new Version(buffer, 48); Version = new NTLMVersion(buffer, 48);
} }
} }

View file

@ -11,7 +11,10 @@ using Utilities;
namespace SMBLibrary.Authentication namespace SMBLibrary.Authentication
{ {
public class Version /// <summary>
/// [MS-NLMP] 2.2.2.10 - VERSION
/// </summary>
public class NTLMVersion
{ {
public const byte NTLMSSP_REVISION_W2K3 = 0x0F; public const byte NTLMSSP_REVISION_W2K3 = 0x0F;
@ -21,7 +24,7 @@ namespace SMBLibrary.Authentication
// Reserved - 3 bytes // Reserved - 3 bytes
public byte NTLMRevisionCurrent; public byte NTLMRevisionCurrent;
public Version(byte majorVersion, byte minorVersion, ushort build, byte ntlmRevisionCurrent) public NTLMVersion(byte majorVersion, byte minorVersion, ushort build, byte ntlmRevisionCurrent)
{ {
ProductMajorVersion = majorVersion; ProductMajorVersion = majorVersion;
ProductMinorVersion = minorVersion; ProductMinorVersion = minorVersion;
@ -29,7 +32,7 @@ namespace SMBLibrary.Authentication
NTLMRevisionCurrent = ntlmRevisionCurrent; NTLMRevisionCurrent = ntlmRevisionCurrent;
} }
public Version(byte[] buffer, int offset) public NTLMVersion(byte[] buffer, int offset)
{ {
ProductMajorVersion = ByteReader.ReadByte(buffer, offset + 0); ProductMajorVersion = ByteReader.ReadByte(buffer, offset + 0);
ProductMinorVersion = ByteReader.ReadByte(buffer, offset + 1); ProductMinorVersion = ByteReader.ReadByte(buffer, offset + 1);
@ -45,19 +48,19 @@ namespace SMBLibrary.Authentication
ByteWriter.WriteByte(buffer, offset + 7, NTLMRevisionCurrent); ByteWriter.WriteByte(buffer, offset + 7, NTLMRevisionCurrent);
} }
public static Version WindowsXP public static NTLMVersion WindowsXP
{ {
get get
{ {
return new Version(5, 1, 2600, NTLMSSP_REVISION_W2K3); return new NTLMVersion(5, 1, 2600, NTLMSSP_REVISION_W2K3);
} }
} }
public static Version Server2003 public static NTLMVersion Server2003
{ {
get get
{ {
return new Version(5, 2, 3790, NTLMSSP_REVISION_W2K3); return new NTLMVersion(5, 2, 3790, NTLMSSP_REVISION_W2K3);
} }
} }
} }

View file

@ -21,7 +21,7 @@ namespace SMBLibrary.Authentication
public NegotiateFlags NegotiateFlags; public NegotiateFlags NegotiateFlags;
public string DomainName; public string DomainName;
public string Workstation; public string Workstation;
public Version Version; public NTLMVersion Version;
public NegotiateMessage() public NegotiateMessage()
{ {
@ -40,7 +40,7 @@ namespace SMBLibrary.Authentication
Workstation = AuthenticationMessageUtils.ReadAnsiStringBufferPointer(buffer, 24); Workstation = AuthenticationMessageUtils.ReadAnsiStringBufferPointer(buffer, 24);
if ((NegotiateFlags & NegotiateFlags.Version) > 0) if ((NegotiateFlags & NegotiateFlags.Version) > 0)
{ {
Version = new Version(buffer, 32); Version = new NTLMVersion(buffer, 32);
} }
} }

View file

@ -40,7 +40,7 @@
<Compile Include="Authentication\AuthenticateMessage\Enums\NegotiateFlags.cs" /> <Compile Include="Authentication\AuthenticateMessage\Enums\NegotiateFlags.cs" />
<Compile Include="Authentication\AuthenticateMessage\NegotiateMessage.cs" /> <Compile Include="Authentication\AuthenticateMessage\NegotiateMessage.cs" />
<Compile Include="Authentication\AuthenticateMessage\NTLMv2ClientChallenge.cs" /> <Compile Include="Authentication\AuthenticateMessage\NTLMv2ClientChallenge.cs" />
<Compile Include="Authentication\AuthenticateMessage\Version.cs" /> <Compile Include="Authentication\AuthenticateMessage\NTLMVersion.cs" />
<Compile Include="Authentication\GSSAPI\DerEncodingHelper.cs" /> <Compile Include="Authentication\GSSAPI\DerEncodingHelper.cs" />
<Compile Include="Authentication\GSSAPI\GSSAPIHelper.cs" /> <Compile Include="Authentication\GSSAPI\GSSAPIHelper.cs" />
<Compile Include="Authentication\GSSAPI\SimpleProtectedNegotiationToken.cs" /> <Compile Include="Authentication\GSSAPI\SimpleProtectedNegotiationToken.cs" />

View file

@ -147,7 +147,7 @@ namespace SMBLibrary.Server
message.TargetName = Environment.MachineName; message.TargetName = Environment.MachineName;
message.ServerChallenge = serverChallenge; message.ServerChallenge = serverChallenge;
message.TargetInfo = AVPairUtils.GetAVPairSequence(Environment.MachineName, Environment.MachineName); message.TargetInfo = AVPairUtils.GetAVPairSequence(Environment.MachineName, Environment.MachineName);
message.Version = Authentication.Version.Server2003; message.Version = NTLMVersion.Server2003;
return message; return message;
} }

View file

@ -81,7 +81,7 @@ namespace SMBLibrary.Server.SMB1
NegotiateFlags.Version | NegotiateFlags.Version |
NegotiateFlags.Use128BitEncryption | NegotiateFlags.Use128BitEncryption |
NegotiateFlags.Use56BitEncryption; NegotiateFlags.Use56BitEncryption;
negotiateMessage.Version = Authentication.Version.Server2003; negotiateMessage.Version = NTLMVersion.Server2003;
return negotiateMessage; return negotiateMessage;
} }
} }

View file

@ -191,7 +191,7 @@ namespace SMBLibrary.Server.SMB1
authenticateMessage.UserName = accountNameToAuth; authenticateMessage.UserName = accountNameToAuth;
authenticateMessage.LmChallengeResponse = lmChallengeResponse; authenticateMessage.LmChallengeResponse = lmChallengeResponse;
authenticateMessage.NtChallengeResponse = ntChallengeResponse; authenticateMessage.NtChallengeResponse = ntChallengeResponse;
authenticateMessage.Version = Authentication.Version.Server2003; authenticateMessage.Version = NTLMVersion.Server2003;
return authenticateMessage; return authenticateMessage;
} }
} }

View file

@ -96,7 +96,7 @@ namespace SMBLibrary
byte[] serverChallenge = new byte[] { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }; byte[] serverChallenge = new byte[] { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };
ChallengeMessage message = new ChallengeMessage(); ChallengeMessage message = new ChallengeMessage();
message.ServerChallenge = serverChallenge; message.ServerChallenge = serverChallenge;
message.Version = new Authentication.Version(6, 0, 6000, 15); message.Version = new NTLMVersion(6, 0, 6000, 15);
message.NegotiateFlags = NegotiateFlags.UnicodeEncoding | NegotiateFlags.OEMEncoding | NegotiateFlags.Sign | NegotiateFlags.Seal | NegotiateFlags.NTLMKey | NegotiateFlags.AlwaysSign | NegotiateFlags.TargetTypeServer | NegotiateFlags.ExtendedSecurity | NegotiateFlags.TargetInfo | NegotiateFlags.Version | NegotiateFlags.Use128BitEncryption | NegotiateFlags.KeyExchange | NegotiateFlags.Use56BitEncryption; message.NegotiateFlags = NegotiateFlags.UnicodeEncoding | NegotiateFlags.OEMEncoding | NegotiateFlags.Sign | NegotiateFlags.Seal | NegotiateFlags.NTLMKey | NegotiateFlags.AlwaysSign | NegotiateFlags.TargetTypeServer | NegotiateFlags.ExtendedSecurity | NegotiateFlags.TargetInfo | NegotiateFlags.Version | NegotiateFlags.Use128BitEncryption | NegotiateFlags.KeyExchange | NegotiateFlags.Use56BitEncryption;
message.TargetName = "Server"; message.TargetName = "Server";
byte[] serverAVPair = AVPairUtils.GetAVPairSequence("Domain", "Server"); byte[] serverAVPair = AVPairUtils.GetAVPairSequence("Domain", "Server");
@ -138,7 +138,7 @@ namespace SMBLibrary
AuthenticateMessage message = new AuthenticateMessage(); AuthenticateMessage message = new AuthenticateMessage();
message.EncryptedRandomSessionKey = sessionKey; message.EncryptedRandomSessionKey = sessionKey;
message.Version = new Authentication.Version(5, 1, 2600, Authentication.Version.NTLMSSP_REVISION_W2K3); message.Version = new NTLMVersion(5, 1, 2600, Authentication.NTLMVersion.NTLMSSP_REVISION_W2K3);
message.NegotiateFlags = NegotiateFlags.UnicodeEncoding | NegotiateFlags.TargetNameSupplied | NegotiateFlags.Sign | NegotiateFlags.Seal | NegotiateFlags.NTLMKey | NegotiateFlags.AlwaysSign | NegotiateFlags.ExtendedSecurity | NegotiateFlags.TargetInfo | NegotiateFlags.Version | NegotiateFlags.Use128BitEncryption | NegotiateFlags.KeyExchange | NegotiateFlags.Use56BitEncryption; message.NegotiateFlags = NegotiateFlags.UnicodeEncoding | NegotiateFlags.TargetNameSupplied | NegotiateFlags.Sign | NegotiateFlags.Seal | NegotiateFlags.NTLMKey | NegotiateFlags.AlwaysSign | NegotiateFlags.ExtendedSecurity | NegotiateFlags.TargetInfo | NegotiateFlags.Version | NegotiateFlags.Use128BitEncryption | NegotiateFlags.KeyExchange | NegotiateFlags.Use56BitEncryption;
message.DomainName = "Domain"; message.DomainName = "Domain";
message.WorkStation = "COMPUTER"; message.WorkStation = "COMPUTER";