Documentation
¶
Index ¶
- type Client
- func (c *Client) Connect(ipaddr net.IP, port int) error
- func (c *Client) GetHost() net.IP
- func (c *Client) GetPort() int
- func (c *Client) GetRemoteServerTime() (time.Time, error)
- func (c *Client) Negotiate() error
- func (c *Client) SessionSetup() error
- func (c *Client) SetHost(host net.IP)
- func (c *Client) SetPort(port int)
- type Connection
- type Server
- type Session
- type TreeConnect
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Transport is the transport layer for the client
Transport transport.Transport
// TreeConnect is the tree connect for the client
TreeConnect *TreeConnect
// Session is the session for the client
Session *Session
// Connection is the connection for the client
Connection *Connection
}
Client represents an SMB v1.0 client
func NewClientUsingNBTTransport ¶
NewClientUsingNBTTransport creates a new SMB v1.0 client using NBT transport
Returns:
- A pointer to the initialized SMB client
- An error if the client initialization fails
func (*Client) Connect ¶
Connect establishes a connection to an SMB server
Returns:
- An error if the connection fails
func (*Client) GetRemoteServerTime ¶
GetRemoteServerTime retrieves the current time from the remote server.
This function sends an SMB_COM_QUERY_TIME_REQUEST message to the server and receives the server's current time in UTC.
The query process: 1. Creates and sends an SMB_COM_NEGOTIATE_REQUEST message 2. Receives the SMB_COM_NEGOTIATE_RESPONSE from the server 3. Validates the response command type 4. Processes server capabilities and configuration
Returns:
- nil if negotiation is successful
- An error if any step in the negotiation process fails (connection issues, message creation/marshalling errors, transport errors, or unexpected responses)
func (*Client) Negotiate ¶
Negotiate initiates the SMB protocol negotiation with the server.
This function performs the SMB_COM_NEGOTIATE exchange, which is the first step in establishing an SMB session. It sends a list of dialects supported by the client and receives the server's preferred dialect along with server capabilities.
The negotiation process: 1. Creates and sends an SMB_COM_NEGOTIATE_REQUEST message 2. Receives the SMB_COM_NEGOTIATE_RESPONSE from the server 3. Validates the response command type 4. Processes server capabilities and configuration
Returns:
- nil if negotiation is successful
- An error if any step in the negotiation process fails (connection issues, message creation/marshalling errors, transport errors, or unexpected responses)
func (*Client) SessionSetup ¶
type Connection ¶
type Connection struct {
Server *Server
// ClientNextSendSequenceNumber is the sequence number for the next signed request being sent
ClientNextSendSequenceNumber uint32
// ClientResponseSequenceNumber is the expected sequence numbers for responses of outstanding signed requests, indexed by PID and MID
ClientResponseSequenceNumber map[uint32]uint32
// ConnectionlessSessionID is the SMB Connection identifier for connectionless transport
ConnectionlessSessionID uint32
// IsSigningActive indicates whether message signing is active
IsSigningActive bool
// NegotiateSent indicates whether an SMB_COM_NEGOTIATE request has been sent
NegotiateSent bool
// NTLMChallenge is the cryptographic challenge received from the server during negotiation
NTLMChallenge []byte
// OpenTable is the list of Opens, allowing lookups based on FID
OpenTable map[uint16]interface{}
// PIDMIDList is the list of outstanding SMB commands
PIDMIDList []interface{}
// SearchOpenTable is the list of SearchOpens representing open file searches
SearchOpenTable []interface{}
// SelectedDialect is the SMB Protocol dialect selected for this connection
SelectedDialect string
// MaxMpxCount is the maximum number of commands permitted to be outstanding
MaxMpxCount uint16
// SessionTable is the list of authenticated sessions established on this connection
SessionTable map[uint16]*Session
ShareLevelAccessControl bool
// SigningChallengeResponse is the challenge response used for signing
SigningChallengeResponse []byte
// SigningSessionKey is the session key used for signing packets
SigningSessionKey []byte
// TreeConnectTable is the list of tree connects over this SMB connection
TreeConnectTable map[uint16]interface{}
}
Connection represents an established SMB connection between the client and server
type Server ¶
type Server struct {
// Host is the IP address of the server
Host net.IP
// Port is the port number of the server
Port int
// Name is the name of the server
Name string
// SecurityMode is the security mode of the server
SecurityMode securitymode.SecurityMode
// SigningState is the signing policy of the server (Disabled, Enabled, or Required)
SigningState string
// Capabilities is the capabilities of the server
Capabilities capabilities.Capabilities
// MaxBufferSize is the negotiated maximum size for SMB messages sent to server
MaxBufferSize uint32
// ChallengeResponse indicates whether server supports challenge/response authentication
ChallengeResponse bool
// SessionKey is the session key value returned by the server in negotiate response
SessionKey uint32
// SystemTime is the system time of the server
SystemTime types.SMB_TIME
// TimeZone is the time zone of the server
TimeZone int16
// DomainName is the domain name of the server
DomainName string
}
Server represents the server for the client
type Session ¶
type Session struct {
// The SMB connection associated with this session
Connection *Client
// The cryptographic session key associated with this session
SessionKey []byte
// The 2-byte UID for this session
SessionUID uint16
// Opaque implementation-specific entity that identifies the credentials
UserCredentials interface{}
}
Session represents an established session between the client and server
type TreeConnect ¶
type TreeConnect struct {
Connection *Connection // The SMB connection associated with this tree connect
TreeID uint16 // The TreeID (TID) that identifies this tree connect
Session *Session // A reference to the session on which this tree connect was established
}
TreeConnect represents an established tree connect between the client and share on the server