HOME 119d84c0c9 Merge branch 'master' into Mod-1 преди 4 години
..
Authentication 40d7aaa228 SMBLibrary: Moved tests to separate project преди 5 години
Client 9ca92eca83 Client: SMB1FileStore: Implemented SetFileInformation with FileInformation parameter преди 4 години
DFS 2646b952ea Moved DFS structures to DFS directory преди 7 години
Enums 01c2fe9887 NTStatus: Added STATUS_NOT_FOUND преди 5 години
Exceptions 62cea47d96 Use InvalidDataException instead of InvalidRequestException преди 7 години
Helpers 0098cc78f5 FileBasicInformation, SMB_SET_FILE_BASIC_INFO: Added support for FILETIME value of -1 преди 7 години
NTFileStore 1401ee7d43 Updated FileLinkInformation and FileRenameInformation remarks преди 4 години
NetBios eda010c37d Optimized connection receive buffer allocation преди 5 години
Properties b233b87d00 SMB Server v1.4.1 преди 4 години
RPC 3289c0e333 RPC: DataRepresentationFormat: Added constructor преди 6 години
SMB1 51697529bf TransactionQueryNamedPipeInfoResponse: Corrected implementation преди 6 години
SMB1FileStore 05d7fa0d5b QueryInformationHelper: Added ToFileInformationLevel and ToFileInformation methods преди 7 години
SMB2 c6908e2d93 SMB2: SecurityMode: Added Flags attribute преди 5 години
Server 7f7ca944ac Server: Reduce maximum PDU size to 1 MB преди 4 години
Services fc048b1232 ServerService, WorkstationService: Unsupported OpNums and Levels are now reported back to the client instead of NotImplementedException преди 6 години
Utilities 3674fcd58a Improved ReleaseSocket implementation преди 7 години
Readme.md 1e189b1735 Updated Readme files преди 7 години
Readme.txt 1e189b1735 Updated Readme files преди 7 години
RevisionHistory.txt b233b87d00 SMB Server v1.4.1 преди 4 години
SMBLibrary.VS2005.csproj 394d12521e Renamed VS2005 solution and projects преди 5 години
SMBLibrary.csproj 98536917b9 commit: fix crash when missing Config section in settings; change ILRepack behavior on release build преди 4 години

Readme.md

About SMBLibrary:

SMBLibrary is an open-source C# SMB 1.0/CIFS, SMB 2.0 and SMB 2.1 server 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.

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.
    • A limited alternative is 'OpenVPN TAP-Windows Adapter' that can be used for client communication with SMBLibrary.

However, you will have to configure this adapter to use a separate network segment. The driver installation can be downloaded from: https://openvpn.net/index.php/open-source/downloads.html To get started, go to Adapter properties > 'Advanced' and set 'Media Status' to 'Always Connected'.

Windows 7/8/2008/2012:
  • if you want localhost access from Windows explorer to work as expected, you must use port 445, you must also specify the IP address that you selected (\\127.0.0.1 or \\localhost will not work as expected).
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.

Contact:

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