Skip to main content

Overview

The smbserver module provides a complete SMB server implementation that allows you to create custom SMB file servers. This is useful for penetration testing, creating honeypots, or implementing custom file sharing services.

Key Classes

SimpleSMBServer

Easy-to-use SMB server with minimal configuration.
str
default:"'0.0.0.0'"
IP address to bind the server to
int
default:"445"
Port to listen on (445 for SMB, 139 for NetBIOS)

SMBSERVER

Advanced SMB server class with full control over configuration.
tuple
required
Tuple of (host, port) to bind to
ConfigParser
required
Configuration object defining server behavior and shares

Server Configuration

Global Settings

The global section defines server-wide settings:
str
NetBIOS name of the server
str
Operating system string returned to clients
str
Domain or workgroup name
str
NTLM challenge (16-character hex string)
str
Path to log file for server activity
str
Path to file where captured credentials are written
str
Enable SMB2/SMB3 support (‘True’ or ‘False’)

Share Configuration

Define shared directories:
str
Description of the share
str
Whether the share is read-only (‘yes’ or ‘no’)
str
Share type:
  • '0' - Disk share (SHARED_DISK)
  • '1' - Print queue (SHARED_PRINT_QUEUE)
  • '3' - IPC (SHARED_IPC)
str
required
Local filesystem path to share

SimpleSMBServer Methods

addShare()

Add a new share to the server.
str
required
Share name (e.g., ‘SHARE’, ‘C$’)
str
required
Local filesystem path
str
default:"''"
Share description
bool
default:"False"
Whether share is read-only

removeShare()

Remove a share from the server.
str
required
Name of share to remove

setSMB2Support()

Enable or disable SMB2/SMB3 support.
bool
required
True to enable SMB2/SMB3, False for SMB1 only

setLogFile()

Set the log file path.
str
required
Path to log file

addCredential()

Add authentication credentials.
str
required
Username to accept
str
required
Password to accept
str
default:"''"
Domain name
str
default:"''"
LM hash
str
default:"''"
NT hash

start()

Start the SMB server (blocking).

stop()

Stop the SMB server.

Callback Hooks

Customize server behavior by registering callback functions.

registerNamedPipe()

Register a handler for named pipe operations.
str
required
Name of the pipe (without \\PIPE\\ prefix)
callable
required
Function with signature (tid, user, data) -> bytes

setSMBChallenge()

Set a custom NTLM challenge.
str
required
16-character hex string representing 8 bytes

Usage Examples

Simple File Server

Authenticated Server

Credential Harvesting Server

Advanced Configuration

Custom Named Pipe Handler

Multi-threaded Server

Security Considerations

Running an SMB server requires root/administrator privileges to bind to port 445. Always run with appropriate security measures.
The credential harvesting capabilities should only be used for authorized security testing. Capturing credentials without permission is illegal.

Best Practices

  1. Use authentication - Always configure credentials unless running a public share
  2. Limit share access - Only share necessary directories
  3. Monitor logs - Regularly check log files for suspicious activity
  4. Set read-only where possible - Minimize write access to prevent abuse
  5. Use SMB2/SMB3 - Enable modern protocol support for better security

Helper Functions

getShares()

Get list of configured shares.

searchShare()

Find a specific share by name.

See Also