mssrvs
import "github.com/TheManticoreProject/Manticore/network/dcerpc/ms-protocols/ms-srvs"
Package mssrvs implements high-level MS-SRVS (Server Service Remote Protocol) workflows over the srvsvc DCE/RPC interface (4b324fc8-1670-01d3-1278-5a47bf6ee188 v3.0), carried over the \srvsvc named pipe on the IPC$ tree.
It is the protocol layer above the interface: callers hold a connected and authenticated SMB v1 client and call the convenience methods here (ListShares, ListSessions, GetServerInfo), which bind to srvsvc, issue the underlying NetrShareEnum / NetrSessionEnum / NetrServerGetInfo calls, and project the NDR containers and unions into friendly Go structs. The smbclient-ng tool’s shares / who / info commands are the intended consumers.
References:
- [MS-SRVS] 3.1.4.8 NetrShareEnum, 3.1.4.6 NetrSessionEnum, 3.1.4.17 NetrServerGetInfo
- [MS-RPCE] DCE/RPC over SMB named pipes
Index
Constants
MaxPreferredLength is passed as the preferred maximum reply length of the Netr*Enum calls. 0xFFFFFFFF asks the server to return every entry in a single response, so no resume-handle paging is needed; this matches common client enumeration usage.
const MaxPreferredLength uint32 = 0xFFFFFFFF
type Client
Client exposes MS-SRVS workflows over an established SMB session. The supplied dialer MUST be backed by a client that is connected, authenticated, and tree-connected to IPC$ before any method is called.
type Client struct {
// contains filtered or unexported fields
}
func New
func New(dialer PipeDialer) *Client
New returns an MS-SRVS client over the given pipe dialer (typically a *network/smb/client.Client).
func (*Client) GetServerInfo
func (c *Client) GetServerInfo() (*ServerInfo, error)
GetServerInfo queries the server’s configuration via NetrServerGetInfo at info level 101 ([MS-SRVS] 3.1.4.17). It binds a fresh \srvsvc pipe for the call.
func (*Client) ListSessions
func (c *Client) ListSessions() ([]SessionInfo, error)
ListSessions enumerates the active sessions on the server via NetrSessionEnum at info level 10 ([MS-SRVS] 3.1.4.6). It binds a fresh \srvsvc pipe for the call. The server typically requires administrative rights to enumerate sessions.
func (*Client) ListShares
func (c *Client) ListShares() ([]ShareInfo, error)
ListShares enumerates the shares exported by the server via NetrShareEnum at info level 1 ([MS-SRVS] 3.1.4.8). It binds a fresh \srvsvc pipe for the call.
type PipeDialer
PipeDialer opens a fresh DCE/RPC named-pipe transport for the given pipe over an established, IPC$-tree-connected SMB session. It is the only capability MS-SRVS needs from the SMB layer, so depending on this interface (rather than a concrete SMB client) keeps mssrvs independent of the SMB dialect: the generic network/smb/client.Client satisfies it (via its RPCTransport method) and routes to an SMB1 or SMB2 named-pipe transport according to what was negotiated.
type PipeDialer interface {
RPCTransport(pipeName string) (dcerpctransport.Transport, error)
}
type ServerInfo
ServerInfo is the configuration of a server: platform id, name, OS version, SV_TYPE_* flags, and comment ([MS-SRVS] 2.2.4.41 SERVER_INFO_101).
type ServerInfo struct {
PlatformID uint32
Name string
VersionMajor uint32
VersionMinor uint32
Type uint32
Comment string
}
type SessionInfo
SessionInfo is an active session on the server: the connecting client’s name, the authenticated user, and the active/idle times in seconds ([MS-SRVS] 2.2.4.15 SESSION_INFO_10).
type SessionInfo struct {
ClientName string
UserName string
ActiveSecs uint32
IdleSecs uint32
}
type ShareInfo
ShareInfo is a shared resource exported by the server: its name, STYPE_* type flags, and comment ([MS-SRVS] 2.2.4.23 SHARE_INFO_1). Type carries the raw STYPE_* value, including the STYPE_SPECIAL (0x80000000) and STYPE_TEMPORARY (0x40000000) high bits.
type ShareInfo struct {
Name string
Type uint32
Comment string
}