Browse Source

SMB1: Renamed ServerCapabilities to Capabilities

Tal Aloni 7 years ago
parent
commit
b70caac445

+ 3 - 3
SMBLibrary/Client/SMB1Client.cs

@@ -154,7 +154,7 @@ namespace SMBLibrary.Client
                 SessionSetupAndXRequest request = new SessionSetupAndXRequest();
                 request.MaxBufferSize = MaxBufferSize;
                 request.MaxMpxCount = MaxMpxCount;
-                request.Capabilities = ServerCapabilities.Unicode | ServerCapabilities.NTStatusCode;
+                request.Capabilities = Capabilities.Unicode | Capabilities.NTStatusCode;
                 request.AccountName = userName;
                 request.PrimaryDomain = domainName;
                 byte[] clientChallenge = new byte[8];
@@ -195,7 +195,7 @@ namespace SMBLibrary.Client
                 SessionSetupAndXRequestExtended request = new SessionSetupAndXRequestExtended();
                 request.MaxBufferSize = MaxBufferSize;
                 request.MaxMpxCount = MaxMpxCount;
-                request.Capabilities = ServerCapabilities.Unicode | ServerCapabilities.NTStatusCode;
+                request.Capabilities = Capabilities.Unicode | Capabilities.NTStatusCode;
                 request.SecurityBlob = NTLMAuthenticationHelper.GetNegotiateMessage(m_securityBlob, domainName, authenticationMethod);
                 TrySendMessage(request);
                 
@@ -209,7 +209,7 @@ namespace SMBLibrary.Client
                         request = new SessionSetupAndXRequestExtended();
                         request.MaxBufferSize = MaxBufferSize;
                         request.MaxMpxCount = MaxMpxCount;
-                        request.Capabilities = ServerCapabilities.Unicode | ServerCapabilities.NTStatusCode | ServerCapabilities.ExtendedSecurity;
+                        request.Capabilities = Capabilities.Unicode | Capabilities.NTStatusCode | Capabilities.ExtendedSecurity;
 
                         request.SecurityBlob = NTLMAuthenticationHelper.GetAuthenticateMessage(response.SecurityBlob, domainName, userName, password, authenticationMethod, out m_sessionKey);
                         TrySendMessage(request);

+ 2 - 2
SMBLibrary/SMB1/Commands/NegotiateResponse.cs

@@ -25,7 +25,7 @@ namespace SMBLibrary.SMB1
         public uint MaxBufferSize;
         public uint MaxRawSize;
         public uint SessionKey;
-        public ServerCapabilities Capabilities;
+        public Capabilities Capabilities;
         public DateTime SystemTime;
         public short ServerTimeZone;
         private byte ChallengeLength;
@@ -50,7 +50,7 @@ namespace SMBLibrary.SMB1
             MaxBufferSize = LittleEndianConverter.ToUInt32(this.SMBParameters, 7);
             MaxRawSize = LittleEndianConverter.ToUInt32(this.SMBParameters, 11);
             SessionKey = LittleEndianConverter.ToUInt32(this.SMBParameters, 15);
-            Capabilities = (ServerCapabilities)LittleEndianConverter.ToUInt32(this.SMBParameters, 19);
+            Capabilities = (Capabilities)LittleEndianConverter.ToUInt32(this.SMBParameters, 19);
             SystemTime = FileTimeHelper.ReadFileTime(this.SMBParameters, 23);
             ServerTimeZone = LittleEndianConverter.ToInt16(this.SMBParameters, 31);
             ChallengeLength = ByteReader.ReadByte(this.SMBParameters, 33);

+ 2 - 2
SMBLibrary/SMB1/Commands/NegotiateResponseExtended.cs

@@ -25,7 +25,7 @@ namespace SMBLibrary.SMB1
         public uint MaxBufferSize;
         public uint MaxRawSize;
         public uint SessionKey;
-        public ServerCapabilities Capabilities;
+        public Capabilities Capabilities;
         public DateTime SystemTime;
         public short ServerTimeZone;
         private byte ChallengeLength; // MUST be set to 0
@@ -47,7 +47,7 @@ namespace SMBLibrary.SMB1
             MaxBufferSize = LittleEndianConverter.ToUInt32(this.SMBParameters, 7);
             MaxRawSize = LittleEndianConverter.ToUInt32(this.SMBParameters, 11);
             SessionKey = LittleEndianConverter.ToUInt32(this.SMBParameters, 15);
-            Capabilities = (ServerCapabilities)LittleEndianConverter.ToUInt32(this.SMBParameters, 19);
+            Capabilities = (Capabilities)LittleEndianConverter.ToUInt32(this.SMBParameters, 19);
             SystemTime = FileTimeHelper.ReadFileTime(this.SMBParameters, 23);
             ServerTimeZone = LittleEndianConverter.ToInt16(this.SMBParameters, 31);
             ChallengeLength = ByteReader.ReadByte(this.SMBParameters, 33);

+ 2 - 2
SMBLibrary/SMB1/Commands/SMB1Command.cs

@@ -370,8 +370,8 @@ namespace SMBLibrary.SMB1
                         // Both NegotiateResponse and NegotiateResponseExtended have WordCount set to 17
                         if (wordCount * 2 == NegotiateResponse.ParametersLength)
                         {
-                            ServerCapabilities capabilities = (ServerCapabilities)LittleEndianConverter.ToUInt32(buffer, offset + 20);
-                            if ((capabilities & ServerCapabilities.ExtendedSecurity) > 0)
+                            Capabilities capabilities = (Capabilities)LittleEndianConverter.ToUInt32(buffer, offset + 20);
+                            if ((capabilities & Capabilities.ExtendedSecurity) > 0)
                             {
                                 return new NegotiateResponseExtended(buffer, offset);
                             }

+ 3 - 3
SMBLibrary/SMB1/Commands/SessionSetupAndXRequest.cs

@@ -25,7 +25,7 @@ namespace SMBLibrary.SMB1
         private ushort OEMPasswordLength;
         private ushort UnicodePasswordLength;
         public uint Reserved;
-        public ServerCapabilities Capabilities;
+        public Capabilities Capabilities;
         // Data:
         public byte[] OEMPassword;
         public byte[] UnicodePassword;
@@ -52,7 +52,7 @@ namespace SMBLibrary.SMB1
             OEMPasswordLength = LittleEndianConverter.ToUInt16(this.SMBParameters, 14);
             UnicodePasswordLength = LittleEndianConverter.ToUInt16(this.SMBParameters, 16);
             Reserved = LittleEndianConverter.ToUInt32(this.SMBParameters, 18);
-            Capabilities = (ServerCapabilities)LittleEndianConverter.ToUInt32(this.SMBParameters, 22);
+            Capabilities = (Capabilities)LittleEndianConverter.ToUInt32(this.SMBParameters, 22);
 
             OEMPassword = ByteReader.ReadBytes(this.SMBData, 0, OEMPasswordLength);
             UnicodePassword = ByteReader.ReadBytes(this.SMBData, OEMPasswordLength, UnicodePasswordLength);
@@ -73,7 +73,7 @@ namespace SMBLibrary.SMB1
 
         public override byte[] GetBytes(bool isUnicode)
         {
-            Capabilities &= ~ServerCapabilities.ExtendedSecurity;
+            Capabilities &= ~Capabilities.ExtendedSecurity;
 
             OEMPasswordLength = (ushort)OEMPassword.Length;
             UnicodePasswordLength = (ushort)UnicodePassword.Length;

+ 3 - 3
SMBLibrary/SMB1/Commands/SessionSetupAndXRequestExtended.cs

@@ -24,7 +24,7 @@ namespace SMBLibrary.SMB1
         public uint SessionKey;
         private ushort SecurityBlobLength;
         public uint Reserved;
-        public ServerCapabilities Capabilities;
+        public Capabilities Capabilities;
         // Data:
         public byte[] SecurityBlob;
         public string NativeOS;     // SMB_STRING (If Unicode, this field MUST be aligned to start on a 2-byte boundary from the start of the SMB header)
@@ -44,7 +44,7 @@ namespace SMBLibrary.SMB1
             SessionKey = LittleEndianConverter.ToUInt32(this.SMBParameters, 10);
             SecurityBlobLength = LittleEndianConverter.ToUInt16(this.SMBParameters, 14);
             Reserved = LittleEndianConverter.ToUInt32(this.SMBParameters, 16);
-            Capabilities = (ServerCapabilities)LittleEndianConverter.ToUInt32(this.SMBParameters, 20);
+            Capabilities = (Capabilities)LittleEndianConverter.ToUInt32(this.SMBParameters, 20);
 
             SecurityBlob = ByteReader.ReadBytes(this.SMBData, 0, SecurityBlobLength);
 
@@ -62,7 +62,7 @@ namespace SMBLibrary.SMB1
 
         public override byte[] GetBytes(bool isUnicode)
         {
-            Capabilities |= ServerCapabilities.ExtendedSecurity;
+            Capabilities |= Capabilities.ExtendedSecurity;
             SecurityBlobLength = (ushort)SecurityBlob.Length;
 
             this.SMBParameters = new byte[ParametersLength];

+ 1 - 1
SMBLibrary/SMB1/Enums/Negotiate/ServerCapabilities.cs

@@ -3,7 +3,7 @@ using System;
 namespace SMBLibrary.SMB1
 {
     [Flags]
-    public enum ServerCapabilities : uint
+    public enum Capabilities : uint
     {
         RawMode          = 0x00000001, // CAP_RAW_MODE
         MPXMode          = 0x00000002, // SMB_COM_READ_MPX

+ 1 - 1
SMBLibrary/SMBLibrary.csproj

@@ -366,8 +366,8 @@
     <Compile Include="SMB1\Enums\HeaderFlags.cs" />
     <Compile Include="SMB1\Enums\HeaderFlags2.cs" />
     <Compile Include="SMB1\Enums\Locking\LockType.cs" />
+    <Compile Include="SMB1\Enums\Negotiate\Capabilities.cs" />
     <Compile Include="SMB1\Enums\Negotiate\SecurityMode.cs" />
-    <Compile Include="SMB1\Enums\Negotiate\ServerCapabilities.cs" />
     <Compile Include="SMB1\Enums\NTCreate\FileStatusFlags.cs" />
     <Compile Include="SMB1\Enums\NTCreate\ImpersonationLevel.cs" />
     <Compile Include="SMB1\Enums\NTCreate\NTCreateFlags.cs" />

+ 15 - 15
SMBLibrary/Server/SMB1/NegotiateHelper.cs

@@ -29,13 +29,13 @@ namespace SMBLibrary.Server.SMB1
             response.MaxNumberVcs = 1;
             response.MaxBufferSize = 16644;
             response.MaxRawSize = 65536;
-            response.Capabilities = ServerCapabilities.Unicode |
-                                    ServerCapabilities.LargeFiles |
-                                    ServerCapabilities.NTSMB |
-                                    ServerCapabilities.NTStatusCode |
-                                    ServerCapabilities.NTFind |
-                                    ServerCapabilities.LargeRead |
-                                    ServerCapabilities.LargeWrite;
+            response.Capabilities = Capabilities.Unicode |
+                                    Capabilities.LargeFiles |
+                                    Capabilities.NTSMB |
+                                    Capabilities.NTStatusCode |
+                                    Capabilities.NTFind |
+                                    Capabilities.LargeRead |
+                                    Capabilities.LargeWrite;
             response.SystemTime = DateTime.UtcNow;
             response.ServerTimeZone = (short)-TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalMinutes;
             NegotiateMessage negotiateMessage = CreateNegotiateMessage();
@@ -60,14 +60,14 @@ namespace SMBLibrary.Server.SMB1
             response.MaxNumberVcs = 1;
             response.MaxBufferSize = 16644;
             response.MaxRawSize = 65536;
-            response.Capabilities = ServerCapabilities.Unicode |
-                                    ServerCapabilities.LargeFiles |
-                                    ServerCapabilities.NTSMB |
-                                    ServerCapabilities.NTStatusCode |
-                                    ServerCapabilities.NTFind |
-                                    ServerCapabilities.LargeRead |
-                                    ServerCapabilities.LargeWrite |
-                                    ServerCapabilities.ExtendedSecurity;
+            response.Capabilities = Capabilities.Unicode |
+                                    Capabilities.LargeFiles |
+                                    Capabilities.NTSMB |
+                                    Capabilities.NTStatusCode |
+                                    Capabilities.NTFind |
+                                    Capabilities.LargeRead |
+                                    Capabilities.LargeWrite |
+                                    Capabilities.ExtendedSecurity;
             response.SystemTime = DateTime.UtcNow;
             response.ServerTimeZone = (short)-TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalMinutes;
             response.ServerGuid = serverGuid;

+ 2 - 2
SMBLibrary/Server/SMB1/SessionSetupHelper.cs

@@ -58,11 +58,11 @@ namespace SMBLibrary.Server.SMB1
 
             header.UID = session.UserID;
             response.PrimaryDomain = request.PrimaryDomain;
-            if ((request.Capabilities & ServerCapabilities.LargeRead) > 0)
+            if ((request.Capabilities & Capabilities.LargeRead) > 0)
             {
                 state.LargeRead = true;
             }
-            if ((request.Capabilities & ServerCapabilities.LargeWrite) > 0)
+            if ((request.Capabilities & Capabilities.LargeWrite) > 0)
             {
                 state.LargeWrite = true;
             }