smb

package
v0.0.0-...-7d23d5e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OIDKerberos = asn1.ObjectIdentifier{1, 2, 840, 113554, 1, 2, 2}

OID for Kerberos V5

Functions

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether err means the SMB target file or path does not exist. The smb2 layer translates STATUS_OBJECT_NAME_NOT_FOUND and STATUS_OBJECT_PATH_NOT_FOUND to os.ErrNotExist in conn.go before wrapping, so most call sites see the sentinel rather than an *smb2.ResponseError. We accept both forms.

func IsSharingViolation

func IsSharingViolation(err error) bool

IsSharingViolation reports whether err wraps STATUS_SHARING_VIOLATION. The smb2 client wraps server responses in *os.PathError → *smb2.ResponseError, so substring matching on err.Error() is unreliable.

Types

type Client

type Client struct {
	Session *smb2.Session
	Target  session.Target
	Creds   *session.Credentials
	// contains filtered or unexported fields
}

func NewClient

func NewClient(target session.Target, creds *session.Credentials) *Client

func (*Client) Cat

func (c *Client) Cat(file string) (string, error)

func (*Client) Cd

func (c *Client) Cd(dir string) error

func (*Client) Close

func (c *Client) Close()

func (*Client) Connect

func (c *Client) Connect() error

func (*Client) EnumerateSnapshots

func (c *Client) EnumerateSnapshots() ([]string, error)

EnumerateSnapshots returns the VSS shadow-copy tokens available on the currently selected share, formatted as `@GMT-YYYY.MM.DD-HH.MM.SS`. Requires a share to be selected via UseShare. Returns an empty slice if no snapshots exist. Implements the two-call size-probe pattern from MS-SMB2 2.2.32.

func (*Client) Get

func (c *Client) Get(remoteFile, localFile string) error

func (*Client) GetCurrentPath

func (c *Client) GetCurrentPath() string

func (*Client) GetDNSHostName

func (c *Client) GetDNSHostName() string

GetDNSHostName returns the server's DNS hostname from the NTLM challenge.

func (*Client) GetDNSTreeName

func (c *Client) GetDNSTreeName() string

GetDNSTreeName returns the forest DNS name from the NTLM challenge.

func (*Client) GetSessionKey

func (c *Client) GetSessionKey() []byte

GetSessionKey returns the SMB session key used for signing/encryption.

func (*Client) ListShares

func (c *Client) ListShares() ([]string, error)

func (*Client) Ls

func (c *Client) Ls(dir string) ([]os.FileInfo, error)

func (*Client) Mget

func (c *Client) Mget(pattern string) error

Mget downloads multiple files matching a pattern.

func (*Client) Mkdir

func (c *Client) Mkdir(dir string) error

func (*Client) OpenPipe

func (c *Client) OpenPipe(name string) (*smb2.File, error)

OpenPipe opens a named pipe on the IPC$ share with read/write access.

func (*Client) OpenPipeWithAccess

func (c *Client) OpenPipeWithAccess(name string, access PipeAccess) (*smb2.File, error)

OpenPipeWithAccess opens a named pipe with specified access mode.

func (*Client) Put

func (c *Client) Put(localFile, remoteFile string) error

func (*Client) Rename

func (c *Client) Rename(oldPath, newPath string) error

func (*Client) Rm

func (c *Client) Rm(file string) error

func (*Client) Rmdir

func (c *Client) Rmdir(dir string) error

func (*Client) Tree

func (c *Client) Tree(root string, fn TreeWalkFunc) error

Tree recursively lists files.

func (*Client) UseShare

func (c *Client) UseShare(name string) error

type KerberosInitiator

type KerberosInitiator struct {
	KrbClient *kerberos.Client
	TargetSPN string
	// contains filtered or unexported fields
}

func (*KerberosInitiator) AcceptSecContext

func (k *KerberosInitiator) AcceptSecContext(sc []byte) ([]byte, error)

func (*KerberosInitiator) InitSecContext

func (k *KerberosInitiator) InitSecContext() ([]byte, error)

func (*KerberosInitiator) OID

func (*KerberosInitiator) SessionKey

func (k *KerberosInitiator) SessionKey() []byte

func (*KerberosInitiator) Sum

func (k *KerberosInitiator) Sum(b []byte) []byte

type PipeAccess

type PipeAccess int

PipeAccess specifies the access mode for named pipes

const (
	PipeAccessReadWrite PipeAccess = iota // Read and write (default)
	PipeAccessRead                        // Read only (for stdout/stderr)
	PipeAccessWrite                       // Write only (for stdin)
)

type TreeWalkFunc

type TreeWalkFunc func(path string, info os.FileInfo, err error) error

TreeWalkFunc is called for each file found by Tree

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL