gopsremote

package module
v0.0.0-...-3a72dea Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 18 Imported by: 0

README

gopsremote

Library to execute powershell commands remotely on a WinRM enabled windows machine

Documentation

Index

Constants

View Source
const (
	Create = 1 << iota
	Execute
	Send
	Receive
	Delete
)
View Source
const (
	WINRM_HTTP_PORT = 5985
	CHUNK           = 512
	SCRIPTSEPARATOR = "\n"
)

Variables

This section is empty.

Functions

func CaptureAttribute

func CaptureAttribute(body io.Reader, tag, attr string) (string, error)

func CaptureErrorMessages

func CaptureErrorMessages(errorMessage string) (string, error)

func CaptureStreams

func CaptureStreams(body io.Reader, stdout, stderr io.Writer) (string, bool, error)

func CaptureText

func CaptureText(body io.Reader, tag string) (string, error)

func Endpoint

func Endpoint(ipAddress, username, password string, auth Authentication, proxy func(*http.Request) (*url.URL, error)) getEndpointDetails

func IsSecure

func IsSecure(b bool) winrmSettingsOption

func Locale

func Locale(locale string) winrmSettingsOption

func MaxEnvelopeSize

func MaxEnvelopeSize(size string) winrmSettingsOption

func OperationTimeout

func OperationTimeout(operationTimeout int) winrmSettingsOption

func Port

func Port(num int) winrmSettingsOption

func Timeout

func Timeout(timeout int) winrmSettingsOption

Types

type Authentication

type Authentication int
const (
	Basic Authentication = 1 << iota
	NTLM
	Kerberos
)

type PayloadBuilder

type PayloadBuilder struct {
	// Format - https://{{ipaddress_or_fqdn}}:{{portno}}/wsman
	Url              string
	OperationTimeout string
	Locale           string
	MessageId        string
	ShellId          string
	CommandId        string
	Command          string
	Input            string
	MaxEnvelopeSize  string
	OpType           RequestType
}

Data structure to build the xml payloads from templates

func (*PayloadBuilder) Execute

func (p *PayloadBuilder) Execute() (*bytes.Buffer, error)

func (*PayloadBuilder) GenerateBody

func (p *PayloadBuilder) GenerateBody() string

func (*PayloadBuilder) GenerateOptionSet

func (p *PayloadBuilder) GenerateOptionSet() string

func (*PayloadBuilder) GenerateSelectorSet

func (p *PayloadBuilder) GenerateSelectorSet() string

func (*PayloadBuilder) GetAction

func (p *PayloadBuilder) GetAction() string

type RequestType

type RequestType int

type WinRMClient

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

WinRM client used for executing scripts TODO: Add support for NTLM and Kerberos, Only basic is supported for now TODO: Add support for certificate verification while initiating connections

func NewWinRMClient

func NewWinRMClient(details getEndpointDetails, options ...winrmSettingsOption) *WinRMClient

Creates a new WinRM client

func (*WinRMClient) ExecuteCommand

func (w *WinRMClient) ExecuteCommand(cmd string) (string, int, error)

ExecuteCommand - Executes the command on the target

Jump to

Keyboard shortcuts

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