Tal Aloni bef9bd6e69 FileTimeHelper.ReadNullableFileTime: throw InvalidDataException if FILETIME is negative 8 tahun lalu
..
Authentication cd03f7c946 Corrected SPNEGO implementation 8 tahun lalu
Client 6700166f5a Renamed SMBMessage to SMB1Message 8 tahun lalu
EnumStructures bbd572e938 Added conversion operators to and from AccessMask 8 tahun lalu
Enums 55b83add4e Added SMB 2.0 / 2.1 server implementation 8 tahun lalu
Helpers bef9bd6e69 FileTimeHelper.ReadNullableFileTime: throw InvalidDataException if FILETIME is negative 8 tahun lalu
NetBios dd8e867693 NetBIOS name service packets implementation refactoring 8 tahun lalu
Properties 9d8ee88f1e SMBServer v1.1.1 8 tahun lalu
RPC 3f36591e14 RPC PDUs can now be read starting from a specified buffer offset 8 tahun lalu
SMB1 3ed2bbcd1c SMB_COM_NT_CREATE_ANDX Response: Added support for relative time (negative value) as specified in MS-CIFS 8 tahun lalu
SMB2 88204faf9b SMB2: Honor SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB flag 8 tahun lalu
Server 0241d5c055 Improved NetBIOS name server implementation 8 tahun lalu
Services 9265858968 Removed leading slash from ServerService.PipeName and WorkstationService.PipeName 8 tahun lalu
Structures d5b73a8f9d Added MS-FSCC enums and structures required for SMB2 8 tahun lalu
Tests 017a96240f Renamed NTLMv2ClientChallengeStructure class to NTLMv2ClientChallenge 8 tahun lalu
Utilities 0641ccd6cf PrefetchStream: changed debug message 8 tahun lalu
Win32 c94ea8ad68 Win32 authentication: fail authentication if AcceptSecurityContext return SEC_E_INVALID_TOKEN 8 tahun lalu
Readme.md 3539d3bd31 Updated Readme.md 8 tahun lalu
Readme.txt 4dbc92fb34 Updated Readme.txt 8 tahun lalu
RevisionHistory.txt 9d8ee88f1e SMBServer v1.1.1 8 tahun lalu
SMBLibrary.csproj 794b1b30e1 Added SMB_GEA_LIST / SMB_GEA structures 8 tahun lalu

Readme.md

About SMBLibrary:

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