winrm

package
v0.0.0-...-9d78121 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: LGPL-3.0 Imports: 16 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAuth returned if the post request is droped due to invalid credentials
	ErrAuth = fmt.Errorf("Unauthorized request")
	// ErrPing returned if the ping fails
	ErrPing = fmt.Errorf("Ping failed, can't recive any response form target")
)

Functions

func TTYGetPasswd

func TTYGetPasswd() (string, error)

TTYGetPasswd will be valid if it's used from a valid TTY input, This can be passed in ClientConfig

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client type retains information about the winrm connection

func NewClient

func NewClient(config ClientConfig) (*Client, error)

NewClient creates a new secure winrm client for initiating connections with the winrm listener

func (Client) Password

func (c Client) Password() string

Password returns the winrm connection password

func (*Client) Ping

func (c *Client) Ping() error

Ping executes a simple echo command on the remote, if the server dosen't respond to this echo command it will return ErrPing. If the payload is executed and the server response accordingly we return nil

func (*Client) Run

func (c *Client) Run(command string, stdout io.Writer, stderr io.Writer) error

Run powershell command and direct output to stdout and errors to stderr If the Run successfully executes it returns nil

func (Client) Secure

func (c Client) Secure() bool

Secure returns true if the client is using a secure connection or false if it's just a normal http

type ClientConfig

type ClientConfig struct {
	// User of the client connection
	// If you want the default user Administrator, leave this empty
	User string
	// Host where we want to connect
	Host string
	// Key Private RSA key
	Key []byte
	// Cert https client x509 cert
	Cert []byte
	// CACert of the host we wish to connect
	// This can be nil if Insecure is false
	CACert []byte
	// Timeout on how long we should wait until a connection is made.
	// If empty this will use the 60*time.Seconds winrm default value
	Timeout time.Duration
	// Insecure flag for checking the CACert or not. If this is true there should
	// be a valid CACert passed also.
	Insecure bool
	// Password callback for returning a password in different ways
	Password GetPasswd
	// Secure flag for specifying if the user wants https or http
	Secure bool
}

ClientConfig used for setting up a secure https client connection

func (ClientConfig) Validate

func (c ClientConfig) Validate() error

Validate checks all config options if they are invalid

type GetPasswd

type GetPasswd func() (string, error)

GetPasswd callback for different semantics that a client could use for secure authentication

type X509

type X509 struct {
	// contains filtered or unexported fields
}

X509 type that defines windows remote manager credentials for client-server secure communication

func NewX509

func NewX509() *X509

NewX509 returns a new to an empty X509

func (*X509) CACert

func (x *X509) CACert() []byte

CACert returns the internal credential client ca cert

func (*X509) ClientCert

func (x *X509) ClientCert() []byte

ClientCert returns the internal credential client x509 cert

func (*X509) ClientKey

func (x *X509) ClientKey() []byte

ClientKey returns the internal credential client x509 private key

func (*X509) LoadCACert

func (x *X509) LoadCACert(path string) error

LoadCACert reads ca cert into memory

func (*X509) LoadClientCert

func (x *X509) LoadClientCert(certFile, keyFile string) error

LoadClientCert generates client cert for x509 authentication if the directory files are not already there , if they are already there it will load them into memory

func (*X509) Reset

func (x *X509) Reset()

Reset fills up the internal state with nil values

Jump to

Keyboard shortcuts

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