Browse Source

SMB1: Added implementation of TRANS2_SET_FS_INFORMATION request and response

Tal Aloni 7 years ago
parent
commit
d7a16a5217

+ 63 - 0
SMBLibrary/SMB1/Transaction2Subcommands/Transaction2SetFSInformationRequest.cs

@@ -0,0 +1,63 @@
+/* Copyright (C) 2017 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
+ * 
+ * You can redistribute this program and/or modify it under the terms of
+ * the GNU Lesser Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ */
+using System;
+using System.Collections.Generic;
+using Utilities;
+
+namespace SMBLibrary.SMB1
+{
+    /// <summary>
+    /// TRANS2_SET_FS_INFORMATION Request
+    /// </summary>
+    public class Transaction2SetFSInformationRequest : Transaction2Subcommand
+    {
+        public const int ParametersLength = 4;
+        // Parameters:
+        public ushort FID;
+        public ushort InformationLevel; // This field MUST be a pass-through Information Level.
+        // Data:
+        public byte[] InformationBytes;
+
+        public Transaction2SetFSInformationRequest() : base()
+        {
+        }
+
+        public Transaction2SetFSInformationRequest(byte[] parameters, byte[] data, bool isUnicode) : base()
+        {
+            FID = LittleEndianConverter.ToUInt16(parameters, 0);
+            InformationLevel = LittleEndianConverter.ToUInt16(parameters, 2);
+
+            InformationBytes = data;
+        }
+
+        public override byte[] GetSetup()
+        {
+            return LittleEndianConverter.GetBytes((ushort)SubcommandName);
+        }
+
+        public override byte[] GetParameters(bool isUnicode)
+        {
+            byte[] parameters = new byte[ParametersLength];
+            LittleEndianWriter.WriteUInt16(parameters, 0, FID);
+            LittleEndianWriter.WriteUInt16(parameters, 2, InformationLevel);
+            return parameters;
+        }
+
+        public override byte[] GetData(bool isUnicode)
+        {
+            return InformationBytes;
+        }
+
+        public override Transaction2SubcommandName SubcommandName
+        {
+            get
+            {
+                return Transaction2SubcommandName.TRANS2_SET_FS_INFORMATION;
+            }
+        }
+    }
+}

+ 30 - 0
SMBLibrary/SMB1/Transaction2Subcommands/Transaction2SetFSInformationResponse.cs

@@ -0,0 +1,30 @@
+/* Copyright (C) 2017 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
+ * 
+ * You can redistribute this program and/or modify it under the terms of
+ * the GNU Lesser Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ */
+using System;
+using System.Collections.Generic;
+using Utilities;
+
+namespace SMBLibrary.SMB1
+{
+    /// <summary>
+    /// TRANS2_SET_FS_INFORMATION Response
+    /// </summary>
+    public class Transaction2SetFSInformationResponse : Transaction2Subcommand
+    {
+        public Transaction2SetFSInformationResponse() : base()
+        {
+        }
+
+        public override Transaction2SubcommandName SubcommandName
+        {
+            get
+            {
+                return Transaction2SubcommandName.TRANS2_SET_FS_INFORMATION;
+            }
+        }
+    }
+}

+ 2 - 0
SMBLibrary/SMB1/Transaction2Subcommands/Transaction2Subcommand.cs

@@ -52,6 +52,8 @@ namespace SMBLibrary.SMB1
                         return new Transaction2FindNext2Request(parameters, data, isUnicode);
                     case Transaction2SubcommandName.TRANS2_QUERY_FS_INFORMATION:
                         return new Transaction2QueryFSInformationRequest(parameters, data, isUnicode);
+                    case Transaction2SubcommandName.TRANS2_SET_FS_INFORMATION:
+                        return new Transaction2SetFSInformationRequest(parameters, data, isUnicode);
                     case Transaction2SubcommandName.TRANS2_QUERY_PATH_INFORMATION:
                         return new Transaction2QueryPathInformationRequest(parameters, data, isUnicode);
                     case Transaction2SubcommandName.TRANS2_SET_PATH_INFORMATION:

+ 2 - 0
SMBLibrary/SMBLibrary.csproj

@@ -446,6 +446,8 @@
     <Compile Include="SMB1\Transaction2Subcommands\Transaction2QueryPathInformationResponse.cs" />
     <Compile Include="SMB1\Transaction2Subcommands\Transaction2SetFileInformationRequest.cs" />
     <Compile Include="SMB1\Transaction2Subcommands\Transaction2SetFileInformationResponse.cs" />
+    <Compile Include="SMB1\Transaction2Subcommands\Transaction2SetFSInformationRequest.cs" />
+    <Compile Include="SMB1\Transaction2Subcommands\Transaction2SetFSInformationResponse.cs" />
     <Compile Include="SMB1\Transaction2Subcommands\Transaction2SetPathInformationRequest.cs" />
     <Compile Include="SMB1\Transaction2Subcommands\Transaction2SetPathInformationResponse.cs" />
     <Compile Include="SMB1\Transaction2Subcommands\Transaction2Subcommand.cs" />

+ 4 - 0
SMBLibrary/Server/SMB1/TransactionHelper.cs

@@ -208,6 +208,10 @@ namespace SMBLibrary.Server.SMB1
             {
                 subcommandResponse = Transaction2SubcommandHelper.GetSubcommandResponse(header, (Transaction2QueryFSInformationRequest)subcommand, share, state);
             }
+            else if (subcommand is Transaction2SetFSInformationRequest)
+            {
+                header.Status = NTStatus.STATUS_NOT_IMPLEMENTED;
+            }
             else if (subcommand is Transaction2QueryPathInformationRequest)
             {
                 subcommandResponse = Transaction2SubcommandHelper.GetSubcommandResponse(header, (Transaction2QueryPathInformationRequest)subcommand, share, state);