SMB1: SMB_COM_TRANSACTION / SMB_COM_TRANSACTION2: interim response will now be sent when required

This commit is contained in:
Tal Aloni 2017-02-19 21:37:49 +02:00
parent 4d51c7eed4
commit b3df4dd01c
5 changed files with 102 additions and 4 deletions

View file

@ -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:

View file

@ -0,0 +1,31 @@
/* 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
{
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;
}
}
}
}

View file

@ -0,0 +1,41 @@
/* 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>
/// SMB_COM_TRANSACTION Interim Response
/// </summary>
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;
}
}
}
}

View file

@ -310,9 +310,11 @@
<Compile Include="SMB1\Commands\SetInformationResponse.cs" />
<Compile Include="SMB1\Commands\SMB1Command.cs" />
<Compile Include="SMB1\Commands\SMBAndXCommand.cs" />
<Compile Include="SMB1\Commands\Transaction2InterimResponse.cs" />
<Compile Include="SMB1\Commands\Transaction2Request.cs" />
<Compile Include="SMB1\Commands\Transaction2Response.cs" />
<Compile Include="SMB1\Commands\Transaction2SecondaryRequest.cs" />
<Compile Include="SMB1\Commands\TransactionInterimResponse.cs" />
<Compile Include="SMB1\Commands\TransactionRequest.cs" />
<Compile Include="SMB1\Commands\TransactionResponse.cs" />
<Compile Include="SMB1\Commands\TransactionSecondaryRequest.cs" />

View file

@ -17,7 +17,6 @@ namespace SMBLibrary.Server.SMB1
public class TransactionHelper
{
/// <summary>
/// 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.
/// </summary>
@ -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<SMB1Command>();
if (request is Transaction2Request)
{
return new Transaction2InterimResponse();
}
else
{
return new TransactionInterimResponse();
}
}
else
{