From f2c8c22703fdb9ad205d903d8ac4407c9e91ada7 Mon Sep 17 00:00:00 2001 From: TalAloni Date: Tue, 13 Apr 2021 18:22:56 +0300 Subject: [PATCH 01/24] NTStatus: Added STATUS_WRONG_PASSWORD --- SMBLibrary/Enums/NTStatus.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/SMBLibrary/Enums/NTStatus.cs b/SMBLibrary/Enums/NTStatus.cs index f8eb2ac..fa4e8dd 100644 --- a/SMBLibrary/Enums/NTStatus.cs +++ b/SMBLibrary/Enums/NTStatus.cs @@ -37,6 +37,7 @@ namespace SMBLibrary STATUS_LOCK_NOT_GRANTED = 0xC0000055, STATUS_DELETE_PENDING = 0xC0000056, STATUS_PRIVILEGE_NOT_HELD = 0xC0000061, + STATUS_WRONG_PASSWORD = 0xC000006A, STATUS_LOGON_FAILURE = 0xC000006D, // Authentication failure. STATUS_ACCOUNT_RESTRICTION = 0xC000006E, // The user has an empty password, which is not allowed STATUS_INVALID_LOGON_HOURS = 0xC000006F, From 6f2b9fa3cae4226c6e7aedb848ad7a53b96fbfe4 Mon Sep 17 00:00:00 2001 From: TalAloni Date: Thu, 15 Apr 2021 21:12:38 +0300 Subject: [PATCH 02/24] SMB2Client: Correctly handle async responses --- SMBLibrary/Client/SMB2Client.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/SMBLibrary/Client/SMB2Client.cs b/SMBLibrary/Client/SMB2Client.cs index cdd1af8..d87bef4 100644 --- a/SMBLibrary/Client/SMB2Client.cs +++ b/SMBLibrary/Client/SMB2Client.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2017-2020 Tal Aloni . All rights reserved. +/* Copyright (C) 2017-2021 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, @@ -481,6 +481,11 @@ namespace SMBLibrary.Client if (command.CommandName == commandName) { m_incomingQueue.RemoveAt(index); + if (command.Header.IsAsync && command.Header.Status == NTStatus.STATUS_PENDING) + { + index--; + continue; + } return command; } } From 8aaf8641c1215e8e4ea540f832686ae2d02ba046 Mon Sep 17 00:00:00 2001 From: TalAloni Date: Fri, 16 Apr 2021 10:43:26 +0300 Subject: [PATCH 03/24] SMB2Command: Add MessageID property --- SMBLibrary/SMB2/Commands/SMB2Command.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/SMBLibrary/SMB2/Commands/SMB2Command.cs b/SMBLibrary/SMB2/Commands/SMB2Command.cs index 23b3796..0738cbf 100644 --- a/SMBLibrary/SMB2/Commands/SMB2Command.cs +++ b/SMBLibrary/SMB2/Commands/SMB2Command.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2017-2020 Tal Aloni . All rights reserved. +/* Copyright (C) 2017-2021 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, @@ -49,6 +49,14 @@ namespace SMBLibrary.SMB2 } } + public ulong MessageID + { + get + { + return Header.MessageID; + } + } + public int Length { get From e4f4f40ef193c1002a424760f1075bc7b2b8f40b Mon Sep 17 00:00:00 2001 From: TalAloni Date: Fri, 16 Apr 2021 10:48:04 +0300 Subject: [PATCH 04/24] SMB2Client: WaitForCommand: Compare MessageID instead of CommandName --- SMBLibrary/Client/SMB2Client.cs | 14 +++++++------- SMBLibrary/Client/SMB2FileStore.cs | 26 +++++++++++++------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/SMBLibrary/Client/SMB2Client.cs b/SMBLibrary/Client/SMB2Client.cs index d87bef4..20acbbc 100644 --- a/SMBLibrary/Client/SMB2Client.cs +++ b/SMBLibrary/Client/SMB2Client.cs @@ -167,7 +167,7 @@ namespace SMBLibrary.Client request.Dialects.Add(SMB2Dialect.SMB300); TrySendCommand(request); - NegotiateResponse response = WaitForCommand(SMB2CommandName.Negotiate) as NegotiateResponse; + NegotiateResponse response = WaitForCommand(request.MessageID) as NegotiateResponse; if (response != null && response.Header.Status == NTStatus.STATUS_SUCCESS) { m_dialect = response.DialectRevision; @@ -203,7 +203,7 @@ namespace SMBLibrary.Client request.SecurityMode = SecurityMode.SigningEnabled; request.SecurityBuffer = negotiateMessage; TrySendCommand(request); - SMB2Command response = WaitForCommand(SMB2CommandName.SessionSetup); + SMB2Command response = WaitForCommand(request.MessageID); if (response != null) { if (response.Header.Status == NTStatus.STATUS_MORE_PROCESSING_REQUIRED && response is SessionSetupResponse) @@ -219,7 +219,7 @@ namespace SMBLibrary.Client request.SecurityMode = SecurityMode.SigningEnabled; request.SecurityBuffer = authenticateMessage; TrySendCommand(request); - response = WaitForCommand(SMB2CommandName.SessionSetup); + response = WaitForCommand(request.MessageID); if (response != null) { m_isLoggedIn = (response.Header.Status == NTStatus.STATUS_SUCCESS); @@ -254,7 +254,7 @@ namespace SMBLibrary.Client LogoffRequest request = new LogoffRequest(); TrySendCommand(request); - SMB2Command response = WaitForCommand(SMB2CommandName.Logoff); + SMB2Command response = WaitForCommand(request.MessageID); if (response != null) { m_isLoggedIn = (response.Header.Status != NTStatus.STATUS_SUCCESS); @@ -293,7 +293,7 @@ namespace SMBLibrary.Client TreeConnectRequest request = new TreeConnectRequest(); request.Path = sharePath; TrySendCommand(request); - SMB2Command response = WaitForCommand(SMB2CommandName.TreeConnect); + SMB2Command response = WaitForCommand(request.MessageID); if (response != null) { status = response.Header.Status; @@ -465,7 +465,7 @@ namespace SMBLibrary.Client } } - internal SMB2Command WaitForCommand(SMB2CommandName commandName) + internal SMB2Command WaitForCommand(ulong messageID) { const int TimeOut = 5000; Stopwatch stopwatch = new Stopwatch(); @@ -478,7 +478,7 @@ namespace SMBLibrary.Client { SMB2Command command = m_incomingQueue[index]; - if (command.CommandName == commandName) + if (command.Header.MessageID == messageID) { m_incomingQueue.RemoveAt(index); if (command.Header.IsAsync && command.Header.Status == NTStatus.STATUS_PENDING) diff --git a/SMBLibrary/Client/SMB2FileStore.cs b/SMBLibrary/Client/SMB2FileStore.cs index 551958c..c581f4f 100644 --- a/SMBLibrary/Client/SMB2FileStore.cs +++ b/SMBLibrary/Client/SMB2FileStore.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2017-2020 Tal Aloni . All rights reserved. +/* Copyright (C) 2017-2021 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, @@ -40,7 +40,7 @@ namespace SMBLibrary.Client request.ImpersonationLevel = ImpersonationLevel.Impersonation; TrySendCommand(request); - SMB2Command response = m_client.WaitForCommand(SMB2CommandName.Create); + SMB2Command response = m_client.WaitForCommand(request.MessageID); if (response != null) { if (response.Header.Status == NTStatus.STATUS_SUCCESS && response is CreateResponse) @@ -60,7 +60,7 @@ namespace SMBLibrary.Client CloseRequest request = new CloseRequest(); request.FileId = (FileID)handle; TrySendCommand(request); - SMB2Command response = m_client.WaitForCommand(SMB2CommandName.Close); + SMB2Command response = m_client.WaitForCommand(request.MessageID); if (response != null) { return response.Header.Status; @@ -79,7 +79,7 @@ namespace SMBLibrary.Client request.ReadLength = (uint)maxCount; TrySendCommand(request); - SMB2Command response = m_client.WaitForCommand(SMB2CommandName.Read); + SMB2Command response = m_client.WaitForCommand(request.MessageID); if (response != null) { if (response.Header.Status == NTStatus.STATUS_SUCCESS && response is ReadResponse) @@ -102,7 +102,7 @@ namespace SMBLibrary.Client request.Data = data; TrySendCommand(request); - SMB2Command response = m_client.WaitForCommand(SMB2CommandName.Write); + SMB2Command response = m_client.WaitForCommand(request.MessageID); if (response != null) { if (response.Header.Status == NTStatus.STATUS_SUCCESS && response is WriteResponse) @@ -142,7 +142,7 @@ namespace SMBLibrary.Client request.FileName = fileName; TrySendCommand(request); - SMB2Command response = m_client.WaitForCommand(SMB2CommandName.QueryDirectory); + SMB2Command response = m_client.WaitForCommand(request.MessageID); if (response != null) { while (response.Header.Status == NTStatus.STATUS_SUCCESS && response is QueryDirectoryResponse) @@ -151,7 +151,7 @@ namespace SMBLibrary.Client result.AddRange(page); request.Reopen = false; TrySendCommand(request); - response = m_client.WaitForCommand(SMB2CommandName.QueryDirectory); + response = m_client.WaitForCommand(request.MessageID); } return response.Header.Status; } @@ -169,7 +169,7 @@ namespace SMBLibrary.Client request.FileId = (FileID)handle; TrySendCommand(request); - SMB2Command response = m_client.WaitForCommand(SMB2CommandName.QueryInfo); + SMB2Command response = m_client.WaitForCommand(request.MessageID); if (response != null) { if (response.Header.Status == NTStatus.STATUS_SUCCESS && response is QueryInfoResponse) @@ -191,7 +191,7 @@ namespace SMBLibrary.Client request.SetFileInformation(information); TrySendCommand(request); - SMB2Command response = m_client.WaitForCommand(SMB2CommandName.SetInfo); + SMB2Command response = m_client.WaitForCommand(request.MessageID); if (response != null) { return response.Header.Status; @@ -226,7 +226,7 @@ namespace SMBLibrary.Client request.FileId = (FileID)handle; TrySendCommand(request); - SMB2Command response = m_client.WaitForCommand(SMB2CommandName.QueryInfo); + SMB2Command response = m_client.WaitForCommand(request.MessageID); if (response != null) { if (response.Header.Status == NTStatus.STATUS_SUCCESS && response is QueryInfoResponse) @@ -254,7 +254,7 @@ namespace SMBLibrary.Client request.FileId = (FileID)handle; TrySendCommand(request); - SMB2Command response = m_client.WaitForCommand(SMB2CommandName.QueryInfo); + SMB2Command response = m_client.WaitForCommand(request.MessageID); if (response != null) { if (response.Header.Status == NTStatus.STATUS_SUCCESS && response is QueryInfoResponse) @@ -293,7 +293,7 @@ namespace SMBLibrary.Client request.Input = input; request.MaxOutputResponse = (uint)maxOutputLength; TrySendCommand(request); - SMB2Command response = m_client.WaitForCommand(SMB2CommandName.IOCtl); + SMB2Command response = m_client.WaitForCommand(request.MessageID); if (response != null) { if ((response.Header.Status == NTStatus.STATUS_SUCCESS || response.Header.Status == NTStatus.STATUS_BUFFER_OVERFLOW) && response is IOCtlResponse) @@ -310,7 +310,7 @@ namespace SMBLibrary.Client { TreeDisconnectRequest request = new TreeDisconnectRequest(); TrySendCommand(request); - SMB2Command response = m_client.WaitForCommand(SMB2CommandName.TreeDisconnect); + SMB2Command response = m_client.WaitForCommand(request.MessageID); if (response != null) { return response.Header.Status; From 4a184258e691d65331a91e63b946f17ad70e6acb Mon Sep 17 00:00:00 2001 From: TalAloni Date: Fri, 16 Apr 2021 10:50:22 +0300 Subject: [PATCH 05/24] SMBLibrary: Increment version to 1.4.6.1 --- SMBLibrary/Properties/AssemblyInfo.cs | 4 ++-- SMBLibrary/SMBLibrary.csproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SMBLibrary/Properties/AssemblyInfo.cs b/SMBLibrary/Properties/AssemblyInfo.cs index 76ba17f..0ba6467 100644 --- a/SMBLibrary/Properties/AssemblyInfo.cs +++ b/SMBLibrary/Properties/AssemblyInfo.cs @@ -31,6 +31,6 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.4.6.0")] -[assembly: AssemblyFileVersion("1.4.6.0")] +[assembly: AssemblyVersion("1.4.6.1")] +[assembly: AssemblyFileVersion("1.4.6.1")] [assembly: InternalsVisibleTo("SMBLibrary.Tests")] \ No newline at end of file diff --git a/SMBLibrary/SMBLibrary.csproj b/SMBLibrary/SMBLibrary.csproj index 8ee3b30..15334ef 100644 --- a/SMBLibrary/SMBLibrary.csproj +++ b/SMBLibrary/SMBLibrary.csproj @@ -4,7 +4,7 @@ net20;net40;netstandard2.0 false SMBLibrary - 1.4.6 + 1.4.6.1 1573;1591 SMBLibrary false From aba8b8a50782ff310a1367c784fadcba0b9f78ad Mon Sep 17 00:00:00 2001 From: Liviu Seniuc Date: Thu, 10 Jun 2021 18:21:57 +0300 Subject: [PATCH 06/24] Update NTStatus.cs Acording to https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55 STATUS_PASSWORD_MUST_CHANGE = 0xC0000224 STATUS_AUDIT_FAILED = 0xC0000244 --- SMBLibrary/Enums/NTStatus.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SMBLibrary/Enums/NTStatus.cs b/SMBLibrary/Enums/NTStatus.cs index fa4e8dd..98ffc8f 100644 --- a/SMBLibrary/Enums/NTStatus.cs +++ b/SMBLibrary/Enums/NTStatus.cs @@ -67,7 +67,7 @@ namespace SMBLibrary STATUS_INSUFF_SERVER_RESOURCES = 0xC0000205, STATUS_NOT_FOUND = 0xC0000225, STATUS_ACCOUNT_LOCKED_OUT = 0xC0000234, - STATUS_PASSWORD_MUST_CHANGE = 0xC0000244, + STATUS_PASSWORD_MUST_CHANGE = 0xC0000224, STATUS_NOT_A_REPARSE_POINT = 0xC0000275, STATUS_INVALID_SMB = 0x00010002, // SMB1/CIFS: A corrupt or invalid SMB request was received From a0bb742dc2cd2db420095721112ef28dd2d3b05d Mon Sep 17 00:00:00 2001 From: Nich Overend Date: Thu, 22 Jul 2021 16:43:00 +0100 Subject: [PATCH 07/24] Implement Flush for SMB2 (#93) Co-authored-by: Nich Overend --- SMBLibrary/Client/SMB2FileStore.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/SMBLibrary/Client/SMB2FileStore.cs b/SMBLibrary/Client/SMB2FileStore.cs index c581f4f..64607d7 100644 --- a/SMBLibrary/Client/SMB2FileStore.cs +++ b/SMBLibrary/Client/SMB2FileStore.cs @@ -117,7 +117,20 @@ namespace SMBLibrary.Client public NTStatus FlushFileBuffers(object handle) { - throw new NotImplementedException(); + FlushRequest request = new FlushRequest(); + request.FileId = (FileID) handle; + + TrySendCommand(request); + SMB2Command response = m_client.WaitForCommand(request.MessageID); + if (response != null) + { + if (response.Header.Status == NTStatus.STATUS_SUCCESS && response is FlushResponse) + { + return response.Header.Status; + } + } + + return NTStatus.STATUS_INVALID_SMB; } public NTStatus LockFile(object handle, long byteOffset, long length, bool exclusiveLock) From 11432727867c051fac788c3f2b1961aa622fa822 Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Fri, 20 Aug 2021 13:57:35 +0300 Subject: [PATCH 08/24] Client: Added support for accessing Cluster Shared Volumes file shares --- .../Client/Helpers/ServerServiceHelper.cs | 13 +++++++-- SMBLibrary/Client/ISMBClient.cs | 4 ++- SMBLibrary/Client/SMB1Client.cs | 13 ++++++++- SMBLibrary/Client/SMB2Client.cs | 29 ++++++++++++++++--- 4 files changed, 51 insertions(+), 8 deletions(-) diff --git a/SMBLibrary/Client/Helpers/ServerServiceHelper.cs b/SMBLibrary/Client/Helpers/ServerServiceHelper.cs index 6d3c21d..fdc0921 100644 --- a/SMBLibrary/Client/Helpers/ServerServiceHelper.cs +++ b/SMBLibrary/Client/Helpers/ServerServiceHelper.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2020 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2021 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, @@ -15,6 +15,15 @@ namespace SMBLibrary.Client public class ServerServiceHelper { public static List ListShares(INTFileStore namedPipeShare, ShareType? shareType, out NTStatus status) + { + return ListShares(namedPipeShare, "*", shareType, out status); + } + + /// + /// When a Windows Server host is using Failover Cluster & Cluster Shared Volumes, each of those CSV file shares is associated + /// with a specific host name associated with the cluster and is not accessible using the node IP address or node host name. + /// + public static List ListShares(INTFileStore namedPipeShare, string serverName, ShareType? shareType, out NTStatus status) { object pipeHandle; int maxTransmitFragmentSize; @@ -29,7 +38,7 @@ namespace SMBLibrary.Client shareEnumRequest.InfoStruct.Level = 1; shareEnumRequest.InfoStruct.Info = new ShareInfo1Container(); shareEnumRequest.PreferedMaximumLength = UInt32.MaxValue; - shareEnumRequest.ServerName = "*"; + shareEnumRequest.ServerName = serverName; RequestPDU requestPDU = new RequestPDU(); requestPDU.Flags = PacketFlags.FirstFragment | PacketFlags.LastFragment; requestPDU.DataRepresentation.CharacterFormat = CharacterFormat.ASCII; diff --git a/SMBLibrary/Client/ISMBClient.cs b/SMBLibrary/Client/ISMBClient.cs index ee59bbe..7ff3c85 100644 --- a/SMBLibrary/Client/ISMBClient.cs +++ b/SMBLibrary/Client/ISMBClient.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Tal Aloni . All rights reserved. +/* Copyright (C) 2017-2021 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, @@ -12,6 +12,8 @@ namespace SMBLibrary.Client { public interface ISMBClient { + bool Connect(string serverName, SMBTransportType transport); + bool Connect(IPAddress serverAddress, SMBTransportType transport); void Disconnect(); diff --git a/SMBLibrary/Client/SMB1Client.cs b/SMBLibrary/Client/SMB1Client.cs index 7a2d993..1a50cd3 100644 --- a/SMBLibrary/Client/SMB1Client.cs +++ b/SMBLibrary/Client/SMB1Client.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2020 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2021 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, @@ -57,6 +57,17 @@ namespace SMBLibrary.Client { } + public bool Connect(string serverName, SMBTransportType transport) + { + IPHostEntry hostEntry = Dns.GetHostEntry(serverName); + if (hostEntry.AddressList.Length == 0) + { + throw new Exception(String.Format("Cannot resolve host name {0} to an IP address", serverName)); + } + IPAddress serverAddress = hostEntry.AddressList[0]; + return Connect(serverAddress, transport); + } + public bool Connect(IPAddress serverAddress, SMBTransportType transport) { return Connect(serverAddress, transport, true); diff --git a/SMBLibrary/Client/SMB2Client.cs b/SMBLibrary/Client/SMB2Client.cs index 20acbbc..8fa8724 100644 --- a/SMBLibrary/Client/SMB2Client.cs +++ b/SMBLibrary/Client/SMB2Client.cs @@ -27,8 +27,9 @@ namespace SMBLibrary.Client public static readonly uint ClientMaxTransactSize = 1048576; public static readonly uint ClientMaxReadSize = 1048576; public static readonly uint ClientMaxWriteSize = 1048576; - private static readonly ushort DesiredCredits = 16; + private static readonly ushort DesiredCredits = 16; + private string m_serverName; private SMBTransportType m_transport; private bool m_isConnected; private bool m_isLoggedIn; @@ -60,8 +61,29 @@ namespace SMBLibrary.Client { } + /// + /// When a Windows Server host is using Failover Cluster & Cluster Shared Volumes, each of those CSV file shares is associated + /// with a specific host name associated with the cluster and is not accessible using the node IP address or node host name. + /// + public bool Connect(string serverName, SMBTransportType transport) + { + m_serverName = serverName; + IPHostEntry hostEntry = Dns.GetHostEntry(serverName); + if (hostEntry.AddressList.Length == 0) + { + throw new Exception(String.Format("Cannot resolve host name {0} to an IP address", serverName)); + } + IPAddress serverAddress = hostEntry.AddressList[0]; + return Connect(serverAddress, transport); + } + public bool Connect(IPAddress serverAddress, SMBTransportType transport) { + if (m_serverName == null) + { + m_serverName = serverAddress.ToString(); + } + m_transport = transport; if (!m_isConnected) { @@ -276,7 +298,7 @@ namespace SMBLibrary.Client return null; } - List shares = ServerServiceHelper.ListShares(namedPipeShare, SMBLibrary.Services.ShareType.DiskDrive, out status); + List shares = ServerServiceHelper.ListShares(namedPipeShare, m_serverName, SMBLibrary.Services.ShareType.DiskDrive, out status); namedPipeShare.Disconnect(); return shares; } @@ -288,8 +310,7 @@ namespace SMBLibrary.Client throw new InvalidOperationException("A login session must be successfully established before connecting to a share"); } - IPAddress serverIPAddress = ((IPEndPoint)m_clientSocket.RemoteEndPoint).Address; - string sharePath = String.Format(@"\\{0}\{1}", serverIPAddress.ToString(), shareName); + string sharePath = String.Format(@"\\{0}\{1}", m_serverName, shareName); TreeConnectRequest request = new TreeConnectRequest(); request.Path = sharePath; TrySendCommand(request); From 1c2bee2b2147aac8641e31a23f2284d8d2147a90 Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Fri, 20 Aug 2021 14:07:50 +0300 Subject: [PATCH 09/24] SMBLibrary: Increment version to 1.4.6.2 --- SMBLibrary/Properties/AssemblyInfo.cs | 4 ++-- SMBLibrary/SMBLibrary.csproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SMBLibrary/Properties/AssemblyInfo.cs b/SMBLibrary/Properties/AssemblyInfo.cs index 0ba6467..91f1f85 100644 --- a/SMBLibrary/Properties/AssemblyInfo.cs +++ b/SMBLibrary/Properties/AssemblyInfo.cs @@ -31,6 +31,6 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.4.6.1")] -[assembly: AssemblyFileVersion("1.4.6.1")] +[assembly: AssemblyVersion("1.4.6.2")] +[assembly: AssemblyFileVersion("1.4.6.2")] [assembly: InternalsVisibleTo("SMBLibrary.Tests")] \ No newline at end of file diff --git a/SMBLibrary/SMBLibrary.csproj b/SMBLibrary/SMBLibrary.csproj index 15334ef..dfda563 100644 --- a/SMBLibrary/SMBLibrary.csproj +++ b/SMBLibrary/SMBLibrary.csproj @@ -4,7 +4,7 @@ net20;net40;netstandard2.0 false SMBLibrary - 1.4.6.1 + 1.4.6.2 1573;1591 SMBLibrary false From b7f93b06b074eab8ef18288a357d66a2a2781bdc Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Sat, 21 Aug 2021 10:36:06 +0300 Subject: [PATCH 10/24] Updated ClientExamples.md --- ClientExamples.md | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/ClientExamples.md b/ClientExamples.md index d96e87c..67dc699 100644 --- a/ClientExamples.md +++ b/ClientExamples.md @@ -11,6 +11,7 @@ if (isConnected) List shares = client.ListShares(out status); client.Logoff(); } + client.Disconnect(); } ``` @@ -93,7 +94,7 @@ status = fileStore.Disconnect(); Create a file and write to it: ============================== ``` -ISMBFileStore fileStore = client.TreeConnect("Shared", out status); +ISMBFileStore fileStore = client.TreeConnect("Shared", out status); string filePath = "NewFile.txt"; if (fileStore is SMB1FileStore) { @@ -116,10 +117,52 @@ if (status == NTStatus.STATUS_SUCCESS) status = fileStore.Disconnect(); ``` +Write a large file: +=================== +``` +ISMBFileStore fileStore = client.TreeConnect("Shared", out status); +if (status != NTStatus.STATUS_SUCCESS) +{ + throw new Exception("Failed to connect to share"); +} +string localFilePath = @"C:\Image.jpg"; +string remoteFilePath = "NewFile.jpg"; +if (fileStore is SMB1FileStore) +{ + remoteFilePath = @"\\" + remoteFilePath; +} +FileStream localFileStream = new FileStream(localFilePath, FileMode.Open, FileAccess.Read); +object fileHandle; +FileStatus fileStatus; +status = fileStore.CreateFile(out fileHandle, out fileStatus, remoteFilePath, AccessMask.GENERIC_WRITE | AccessMask.SYNCHRONIZE, FileAttributes.Normal, ShareAccess.None, CreateDisposition.FILE_CREATE, CreateOptions.FILE_NON_DIRECTORY_FILE | CreateOptions.FILE_SYNCHRONOUS_IO_ALERT, null); +if (status == NTStatus.STATUS_SUCCESS) +{ + int writeOffset = 0; + while (localFileStream.Position < localFileStream.Length) + { + byte[] buffer = new byte[(int)client.MaxWriteSize]; + int bytesRead = localFileStream.Read(buffer, 0, buffer.Length); + if (bytesRead < (int)client.MaxWriteSize) + { + Array.Resize(ref buffer, bytesRead); + } + int numberOfBytesWritten; + status = fileStore.WriteFile(out numberOfBytesWritten, fileHandle, writeOffset, buffer); + if (status != NTStatus.STATUS_SUCCESS) + { + throw new Exception("Failed to write to file"); + } + writeOffset += bytesRead; + } + status = fileStore.CloseFile(fileHandle); +} +status = fileStore.Disconnect(); +``` + Delete file: ============ ``` -ISMBFileStore fileStore = client.TreeConnect("Shared", out status); +ISMBFileStore fileStore = client.TreeConnect("Shared", out status); string filePath = "DeleteMe.txt"; if (fileStore is SMB1FileStore) { From 193ab13777b9dab47f313bd6d91602d4e65e401e Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Fri, 10 Sep 2021 20:53:14 +0300 Subject: [PATCH 11/24] FileInformation.GetFileInformation: Improved exception message --- .../NTFileStore/Structures/FileInformation/FileInformation.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SMBLibrary/NTFileStore/Structures/FileInformation/FileInformation.cs b/SMBLibrary/NTFileStore/Structures/FileInformation/FileInformation.cs index b841527..b0b3843 100644 --- a/SMBLibrary/NTFileStore/Structures/FileInformation/FileInformation.cs +++ b/SMBLibrary/NTFileStore/Structures/FileInformation/FileInformation.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Tal Aloni . All rights reserved. +/* Copyright (C) 2017-2021 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, @@ -88,7 +88,7 @@ namespace SMBLibrary case FileInformationClass.FileShortNameInformation: throw new NotImplementedException(); default: - throw new UnsupportedInformationLevelException(); + throw new UnsupportedInformationLevelException(String.Format("Unsupported information class: {0}", informationClass)); } } } From 4ffd9ef128f4c61ad00e47d2034b3bfd4d444d74 Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Tue, 19 Oct 2021 20:29:25 +0300 Subject: [PATCH 12/24] SMB2Client: Removed unused using statements --- SMBLibrary/Client/SMB2Client.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/SMBLibrary/Client/SMB2Client.cs b/SMBLibrary/Client/SMB2Client.cs index 8fa8724..0ce030f 100644 --- a/SMBLibrary/Client/SMB2Client.cs +++ b/SMBLibrary/Client/SMB2Client.cs @@ -9,11 +9,8 @@ using System.Collections.Generic; using System.Diagnostics; using System.Net; using System.Net.Sockets; -using System.Security.Cryptography; using System.Threading; -using SMBLibrary.Authentication.NTLM; using SMBLibrary.NetBios; -using SMBLibrary.Services; using SMBLibrary.SMB2; using Utilities; From 557936fbabad2501570e229b81d8ae6edf10b80a Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Tue, 19 Oct 2021 20:30:38 +0300 Subject: [PATCH 13/24] Client: Use static readonly ResponseTimeoutInMilliseconds instead of cost --- SMBLibrary/Client/SMB1Client.cs | 4 ++-- SMBLibrary/Client/SMB2Client.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SMBLibrary/Client/SMB1Client.cs b/SMBLibrary/Client/SMB1Client.cs index 1a50cd3..c3328fa 100644 --- a/SMBLibrary/Client/SMB1Client.cs +++ b/SMBLibrary/Client/SMB1Client.cs @@ -27,6 +27,7 @@ namespace SMBLibrary.Client private static readonly ushort ClientMaxBufferSize = 65535; // Valid range: 512 - 65535 private static readonly ushort ClientMaxMpxCount = 1; + private static readonly int ResponseTimeoutInMilliseconds = 5000; private SMBTransportType m_transport; private bool m_isConnected; @@ -536,10 +537,9 @@ namespace SMBLibrary.Client internal SMB1Message WaitForMessage(CommandName commandName) { - const int TimeOut = 5000; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); - while (stopwatch.ElapsedMilliseconds < TimeOut) + while (stopwatch.ElapsedMilliseconds < ResponseTimeoutInMilliseconds) { lock (m_incomingQueueLock) { diff --git a/SMBLibrary/Client/SMB2Client.cs b/SMBLibrary/Client/SMB2Client.cs index 0ce030f..f8c7dea 100644 --- a/SMBLibrary/Client/SMB2Client.cs +++ b/SMBLibrary/Client/SMB2Client.cs @@ -25,6 +25,7 @@ namespace SMBLibrary.Client public static readonly uint ClientMaxReadSize = 1048576; public static readonly uint ClientMaxWriteSize = 1048576; private static readonly ushort DesiredCredits = 16; + public static readonly int ResponseTimeoutInMilliseconds = 5000; private string m_serverName; private SMBTransportType m_transport; @@ -485,10 +486,9 @@ namespace SMBLibrary.Client internal SMB2Command WaitForCommand(ulong messageID) { - const int TimeOut = 5000; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); - while (stopwatch.ElapsedMilliseconds < TimeOut) + while (stopwatch.ElapsedMilliseconds < ResponseTimeoutInMilliseconds) { lock (m_incomingQueueLock) { From 083128889a9a0631eb1c257790b447aebfb0e1a9 Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Fri, 19 Nov 2021 12:43:09 +0200 Subject: [PATCH 14/24] Correct parameter name in documentation --- SMBLibrary/NetBios/NetBiosUtils.cs | 4 ++-- SMBLibrary/SMB2/Commands/SMB2Command.cs | 2 +- SMBLibrary/Server/Shares/SMBShareCollection.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SMBLibrary/NetBios/NetBiosUtils.cs b/SMBLibrary/NetBios/NetBiosUtils.cs index 67fb9b1..1661222 100644 --- a/SMBLibrary/NetBios/NetBiosUtils.cs +++ b/SMBLibrary/NetBios/NetBiosUtils.cs @@ -60,7 +60,7 @@ namespace SMBLibrary.NetBios return EncodeName(netBiosName, scopeID); } - /// NetBIOS name + /// NetBIOS name /// dot-separated labels, formatted per DNS naming rules public static byte[] EncodeName(string netBiosName, string scopeID) { @@ -75,7 +75,7 @@ namespace SMBLibrary.NetBios // into two nibbles and then adding the value of 'A' (0x41). // Thus, the '&' character (0x26) would be encoded as "CG". // NetBIOS names are usually padded with spaces before being encoded. - /// NetBIOS name + /// NetBIOS name /// dot-separated labels, formatted per DNS naming rules public static string FirstLevelEncoding(string netBiosName, string scopeID) { diff --git a/SMBLibrary/SMB2/Commands/SMB2Command.cs b/SMBLibrary/SMB2/Commands/SMB2Command.cs index 0738cbf..479aa36 100644 --- a/SMBLibrary/SMB2/Commands/SMB2Command.cs +++ b/SMBLibrary/SMB2/Commands/SMB2Command.cs @@ -135,7 +135,7 @@ namespace SMBLibrary.SMB2 return GetCommandChainBytes(commands, null, SMB2Dialect.SMB2xx); } - /// + /// /// Message will be signed using this key if (not null and) SMB2_FLAGS_SIGNED is set. /// /// diff --git a/SMBLibrary/Server/Shares/SMBShareCollection.cs b/SMBLibrary/Server/Shares/SMBShareCollection.cs index 4cd61a1..0321674 100644 --- a/SMBLibrary/Server/Shares/SMBShareCollection.cs +++ b/SMBLibrary/Server/Shares/SMBShareCollection.cs @@ -39,7 +39,7 @@ namespace SMBLibrary.Server return result; } - /// e.g. \Shared + /// e.g. \Shared public FileSystemShare GetShareFromName(string shareName) { int index = IndexOf(shareName, StringComparison.OrdinalIgnoreCase); From 027b4652fadb72b6b5128490ae2c373eb4b336ce Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Fri, 19 Nov 2021 12:44:14 +0200 Subject: [PATCH 15/24] Documentation syntax corrections --- SMBLibrary/Helpers/SP800_1008.cs | 2 +- .../Transaction2QueryFileInformationResponse.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SMBLibrary/Helpers/SP800_1008.cs b/SMBLibrary/Helpers/SP800_1008.cs index 0ac7684..1c78512 100644 --- a/SMBLibrary/Helpers/SP800_1008.cs +++ b/SMBLibrary/Helpers/SP800_1008.cs @@ -1,4 +1,4 @@ -/// Adapted from https://referencesource.microsoft.com/#system.web/Security/Cryptography/SP800_108.cs +// Adapted from https://referencesource.microsoft.com/#system.web/Security/Cryptography/SP800_108.cs using System; using System.Security.Cryptography; using Utilities; diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Transaction2QueryFileInformationResponse.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Transaction2QueryFileInformationResponse.cs index 75b156b..bc750c1 100644 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Transaction2QueryFileInformationResponse.cs +++ b/SMBLibrary/SMB1/Transaction2Subcommands/Transaction2QueryFileInformationResponse.cs @@ -12,7 +12,7 @@ namespace SMBLibrary.SMB1 { /// /// TRANS2_QUERY_FILE_INFORMATION Response - /// public class Transaction2QueryFileInformationResponse : Transaction2Subcommand { public const int ParametersLength = 2; From 02c4ab2e22e9f4acdf79cddab7a8899d6d588e2d Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Fri, 19 Nov 2021 12:46:43 +0200 Subject: [PATCH 16/24] Documentation XML syntax corrections --- SMBLibrary/Client/Helpers/ServerServiceHelper.cs | 2 +- SMBLibrary/Client/SMB2Client.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SMBLibrary/Client/Helpers/ServerServiceHelper.cs b/SMBLibrary/Client/Helpers/ServerServiceHelper.cs index fdc0921..f37e12f 100644 --- a/SMBLibrary/Client/Helpers/ServerServiceHelper.cs +++ b/SMBLibrary/Client/Helpers/ServerServiceHelper.cs @@ -20,7 +20,7 @@ namespace SMBLibrary.Client } /// - /// When a Windows Server host is using Failover Cluster & Cluster Shared Volumes, each of those CSV file shares is associated + /// When a Windows Server host is using Failover Cluster and Cluster Shared Volumes, each of those CSV file shares is associated /// with a specific host name associated with the cluster and is not accessible using the node IP address or node host name. /// public static List ListShares(INTFileStore namedPipeShare, string serverName, ShareType? shareType, out NTStatus status) diff --git a/SMBLibrary/Client/SMB2Client.cs b/SMBLibrary/Client/SMB2Client.cs index f8c7dea..b8fd19a 100644 --- a/SMBLibrary/Client/SMB2Client.cs +++ b/SMBLibrary/Client/SMB2Client.cs @@ -60,7 +60,7 @@ namespace SMBLibrary.Client } /// - /// When a Windows Server host is using Failover Cluster & Cluster Shared Volumes, each of those CSV file shares is associated + /// When a Windows Server host is using Failover Cluster and Cluster Shared Volumes, each of those CSV file shares is associated /// with a specific host name associated with the cluster and is not accessible using the node IP address or node host name. /// public bool Connect(string serverName, SMBTransportType transport) From db007d09e5bc7591a0e49a0c42b93adfbbb52d93 Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Fri, 10 Dec 2021 09:15:58 +0200 Subject: [PATCH 17/24] SMBServer: Added private Start overload allowing to specify the listening port --- SMBLibrary/Server/SMBServer.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/SMBLibrary/Server/SMBServer.cs b/SMBLibrary/Server/SMBServer.cs index c85a266..9e87ff8 100644 --- a/SMBLibrary/Server/SMBServer.cs +++ b/SMBLibrary/Server/SMBServer.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2020 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2021 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, @@ -77,6 +77,12 @@ namespace SMBLibrary.Server /// /// public void Start(IPAddress serverAddress, SMBTransportType transport, bool enableSMB1, bool enableSMB2, bool enableSMB3, TimeSpan? connectionInactivityTimeout) + { + int port = (m_transport == SMBTransportType.DirectTCPTransport ? DirectTCPPort : NetBiosOverTCPPort); + Start(serverAddress, transport, port, enableSMB1, enableSMB2, enableSMB3, connectionInactivityTimeout); + } + + private void Start(IPAddress serverAddress, SMBTransportType transport, int port, bool enableSMB1, bool enableSMB2, bool enableSMB3, TimeSpan? connectionInactivityTimeout) { if (!m_listening) { @@ -95,7 +101,6 @@ namespace SMBLibrary.Server m_serverStartTime = DateTime.Now; m_listenerSocket = new Socket(m_serverAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp); - int port = (m_transport == SMBTransportType.DirectTCPTransport ? DirectTCPPort : NetBiosOverTCPPort); m_listenerSocket.Bind(new IPEndPoint(m_serverAddress, port)); m_listenerSocket.Listen((int)SocketOptionName.MaxConnections); m_listenerSocket.BeginAccept(ConnectRequestCallback, m_listenerSocket); From 0ae5986759bad13fa06bdbcd362ee58318cf6839 Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Fri, 10 Dec 2021 09:17:58 +0200 Subject: [PATCH 18/24] Client: Added private Connect overload allowing to specify the server port --- SMBLibrary/Client/SMB1Client.cs | 16 ++++++---------- SMBLibrary/Client/SMB2Client.cs | 16 ++++++---------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/SMBLibrary/Client/SMB1Client.cs b/SMBLibrary/Client/SMB1Client.cs index c3328fa..7eb1efa 100644 --- a/SMBLibrary/Client/SMB1Client.cs +++ b/SMBLibrary/Client/SMB1Client.cs @@ -75,21 +75,17 @@ namespace SMBLibrary.Client } public bool Connect(IPAddress serverAddress, SMBTransportType transport, bool forceExtendedSecurity) + { + int port = (transport == SMBTransportType.DirectTCPTransport ? DirectTCPPort : NetBiosOverTCPPort); + return Connect(serverAddress, transport, port, forceExtendedSecurity); + } + + private bool Connect(IPAddress serverAddress, SMBTransportType transport, int port, bool forceExtendedSecurity) { m_transport = transport; if (!m_isConnected) { m_forceExtendedSecurity = forceExtendedSecurity; - int port; - if (transport == SMBTransportType.NetBiosOverTCP) - { - port = NetBiosOverTCPPort; - } - else - { - port = DirectTCPPort; - } - if (!ConnectSocket(serverAddress, port)) { return false; diff --git a/SMBLibrary/Client/SMB2Client.cs b/SMBLibrary/Client/SMB2Client.cs index b8fd19a..b64f42b 100644 --- a/SMBLibrary/Client/SMB2Client.cs +++ b/SMBLibrary/Client/SMB2Client.cs @@ -76,6 +76,12 @@ namespace SMBLibrary.Client } public bool Connect(IPAddress serverAddress, SMBTransportType transport) + { + int port = (transport == SMBTransportType.DirectTCPTransport ? DirectTCPPort : NetBiosOverTCPPort); + return Connect(serverAddress, transport, port); + } + + private bool Connect(IPAddress serverAddress, SMBTransportType transport, int port) { if (m_serverName == null) { @@ -85,16 +91,6 @@ namespace SMBLibrary.Client m_transport = transport; if (!m_isConnected) { - int port; - if (transport == SMBTransportType.NetBiosOverTCP) - { - port = NetBiosOverTCPPort; - } - else - { - port = DirectTCPPort; - } - if (!ConnectSocket(serverAddress, port)) { return false; From 849b99ad837f23ee8199f4d443c51c479819275e Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Fri, 10 Dec 2021 10:21:50 +0200 Subject: [PATCH 19/24] Client: Correct NetrShareEnum ServerName syntax --- SMBLibrary/Client/Helpers/ServerServiceHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SMBLibrary/Client/Helpers/ServerServiceHelper.cs b/SMBLibrary/Client/Helpers/ServerServiceHelper.cs index f37e12f..39d0645 100644 --- a/SMBLibrary/Client/Helpers/ServerServiceHelper.cs +++ b/SMBLibrary/Client/Helpers/ServerServiceHelper.cs @@ -38,7 +38,7 @@ namespace SMBLibrary.Client shareEnumRequest.InfoStruct.Level = 1; shareEnumRequest.InfoStruct.Info = new ShareInfo1Container(); shareEnumRequest.PreferedMaximumLength = UInt32.MaxValue; - shareEnumRequest.ServerName = serverName; + shareEnumRequest.ServerName = @"\\" + serverName; RequestPDU requestPDU = new RequestPDU(); requestPDU.Flags = PacketFlags.FirstFragment | PacketFlags.LastFragment; requestPDU.DataRepresentation.CharacterFormat = CharacterFormat.ASCII; From 3c47285484b915dfd9da4d7d4d0cfaa64f5441f6 Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Fri, 10 Dec 2021 10:37:02 +0200 Subject: [PATCH 20/24] SMBServer 1.4.7 --- SMBLibrary.Adapters/Properties/AssemblyInfo.cs | 4 ++-- SMBLibrary.Adapters/SMBLibrary.Adapters.csproj | 2 +- SMBLibrary.Win32/Properties/AssemblyInfo.cs | 4 ++-- SMBLibrary.Win32/SMBLibrary.Win32.csproj | 2 +- SMBLibrary/Properties/AssemblyInfo.cs | 4 ++-- SMBLibrary/RevisionHistory.txt | 10 ++++++++++ SMBLibrary/SMBLibrary.csproj | 2 +- SMBServer/Properties/AssemblyInfo.cs | 4 ++-- 8 files changed, 21 insertions(+), 11 deletions(-) diff --git a/SMBLibrary.Adapters/Properties/AssemblyInfo.cs b/SMBLibrary.Adapters/Properties/AssemblyInfo.cs index fc116cf..1f55f8c 100644 --- a/SMBLibrary.Adapters/Properties/AssemblyInfo.cs +++ b/SMBLibrary.Adapters/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.4.6.0")] -[assembly: AssemblyFileVersion("1.4.6.0")] +[assembly: AssemblyVersion("1.4.7.0")] +[assembly: AssemblyFileVersion("1.4.7.0")] diff --git a/SMBLibrary.Adapters/SMBLibrary.Adapters.csproj b/SMBLibrary.Adapters/SMBLibrary.Adapters.csproj index 9956471..9510712 100644 --- a/SMBLibrary.Adapters/SMBLibrary.Adapters.csproj +++ b/SMBLibrary.Adapters/SMBLibrary.Adapters.csproj @@ -4,7 +4,7 @@ net20;net40;netstandard2.0 false SMBLibrary.Adapters - 1.4.6 + 1.4.7 1573;1591 SMBLibrary.Adapters Tal Aloni diff --git a/SMBLibrary.Win32/Properties/AssemblyInfo.cs b/SMBLibrary.Win32/Properties/AssemblyInfo.cs index 7588932..13ac613 100644 --- a/SMBLibrary.Win32/Properties/AssemblyInfo.cs +++ b/SMBLibrary.Win32/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.4.6.0")] -[assembly: AssemblyFileVersion("1.4.6.0")] +[assembly: AssemblyVersion("1.4.7.0")] +[assembly: AssemblyFileVersion("1.4.7.0")] diff --git a/SMBLibrary.Win32/SMBLibrary.Win32.csproj b/SMBLibrary.Win32/SMBLibrary.Win32.csproj index 2908afb..1fe588a 100644 --- a/SMBLibrary.Win32/SMBLibrary.Win32.csproj +++ b/SMBLibrary.Win32/SMBLibrary.Win32.csproj @@ -4,7 +4,7 @@ net20;net40;netstandard2.0 false SMBLibrary.Win32 - 1.4.6 + 1.4.7 1573;1591 SMBLibrary.Win32 Tal Aloni diff --git a/SMBLibrary/Properties/AssemblyInfo.cs b/SMBLibrary/Properties/AssemblyInfo.cs index 91f1f85..fae33fa 100644 --- a/SMBLibrary/Properties/AssemblyInfo.cs +++ b/SMBLibrary/Properties/AssemblyInfo.cs @@ -31,6 +31,6 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.4.6.2")] -[assembly: AssemblyFileVersion("1.4.6.2")] +[assembly: AssemblyVersion("1.4.7.0")] +[assembly: AssemblyFileVersion("1.4.7.0")] [assembly: InternalsVisibleTo("SMBLibrary.Tests")] \ No newline at end of file diff --git a/SMBLibrary/RevisionHistory.txt b/SMBLibrary/RevisionHistory.txt index d03156b..6fbd7b8 100644 --- a/SMBLibrary/RevisionHistory.txt +++ b/SMBLibrary/RevisionHistory.txt @@ -459,3 +459,13 @@ Revision History: NTLM: Bugfix: IndependentNTLMAuthenticationProvider login failed to to modification of message byte arrays. 1.4.6 - SMB2Client: Fixed InvalidCastException on failed login to SMB 3.0 server. + +1.4.7 - SMBServer: Added private Start overload allowing to specify the listening port. + Client: Added private Connect overload allowing to specify the server port. + SMB2Client: Correctly handle async responses. + SMB2Client: WaitForCommand: Compare MessageID instead of CommandName. + Client: SMB2FileStore: Implement Flush. + Client: Added support for accessing Cluster Shared Volumes file shares. + SMB2Command: Add MessageID property. + NTStatus: Added STATUS_WRONG_PASSWORD. + NTStatus: Correct STATUS_PASSWORD_MUST_CHANGE value. diff --git a/SMBLibrary/SMBLibrary.csproj b/SMBLibrary/SMBLibrary.csproj index dfda563..5230452 100644 --- a/SMBLibrary/SMBLibrary.csproj +++ b/SMBLibrary/SMBLibrary.csproj @@ -4,7 +4,7 @@ net20;net40;netstandard2.0 false SMBLibrary - 1.4.6.2 + 1.4.7 1573;1591 SMBLibrary false diff --git a/SMBServer/Properties/AssemblyInfo.cs b/SMBServer/Properties/AssemblyInfo.cs index 3a6ce02..a380364 100644 --- a/SMBServer/Properties/AssemblyInfo.cs +++ b/SMBServer/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("1.4.6.0")] -[assembly: AssemblyFileVersion("1.4.6.0")] +[assembly: AssemblyVersion("1.4.7.0")] +[assembly: AssemblyFileVersion("1.4.7.0")] From 00990840651347063a1626cbe2d6c4157ce8f1d8 Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Fri, 10 Dec 2021 13:44:43 +0200 Subject: [PATCH 21/24] SMBServer: Start Bugfix --- SMBLibrary/Server/SMBServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SMBLibrary/Server/SMBServer.cs b/SMBLibrary/Server/SMBServer.cs index 9e87ff8..8cc48a2 100644 --- a/SMBLibrary/Server/SMBServer.cs +++ b/SMBLibrary/Server/SMBServer.cs @@ -78,7 +78,7 @@ namespace SMBLibrary.Server /// public void Start(IPAddress serverAddress, SMBTransportType transport, bool enableSMB1, bool enableSMB2, bool enableSMB3, TimeSpan? connectionInactivityTimeout) { - int port = (m_transport == SMBTransportType.DirectTCPTransport ? DirectTCPPort : NetBiosOverTCPPort); + int port = (transport == SMBTransportType.DirectTCPTransport ? DirectTCPPort : NetBiosOverTCPPort); Start(serverAddress, transport, port, enableSMB1, enableSMB2, enableSMB3, connectionInactivityTimeout); } From 6b2906b6346ee093a9f0ea1361254483e419e080 Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Fri, 10 Dec 2021 13:49:27 +0200 Subject: [PATCH 22/24] SMBServer 1.4.8 --- SMBLibrary.Adapters/Properties/AssemblyInfo.cs | 4 ++-- SMBLibrary.Adapters/SMBLibrary.Adapters.csproj | 2 +- SMBLibrary.Win32/Properties/AssemblyInfo.cs | 4 ++-- SMBLibrary.Win32/SMBLibrary.Win32.csproj | 2 +- SMBLibrary/Properties/AssemblyInfo.cs | 4 ++-- SMBLibrary/RevisionHistory.txt | 2 ++ SMBLibrary/SMBLibrary.csproj | 2 +- SMBServer/Properties/AssemblyInfo.cs | 4 ++-- 8 files changed, 13 insertions(+), 11 deletions(-) diff --git a/SMBLibrary.Adapters/Properties/AssemblyInfo.cs b/SMBLibrary.Adapters/Properties/AssemblyInfo.cs index 1f55f8c..5bfe40d 100644 --- a/SMBLibrary.Adapters/Properties/AssemblyInfo.cs +++ b/SMBLibrary.Adapters/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.4.7.0")] -[assembly: AssemblyFileVersion("1.4.7.0")] +[assembly: AssemblyVersion("1.4.8.0")] +[assembly: AssemblyFileVersion("1.4.8.0")] diff --git a/SMBLibrary.Adapters/SMBLibrary.Adapters.csproj b/SMBLibrary.Adapters/SMBLibrary.Adapters.csproj index 9510712..991139f 100644 --- a/SMBLibrary.Adapters/SMBLibrary.Adapters.csproj +++ b/SMBLibrary.Adapters/SMBLibrary.Adapters.csproj @@ -4,7 +4,7 @@ net20;net40;netstandard2.0 false SMBLibrary.Adapters - 1.4.7 + 1.4.8 1573;1591 SMBLibrary.Adapters Tal Aloni diff --git a/SMBLibrary.Win32/Properties/AssemblyInfo.cs b/SMBLibrary.Win32/Properties/AssemblyInfo.cs index 13ac613..13a5087 100644 --- a/SMBLibrary.Win32/Properties/AssemblyInfo.cs +++ b/SMBLibrary.Win32/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.4.7.0")] -[assembly: AssemblyFileVersion("1.4.7.0")] +[assembly: AssemblyVersion("1.4.8.0")] +[assembly: AssemblyFileVersion("1.4.8.0")] diff --git a/SMBLibrary.Win32/SMBLibrary.Win32.csproj b/SMBLibrary.Win32/SMBLibrary.Win32.csproj index 1fe588a..65a2d6b 100644 --- a/SMBLibrary.Win32/SMBLibrary.Win32.csproj +++ b/SMBLibrary.Win32/SMBLibrary.Win32.csproj @@ -4,7 +4,7 @@ net20;net40;netstandard2.0 false SMBLibrary.Win32 - 1.4.7 + 1.4.8 1573;1591 SMBLibrary.Win32 Tal Aloni diff --git a/SMBLibrary/Properties/AssemblyInfo.cs b/SMBLibrary/Properties/AssemblyInfo.cs index fae33fa..e2d24a4 100644 --- a/SMBLibrary/Properties/AssemblyInfo.cs +++ b/SMBLibrary/Properties/AssemblyInfo.cs @@ -31,6 +31,6 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.4.7.0")] -[assembly: AssemblyFileVersion("1.4.7.0")] +[assembly: AssemblyVersion("1.4.8.0")] +[assembly: AssemblyFileVersion("1.4.8.0")] [assembly: InternalsVisibleTo("SMBLibrary.Tests")] \ No newline at end of file diff --git a/SMBLibrary/RevisionHistory.txt b/SMBLibrary/RevisionHistory.txt index 6fbd7b8..678b1b7 100644 --- a/SMBLibrary/RevisionHistory.txt +++ b/SMBLibrary/RevisionHistory.txt @@ -469,3 +469,5 @@ Revision History: SMB2Command: Add MessageID property. NTStatus: Added STATUS_WRONG_PASSWORD. NTStatus: Correct STATUS_PASSWORD_MUST_CHANGE value. + +1.4.8 - SMBServer - Start method bugfix. diff --git a/SMBLibrary/SMBLibrary.csproj b/SMBLibrary/SMBLibrary.csproj index 5230452..81eb0d1 100644 --- a/SMBLibrary/SMBLibrary.csproj +++ b/SMBLibrary/SMBLibrary.csproj @@ -4,7 +4,7 @@ net20;net40;netstandard2.0 false SMBLibrary - 1.4.7 + 1.4.8 1573;1591 SMBLibrary false diff --git a/SMBServer/Properties/AssemblyInfo.cs b/SMBServer/Properties/AssemblyInfo.cs index a380364..de3408d 100644 --- a/SMBServer/Properties/AssemblyInfo.cs +++ b/SMBServer/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("1.4.7.0")] -[assembly: AssemblyFileVersion("1.4.7.0")] +[assembly: AssemblyVersion("1.4.8.0")] +[assembly: AssemblyFileVersion("1.4.8.0")] From 22247a8bae584e15f3c0b677cd4232caf7e55593 Mon Sep 17 00:00:00 2001 From: Jacob Hales Date: Mon, 27 Dec 2021 12:18:14 -0800 Subject: [PATCH 23/24] Adding STATUS_PATH_NOT_COVERED = 0xC0000257 to NTStatus (#120) --- SMBLibrary/Enums/NTStatus.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/SMBLibrary/Enums/NTStatus.cs b/SMBLibrary/Enums/NTStatus.cs index 98ffc8f..d9ba068 100644 --- a/SMBLibrary/Enums/NTStatus.cs +++ b/SMBLibrary/Enums/NTStatus.cs @@ -68,6 +68,7 @@ namespace SMBLibrary STATUS_NOT_FOUND = 0xC0000225, STATUS_ACCOUNT_LOCKED_OUT = 0xC0000234, STATUS_PASSWORD_MUST_CHANGE = 0xC0000224, + STATUS_PATH_NOT_COVERED = 0xC0000257, STATUS_NOT_A_REPARSE_POINT = 0xC0000275, STATUS_INVALID_SMB = 0x00010002, // SMB1/CIFS: A corrupt or invalid SMB request was received From 5c4b88c759f47b97e706a9ab5a86199651dfa545 Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Mon, 27 Dec 2021 22:25:17 +0200 Subject: [PATCH 24/24] Update NTStatus.cs: Correct ordering --- SMBLibrary/Enums/NTStatus.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SMBLibrary/Enums/NTStatus.cs b/SMBLibrary/Enums/NTStatus.cs index d9ba068..9ce465e 100644 --- a/SMBLibrary/Enums/NTStatus.cs +++ b/SMBLibrary/Enums/NTStatus.cs @@ -65,9 +65,9 @@ namespace SMBLibrary STATUS_FS_DRIVER_REQUIRED = 0xC000019C, STATUS_USER_SESSION_DELETED = 0xC0000203, STATUS_INSUFF_SERVER_RESOURCES = 0xC0000205, + STATUS_PASSWORD_MUST_CHANGE = 0xC0000224, STATUS_NOT_FOUND = 0xC0000225, STATUS_ACCOUNT_LOCKED_OUT = 0xC0000234, - STATUS_PASSWORD_MUST_CHANGE = 0xC0000224, STATUS_PATH_NOT_COVERED = 0xC0000257, STATUS_NOT_A_REPARSE_POINT = 0xC0000275,