diff --git a/SMBLibrary/SMB1/Commands/SMB1Command.cs b/SMBLibrary/SMB1/Commands/SMB1Command.cs index 33f588b..e8ab433 100644 --- a/SMBLibrary/SMB1/Commands/SMB1Command.cs +++ b/SMBLibrary/SMB1/Commands/SMB1Command.cs @@ -196,7 +196,16 @@ namespace SMBLibrary.SMB1 case CommandName.SMB_COM_LOCKING_ANDX: return new LockingAndXResponse(buffer, offset); case CommandName.SMB_COM_TRANSACTION: - return new TransactionResponse(buffer, offset); + { + if (wordCount * 2 == TransactionInterimResponse.ParametersLength) + { + return new TransactionInterimResponse(buffer, offset); + } + else + { + return new TransactionResponse(buffer, offset); + } + } case CommandName.SMB_COM_ECHO: return new EchoResponse(buffer, offset); case CommandName.SMB_COM_OPEN_ANDX: @@ -219,7 +228,16 @@ namespace SMBLibrary.SMB1 case CommandName.SMB_COM_WRITE_ANDX: return new WriteAndXResponse(buffer, offset); case CommandName.SMB_COM_TRANSACTION2: - return new Transaction2Response(buffer, offset); + { + if (wordCount * 2 == Transaction2InterimResponse.ParametersLength) + { + return new Transaction2InterimResponse(buffer, offset); + } + else + { + return new Transaction2Response(buffer, offset); + } + } case CommandName.SMB_COM_FIND_CLOSE2: return new FindClose2Response(buffer, offset); case CommandName.SMB_COM_TREE_DISCONNECT: diff --git a/SMBLibrary/SMB1/Commands/Transaction2InterimResponse.cs b/SMBLibrary/SMB1/Commands/Transaction2InterimResponse.cs new file mode 100644 index 0000000..cbdaf47 --- /dev/null +++ b/SMBLibrary/SMB1/Commands/Transaction2InterimResponse.cs @@ -0,0 +1,31 @@ +/* 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 +{ + public class Transaction2InterimResponse : TransactionInterimResponse + { + public Transaction2InterimResponse() : base() + { + } + + public Transaction2InterimResponse(byte[] buffer, int offset) : base(buffer, offset) + { + } + + public override CommandName CommandName + { + get + { + return CommandName.SMB_COM_TRANSACTION2; + } + } + } +} diff --git a/SMBLibrary/SMB1/Commands/TransactionInterimResponse.cs b/SMBLibrary/SMB1/Commands/TransactionInterimResponse.cs new file mode 100644 index 0000000..f5bf679 --- /dev/null +++ b/SMBLibrary/SMB1/Commands/TransactionInterimResponse.cs @@ -0,0 +1,41 @@ +/* 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 +{ + /// + /// SMB_COM_TRANSACTION Interim Response + /// + public class TransactionInterimResponse : SMB1Command + { + public const int ParametersLength = 0; + + public TransactionInterimResponse() : base() + { + } + + public TransactionInterimResponse(byte[] buffer, int offset) : base(buffer, offset, false) + { + } + + public override byte[] GetBytes(bool isUnicode) + { + return base.GetBytes(isUnicode); + } + + public override CommandName CommandName + { + get + { + return CommandName.SMB_COM_TRANSACTION; + } + } + } +} diff --git a/SMBLibrary/SMBLibrary.csproj b/SMBLibrary/SMBLibrary.csproj index 611491e..aa39816 100644 --- a/SMBLibrary/SMBLibrary.csproj +++ b/SMBLibrary/SMBLibrary.csproj @@ -310,9 +310,11 @@ + + diff --git a/SMBLibrary/Server/SMB1/TransactionHelper.cs b/SMBLibrary/Server/SMB1/TransactionHelper.cs index 5951fcc..074b178 100644 --- a/SMBLibrary/Server/SMB1/TransactionHelper.cs +++ b/SMBLibrary/Server/SMB1/TransactionHelper.cs @@ -17,7 +17,6 @@ namespace SMBLibrary.Server.SMB1 public class TransactionHelper { /// - /// There are no interim response messages. /// The client MUST send as many secondary requests as are needed to complete the transfer of the transaction request. /// The server MUST respond to the transaction request as a whole. /// @@ -38,7 +37,14 @@ namespace SMBLibrary.Server.SMB1 ByteWriter.WriteBytes(processState.TransactionData, 0, request.TransData); processState.TransactionParametersReceived += request.TransParameters.Length; processState.TransactionDataReceived += request.TransData.Length; - return new List(); + if (request is Transaction2Request) + { + return new Transaction2InterimResponse(); + } + else + { + return new TransactionInterimResponse(); + } } else {