From d7a16a5217d4b78ce7e6a4d016bcdcea108ae0d0 Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Wed, 27 Sep 2017 14:20:40 +0300 Subject: [PATCH] SMB1: Added implementation of TRANS2_SET_FS_INFORMATION request and response --- .../Transaction2SetFSInformationRequest.cs | 63 +++++++++++++++++++ .../Transaction2SetFSInformationResponse.cs | 30 +++++++++ .../Transaction2Subcommand.cs | 2 + SMBLibrary/SMBLibrary.csproj | 2 + SMBLibrary/Server/SMB1/TransactionHelper.cs | 4 ++ 5 files changed, 101 insertions(+) create mode 100644 SMBLibrary/SMB1/Transaction2Subcommands/Transaction2SetFSInformationRequest.cs create mode 100644 SMBLibrary/SMB1/Transaction2Subcommands/Transaction2SetFSInformationResponse.cs diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Transaction2SetFSInformationRequest.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Transaction2SetFSInformationRequest.cs new file mode 100644 index 0000000..60b4f5a --- /dev/null +++ b/SMBLibrary/SMB1/Transaction2Subcommands/Transaction2SetFSInformationRequest.cs @@ -0,0 +1,63 @@ +/* Copyright (C) 2017 Tal Aloni . 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 +{ + /// + /// TRANS2_SET_FS_INFORMATION Request + /// + 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; + } + } + } +} diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Transaction2SetFSInformationResponse.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Transaction2SetFSInformationResponse.cs new file mode 100644 index 0000000..d01a5dc --- /dev/null +++ b/SMBLibrary/SMB1/Transaction2Subcommands/Transaction2SetFSInformationResponse.cs @@ -0,0 +1,30 @@ +/* Copyright (C) 2017 Tal Aloni . 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 +{ + /// + /// TRANS2_SET_FS_INFORMATION Response + /// + public class Transaction2SetFSInformationResponse : Transaction2Subcommand + { + public Transaction2SetFSInformationResponse() : base() + { + } + + public override Transaction2SubcommandName SubcommandName + { + get + { + return Transaction2SubcommandName.TRANS2_SET_FS_INFORMATION; + } + } + } +} diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Transaction2Subcommand.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Transaction2Subcommand.cs index ce7b6c2..47fb75e 100644 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Transaction2Subcommand.cs +++ b/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: diff --git a/SMBLibrary/SMBLibrary.csproj b/SMBLibrary/SMBLibrary.csproj index 701e1f7..62b57ec 100644 --- a/SMBLibrary/SMBLibrary.csproj +++ b/SMBLibrary/SMBLibrary.csproj @@ -446,6 +446,8 @@ + + diff --git a/SMBLibrary/Server/SMB1/TransactionHelper.cs b/SMBLibrary/Server/SMB1/TransactionHelper.cs index 5caa89c..010ee46 100644 --- a/SMBLibrary/Server/SMB1/TransactionHelper.cs +++ b/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);