ssh

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package ssh defines chunk types for recordings of the ssh protocol.

Index

Constants

View Source
const (
	// Protocol is used to identify chunks that are recorded from SSH.
	Protocol bsr.Protocol = "BSSH"

	// MaxPacketSize is used by the DataWriter to determine if SSH data should
	// be broken into multiple chunks.
	MaxPacketSize = 256 * 1024
)
View Source
const (
	DataChunkType                  bsr.ChunkType = "DATA"
	BreakReqChunkType              bsr.ChunkType = "BREK"
	CancelTCPIPForwardReqChunkType bsr.ChunkType = "CTPF"
	DirectTCPIPReqChunkType        bsr.ChunkType = "DTCP"
	EnvReqChunkType                bsr.ChunkType = "ENVR"
	ExecReqChunkType               bsr.ChunkType = "EXEC"
	ExitSignalReqChunkType         bsr.ChunkType = "EXSG"
	ExitStatusReqChunkType         bsr.ChunkType = "EXST"
	ForwardedTCPIPReqChunkType     bsr.ChunkType = "FTCP"
	PtyReqChunkType                bsr.ChunkType = "PTYR"
	SessionReqChunkType            bsr.ChunkType = "SESS"
	ShellReqChunkType              bsr.ChunkType = "SHLL"
	SignalReqChunkType             bsr.ChunkType = "SGNL"
	SubsystemReqChunkType          bsr.ChunkType = "SUBS"
	TCPIPForwardReqChunkType       bsr.ChunkType = "TCPF"
	UnknownReqChunkType            bsr.ChunkType = "UNKR"
	WindowChangeReqChunkType       bsr.ChunkType = "WCHG"
	X11ForwardingReqChunkType      bsr.ChunkType = "X11F"
	X11ReqChunkType                bsr.ChunkType = "X11R"
	XonXoffReqChunkType            bsr.ChunkType = "XOXO"
)

Chunk types

View Source
const BreakRequestType = "break"
View Source
const CancelTCPIPForwardRequestType = "cancel-tcpip-forward"
View Source
const DirectTCPIPRequestType = "direct-tcpip"
View Source
const EnvRequestType = "env"
View Source
const ExecRequestType = "exec"
View Source
const ExitSignalRequestType = "exit-signal"
View Source
const ExitStatusRequestType = "exit-status"
View Source
const ForwardedTCPIPRequestType = "forwarded-tcpip"
View Source
const PtyRequestType = "pty-req"
View Source
const SessionRequestType = "session"
View Source
const ShellRequestType = "shell"
View Source
const SignalRequestType = "signal"
View Source
const SubsystemRequestType = "subsystem"
View Source
const TCPIPForwardRequestType = "tcpip-forward"
View Source
const WindowChangeRequestType = "window-change"
View Source
const X11ForwardingRequestType = "x11-req"
View Source
const X11RequestType = "x11"
View Source
const XonXoffRequestType = "xon-xoff"

Variables

This section is empty.

Functions

func DecodeChunk

func DecodeChunk(_ context.Context, bc *bsr.BaseChunk, data []byte) (bsr.Chunk, error)

DecodeChunk will decode any known SSH Chunk type. If the chunk type is not an ssh chunk type, and error is returned.

func ValidExecApplicationProgram

func ValidExecApplicationProgram(d ExecApplicationProgram) bool

ValidExecApplicationProgram checks if a given ExecApplicationProgram is valid.

func ValidSessionProgram

func ValidSessionProgram(d SessionProgram) bool

ValidSessionProgram checks if a given SessionProgram is valid.

Types

type BreakRequest

type BreakRequest struct {
	*bsr.BaseChunk
	*pssh.BreakRequest
}

BreakRequest is a chunk to contain data for an SSH Break request

func NewBreakRequest

func NewBreakRequest(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, r *gssh.Request) (*BreakRequest, error)

NewBreakRequest creates a BreakRequest chunk

func (*BreakRequest) MarshalData

func (r *BreakRequest) MarshalData(ctx context.Context) ([]byte, error)

MarshalData serializes a BreakRequest chunk

type CancelTCPIPForwardRequest

type CancelTCPIPForwardRequest struct {
	*bsr.BaseChunk
	*pssh.CancelTCPIPForwardRequest
}

CancelTCPIPForwardRequest is a chunk to contain data for an SSH Cancel TCIPIP Forward request

func NewCancelTCPIPForwardRequest

func NewCancelTCPIPForwardRequest(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, r *gssh.Request) (*CancelTCPIPForwardRequest, error)

NewCancelTCPIPForwardRequest creates a CancelTCPIPForwardRequest chunk

func (*CancelTCPIPForwardRequest) MarshalData

func (r *CancelTCPIPForwardRequest) MarshalData(ctx context.Context) ([]byte, error)

MarshalData serializes a CancelTCPIPForwardRequest chunk

type ChannelSummary

type ChannelSummary struct {
	ChannelSummary        *bsr.ChannelSummary
	SessionProgram        SessionProgram
	SubsystemName         string
	ExecProgram           ExecApplicationProgram
	FileTransferDirection FileTransferDirection
	OpenFailure           *OpenChannelError `json:",omitempty"`
}

ChannelSummary encapsulates data for a channel SessionProgram can only be one of the following: exec, shell, or subsystem SubsystemName is only populated if SessionProgram is subsystem ExecApplicationProgram is only populated if Channel Program is subsystem, and can be one of the following:

scp, rsync, or unknown

OpenFailure will be nil if the Channel was successfully opened.

type DataChunk

type DataChunk struct {
	*bsr.BaseChunk
	Data []byte
}

DataChunk contains the raw byte data from an SSH session

func NewDataChunk

func NewDataChunk(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, data []byte) (*DataChunk, error)

NewDataChunk constructs a DataChunk

func (*DataChunk) MarshalData

func (c *DataChunk) MarshalData(_ context.Context) ([]byte, error)

MarshalData returns the data for a DataChunk

type DirectTCPIPRequest

type DirectTCPIPRequest struct {
	*bsr.BaseChunk
	*pssh.DirectTCPIPRequest
}

DirectTCPIPRequest is a chunk to contain data for an SSH Direct TCPIP request

func NewDirectTCPIPRequest

func NewDirectTCPIPRequest(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, r *gssh.Request) (*DirectTCPIPRequest, error)

NewDirectTCPIPRequest creates a DirectTCPIPRequest chunk

func (*DirectTCPIPRequest) MarshalData

func (r *DirectTCPIPRequest) MarshalData(ctx context.Context) ([]byte, error)

MarshalData serializes a DirectTCPIPRequest chunk

type EnvRequest

type EnvRequest struct {
	*bsr.BaseChunk
	*pssh.EnvRequest
}

EnvRequest is a chunk to contain data for an SSH Env request

func NewEnvRequest

func NewEnvRequest(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, r *gssh.Request) (*EnvRequest, error)

NewEnvRequest creates an EnvRequest chunk

func (*EnvRequest) MarshalData

func (r *EnvRequest) MarshalData(ctx context.Context) ([]byte, error)

MarshalData serializes an EnvRequest chunk

type ExecApplicationProgram

type ExecApplicationProgram string

ExecApplicationProgram identifies what program was run with exec Currently, only Scp and Rsync are recognized to identify file transfers

const (
	ExecApplicationProgramNotApplicable ExecApplicationProgram = "not applicable"
	Unknown                             ExecApplicationProgram = "unknown"
	Scp                                 ExecApplicationProgram = "scp"
	Rsync                               ExecApplicationProgram = "rsync"
)

ExecApplicationPrograms

type ExecRequest

type ExecRequest struct {
	*bsr.BaseChunk
	*pssh.ExecRequest
}

ExecRequest is a chunk to contain data for an SSH Exec request

func NewExecRequest

func NewExecRequest(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, r *gssh.Request) (*ExecRequest, error)

NewExecRequest creates an ExecRequest chunk

func (*ExecRequest) MarshalData

func (r *ExecRequest) MarshalData(ctx context.Context) ([]byte, error)

MarshalData serializes an ExecRequest chunk

type ExitSignalRequest

type ExitSignalRequest struct {
	*bsr.BaseChunk
	*pssh.ExitSignalRequest
}

ExitSignalRequest is a chunk to contain data for an SSH Exit Signal request

func NewExitSignalRequest

func NewExitSignalRequest(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, r *gssh.Request) (*ExitSignalRequest, error)

NewExitSignalRequest creates an ExitSignalRequest chunk

func (*ExitSignalRequest) MarshalData

func (r *ExitSignalRequest) MarshalData(ctx context.Context) ([]byte, error)

MarshalData serializes an ExitSignalRequest chunk

type ExitStatusRequest

type ExitStatusRequest struct {
	*bsr.BaseChunk
	*pssh.ExitStatusRequest
}

ExitStatusRequest is a chunk to contain data for an SSH Exit Status request

func NewExitStatusRequest

func NewExitStatusRequest(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, r *gssh.Request) (*ExitStatusRequest, error)

NewExitSignalRequest creates an ExitSignalRequest chunk

func (*ExitStatusRequest) MarshalData

func (r *ExitStatusRequest) MarshalData(ctx context.Context) ([]byte, error)

MarshalData serializes an ExitStatusRequest chunk

type FileTransferDirection

type FileTransferDirection string

FileTransferDirection indicates the direction of a file transfer.

const (
	FileTransferNotApplicable FileTransferDirection = "not applicable"
	FileTransferUpload        FileTransferDirection = "upload"
	FileTransferDownload      FileTransferDirection = "download"
)

Valid file transfer directions.

type ForwardedTCPIPRequest

type ForwardedTCPIPRequest struct {
	*bsr.BaseChunk
	*pssh.ForwardedTCPIPRequest
}

ForwardedTCPIPRequest is a chunk to contain data for an SSH Forwarded TCPIP request

func NewForwardedTCPIPRequest

func NewForwardedTCPIPRequest(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, r *gssh.Request) (*ForwardedTCPIPRequest, error)

NewForwardedTCPIPRequest creates an ForwardedTCPIPRequest chunk

func (*ForwardedTCPIPRequest) MarshalData

func (r *ForwardedTCPIPRequest) MarshalData(ctx context.Context) ([]byte, error)

MarshalData serializes an ForwardedTCPIPRequest chunk

type OpenChannelError

type OpenChannelError ssh.OpenChannelError

OpenChannelError provides details if a channel was rejected. This will contain details from the SSH_MSG_CHANNEL_OPEN_FAILURE request that rejected the channel. See: https://www.rfc-editor.org/rfc/rfc4254#section-5.1

type PtyRequest

type PtyRequest struct {
	*bsr.BaseChunk
	*pssh.PtyRequest
}

PtyPRequest is a chunk to contain data for an SSH Pty request

func NewPtyRequest

func NewPtyRequest(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, r *gssh.Request) (*PtyRequest, error)

NewPtyRequest creates an PtyRequest chunk

func (*PtyRequest) MarshalData

func (r *PtyRequest) MarshalData(ctx context.Context) ([]byte, error)

MarshalData serializes an PtyRequest chunk

type SessionProgram

type SessionProgram string

SessionProgram identifies the program running on this channel as outlined in https://www.rfc-editor.org/rfc/rfc4254.html#section-6.5 :

Once the session has been set up, a program is started at the remote
end.  The program can be a shell, an application program, or a
subsystem with a host-independent name.  Only one of these requests
can succeed per channel.

SessionProgram is only valid when the channel type is 'session'

const (
	NotApplicable SessionProgram = "not applicable"
	None          SessionProgram = "none"
	Exec          SessionProgram = "exec"
	Shell         SessionProgram = "shell"
	Subsystem     SessionProgram = "subsystem"
)

SessionPrograms If the channel type is not of type session, then NotApplicable is expected If the session program is not exec, shell, or subsystem, then None is used

type SessionRequest

type SessionRequest struct {
	*bsr.BaseChunk
	*pssh.SessionRequest
}

SessionRequest is a chunk to contain data for an SSH Session request

func NewSessionRequest

func NewSessionRequest(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, r *gssh.Request) (*SessionRequest, error)

NewSessionRequest creates an SessionRequest chunk

func (*SessionRequest) MarshalData

func (r *SessionRequest) MarshalData(ctx context.Context) ([]byte, error)

MarshalData serializes an SessionRequest chunk

type ShellRequest

type ShellRequest struct {
	*bsr.BaseChunk
	*pssh.ShellRequest
}

ShellRequest is a chunk to contain data for an SSH Shell request

func NewShellRequest

func NewShellRequest(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, r *gssh.Request) (*ShellRequest, error)

NewShellRequest creates an ShellRequest chunk

func (*ShellRequest) MarshalData

func (r *ShellRequest) MarshalData(ctx context.Context) ([]byte, error)

MarshalData serializes an ShellRequest chunk

type SignalRequest

type SignalRequest struct {
	*bsr.BaseChunk
	*pssh.SignalRequest
}

SignalRequest is a chunk to contain data for an SSH Signal request

func NewSignalRequest

func NewSignalRequest(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, r *gssh.Request) (*SignalRequest, error)

NewSignalRequest creates an SignalRequest chunk

func (*SignalRequest) MarshalData

func (r *SignalRequest) MarshalData(ctx context.Context) ([]byte, error)

MarshalData serializes an SignalRequest chunk

type SubsystemRequest

type SubsystemRequest struct {
	*bsr.BaseChunk
	*pssh.SubsystemRequest
}

SubsystemRequest is a chunk to contain data for an SSH Subsystem request

func NewSubsystemRequest

func NewSubsystemRequest(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, r *gssh.Request) (*SubsystemRequest, error)

NewSubsystemRequest creates an SubsystemRequest chunk

func (*SubsystemRequest) MarshalData

func (r *SubsystemRequest) MarshalData(ctx context.Context) ([]byte, error)

MarshalData serializes an SubsystemRequest chunk

type TCPIPForwardRequest

type TCPIPForwardRequest struct {
	*bsr.BaseChunk
	*pssh.TCPIPForwardRequest
}

TCPIPForwardRequest is a chunk to contain data for an SSH TCPIP Forward request

func NewTCPIPForwardRequest

func NewTCPIPForwardRequest(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, r *gssh.Request) (*TCPIPForwardRequest, error)

NewTCPIPForwardRequest creates an TCPIPForwardRequest chunk

func (*TCPIPForwardRequest) MarshalData

func (r *TCPIPForwardRequest) MarshalData(ctx context.Context) ([]byte, error)

MarshalData serializes an TCPIPForwardRequest chunk

type UnknownRequest

type UnknownRequest struct {
	*bsr.BaseChunk
	*pssh.UnknownRequest
}

UnknownRequest is a chunk to contain data for any unrecognized SSH request

func NewUnknownRequest

func NewUnknownRequest(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, r *gssh.Request) (*UnknownRequest, error)

NewUnknownRequest creates an UnknownRequest chunk

func (*UnknownRequest) MarshalData

func (r *UnknownRequest) MarshalData(ctx context.Context) ([]byte, error)

MarshalData serializes an UnknownRequest chunk

type WindowChangeRequest

type WindowChangeRequest struct {
	*bsr.BaseChunk
	*pssh.WindowChangeRequest
}

WindowChangeRequest is a chunk to contain data for an SSH Window Change request

func NewWindowChangeRequest

func NewWindowChangeRequest(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, r *gssh.Request) (*WindowChangeRequest, error)

NewWindowChangeRequest creates a WindowChangeRequest chunk

func (*WindowChangeRequest) MarshalData

func (r *WindowChangeRequest) MarshalData(ctx context.Context) ([]byte, error)

MarshalData serializes an WindowChangeRequest chunk

type X11ForwardingRequest

type X11ForwardingRequest struct {
	*bsr.BaseChunk
	*pssh.X11ForwardingRequest
}

X11ForwardingRequest is a chunk to contain data for an SSH X11 Forwarding request

func NewX11ForwardingRequest

func NewX11ForwardingRequest(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, r *gssh.Request) (*X11ForwardingRequest, error)

NewX11ForwardingRequest creates an X11ForwardingRequest chunk

func (*X11ForwardingRequest) MarshalData

func (r *X11ForwardingRequest) MarshalData(ctx context.Context) ([]byte, error)

MarshalData serializes an X11ForwardingRequest chunk

type X11Request

type X11Request struct {
	*bsr.BaseChunk
	*pssh.X11Request
}

X11Request is a chunk to contain data for an SSH X11 request

func NewX11Request

func NewX11Request(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, r *gssh.Request) (*X11Request, error)

NewX11Request creates an X11Request chunk

func (*X11Request) MarshalData

func (r *X11Request) MarshalData(ctx context.Context) ([]byte, error)

MarshalData serializes an X11Request chunk

type XonXoffRequest

type XonXoffRequest struct {
	*bsr.BaseChunk
	*pssh.XonXoffRequest
}

XonXoffRequest is a chunk to contain data for an SSH Xon Xoff request

func NewXonXoffRequest

func NewXonXoffRequest(ctx context.Context, d bsr.Direction, t *bsr.Timestamp, r *gssh.Request) (*XonXoffRequest, error)

NewXonXoffRequest creates an XonXoffRequest chunk

func (*XonXoffRequest) MarshalData

func (r *XonXoffRequest) MarshalData(ctx context.Context) ([]byte, error)

MarshalData serializes an XonXoffRequest chunk

Jump to

Keyboard shortcuts

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