SMBLibrary 1.5.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SMBLibrary --version 1.5.0                
NuGet\Install-Package SMBLibrary -Version 1.5.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SMBLibrary" Version="1.5.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SMBLibrary --version 1.5.0                
#r "nuget: SMBLibrary, 1.5.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SMBLibrary as a Cake Addin
#addin nuget:?package=SMBLibrary&version=1.5.0

// Install SMBLibrary as a Cake Tool
#tool nuget:?package=SMBLibrary&version=1.5.0                

About SMBLibrary:

SMBLibrary is an open-source C# SMB 1.0/CIFS, SMB 2.0, SMB 2.1 and SMB 3.0 server and client implementation.
SMBLibrary gives .NET developers an easy way to share a directory / file system / virtual file system, with any operating system that supports the SMB protocol.
SMBLibrary is modular, you can take advantage of Integrated Windows Authentication and the Windows storage subsystem on a Windows host or use independent implementations that allow for cross-platform compatibility.
SMBLibrary shares can be accessed from any Windows version since Windows NT 4.0.

Windows specific implementations can be found in SMBLibrary.Win32.

Supported SMB / CIFS transport methods:

• NetBIOS over TCP (port 139)
• Direct TCP hosting (port 445)

'NetBIOS over TCP' and 'Direct TCP hosting' are almost identical, the only differences:
  • A 'session request' packet is initiating the NBT connection.
  • A 'keep alive' packet is sent from time to time over NBT connections.
  • SMB2: Direct TCP hosting supports large MTUs.

Notes:

By default, Windows already use ports 139 and 445. there are several techniques to free / utilize those ports:

Method 1: Disable Windows File and Printer Sharing server completely:
Windows XP/2003:
  1. For every network adapter: Uncheck 'File and Printer Sharing for Microsoft Networks".
  2. Navigate to 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters' and set 'SMBDeviceEnabled' to '0' (this will free port 445).
  3. Reboot.
Windows 7/8/2008/2012:

Disable the "Server" service (p.s. "TCP\IP NETBIOS Helper" should be enabled).

Method 2: Use Windows File Sharing AND SMBLibrary:

Windows bind port 139 to the first IP addres of every adapter, while port 445 is bound globally. This means that if you'll disable port 445 (or block it using a firewall), you'll be able to use a different service on port 139 for every IP address.

Additional Notes:
  • To free port 139 for a given adapter, go to 'Internet Protocol (TCP/IP) Properties' > Advanced > WINS, and select 'Disable NetBIOS over TCP/IP'. Uncheck 'File and Printer Sharing for Microsoft Networks' to ensure Windows will not answer to SMB traffic on port 445 for this adapter.

  • It's important to note that disabling NetBIOS over TCP/IP will also disable NetBIOS name service for that adapter (a.k.a. WINS), This service uses UDP port 137. SMBLibrary offers a name service of its own.

  • You can install a virtual network adapter driver for Windows to be used solely with SMBLibrary:

    • You can install the 'Microsoft Loopback adapter' and use it for server-only communication with SMBLibrary.
Windows 7/8/2008/2012:
  • It's possible to prevent Windows from using port 445 by removing all of the '\Device\Tcpip_{..}' and '\Device\Tcpip6_{..}' entries from the `Bind' registry key under 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Linkage'.

  • if you want localhost access from Windows explorer to work as expected, you must specify the IP address that you selected (\\127.0.0.1 or \\localhost will not work as expected), in addition, I have observed that when connecting to the first IP address of a given adapter, Windows will only attempt to connect to port 445.

Method 3: Use an IP address that is invisible to Windows File Sharing:

Using PCap.Net you can programmatically setup a virtual Network adapter and intercept SMB traffic (similar to how a virtual machine operates), You should use the ARP protocol to notify the network about the new IP address, and then process the incoming SMB traffic using SMBLibrary, good luck!

Using SMBLibrary:

Any directory / filesystem / object you wish to share must implement the IFileSystem interface (or the lower-level INTFileStore interface).
You can share anything from actual directories to custom objects, as long as they expose a directory structure.

Client code examples can be found here.

Contact:

If you have any question, feel free to contact me.
Tal Aloni tal.aloni.il@gmail.com

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net20 is compatible.  net35 was computed.  net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 2.0

    • No dependencies.
  • .NETFramework 4.0

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (9)

Showing the top 5 NuGet packages that depend on SMBLibrary:

Package Downloads
Lurgle.Transfer

File transfer library that accelerates getting projects up and running with SSH.NET, FluentFTP, and SMBLibrary!

SMBLibrary.Win32

Windows specific extensions for SMBLibrary

Beztek.Facade.Storage

Package Description

SMBLibrary.Adapters

FileSystem adapters for SMBLibrary

FileSyncLibNet

A library to easily backup or sync 2 folders either once or in a given interval.

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on SMBLibrary:

Repository Stars
punk-security/smbeagle
SMBeagle - Fileshare auditing tool.
github/gh-gei
Migration CLI for GitHub to GitHub migrations
exploits-forsale/themebleed
Proof-of-Concept for CVE-2023-38146 ("ThemeBleed")
Version Downloads Last updated
1.5.3.5 40,202 8/31/2024
1.5.3.4 21,717 8/3/2024
1.5.3.3 96 8/2/2024
1.5.3.2 1,713 7/30/2024
1.5.3.1 557 7/29/2024
1.5.3 33,143 6/25/2024
1.5.2 18,377 6/5/2024
1.5.1.3 97,153 3/1/2024
1.5.1.2 16,801 2/12/2024
1.5.1.1 7,878 2/5/2024
1.5.1 34,163 1/6/2024
1.5.0.3 18,451 12/11/2023
1.5.0.1 136,549 7/29/2023
1.5.0 111,741 5/20/2023
1.4.9 214,421 10/28/2022
1.4.8 748,279 12/10/2021
1.4.6.2 141,265 8/20/2021
1.4.6.1 86,156 4/16/2021
1.4.6 783,150 1/26/2021
1.4.5 1,833 1/23/2021
1.4.4 634 1/23/2021
1.4.3 7,790 11/28/2020
1.4.2 52,623 4/12/2020
1.4.1 2,045 2/15/2020