ssh

package
v0.6.11 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: BSD-3-Clause, GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgIgnore        = 2
	MsgUnimplemented = 3
	MsgDebug         = 4
	MsgNewKeys       = 21
)

These are SSH message type numbers. They are scattered around several documents but many were taken from [SSH-PARAMETERS].

Variables

View Source
var Decoder = &decoder.StreamDecoder{
	Type:        types.Type_NC_SSH,
	Name:        serviceSSH,
	Description: "The Secure Shell Protocol allows controlling remote machines over an encrypted connection",
	PostInit: func(d *decoder.StreamDecoder) error {
		var err error
		sshLog, _, err = logging.InitZapLogger(
			decoderconfig.Instance.Out,
			"ssh",
			decoderconfig.Instance.Debug,
		)
		return err
	},
	CanDecode: func(client, server []byte) bool {
		return bytes.Contains(server, sshServiceName)
	},
	DeInit: func(sd *decoder.StreamDecoder) error {
		return sshLog.Sync()
	},
	Factory: &sshReader{},
	Typ:     core.TCP,
}

Decoder for protocol analysis and writing audit records to disk.

Functions

func Marshal

func Marshal(msg interface{}) []byte

Marshal serializes the message in msg to SSH wire format. The msg argument should be a struct or pointer to struct. If the first member has the "sshtype" tag set to a number in decimal, that number is prepended to the result. If the last of member has the "ssh" tag set to "rest", its contents are appended to the output.

func Unmarshal

func Unmarshal(data []byte, out interface{}) error

Unmarshal parses data in SSH wire format into a structure. The out argument should be a pointer to struct. If the first member of the struct has the "sshtype" tag set to a '|'-separated set of numbers in decimal, the packet must start with one of those numbers. In case of error, Unmarshal returns a ParseError or UnexpectedMessageError.

Types

type ChannelCloseMsg

type ChannelCloseMsg struct {
	PeersID uint32 `sshtype:"97"`
}

type ChannelDataMsg

type ChannelDataMsg struct {
	PeersID uint32 `sshtype:"94"`
	Length  uint32
	Rest    []byte `ssh:"rest"`
}

Used for debug print outs of packets.

type ChannelEOFMsg

type ChannelEOFMsg struct {
	PeersID uint32 `sshtype:"96"`
}

type ChannelOpenConfirmMsg

type ChannelOpenConfirmMsg struct {
	PeersID          uint32 `sshtype:"91"`
	MyID             uint32
	MyWindow         uint32
	MaxPacketSize    uint32
	TypeSpecificData []byte `ssh:"rest"`
}

type ChannelOpenFailureMsg

type ChannelOpenFailureMsg struct {
	PeersID  uint32 `sshtype:"92"`
	Reason   RejectionReason
	Message  string
	Language string
}

type ChannelOpenMsg

type ChannelOpenMsg struct {
	ChanType         string `sshtype:"90"`
	PeersID          uint32
	PeersWindow      uint32
	MaxPacketSize    uint32
	TypeSpecificData []byte `ssh:"rest"`
}

type ChannelRequestFailureMsg

type ChannelRequestFailureMsg struct {
	PeersID uint32 `sshtype:"100"`
}

type ChannelRequestMsg

type ChannelRequestMsg struct {
	PeersID             uint32 `sshtype:"98"`
	Request             string
	WantReply           bool
	RequestSpecificData []byte `ssh:"rest"`
}

type ChannelRequestSuccessMsg

type ChannelRequestSuccessMsg struct {
	PeersID uint32 `sshtype:"99"`
}

type DisconnectMsg

type DisconnectMsg struct {
	Reason   uint32 `sshtype:"1"`
	Message  string
	Language string
}

disconnectMsg is the message that signals a disconnect. It is also the error type returned from mux.Wait()

func (*DisconnectMsg) Error

func (d *DisconnectMsg) Error() string

type GlobalRequestFailureMsg

type GlobalRequestFailureMsg struct {
	Data []byte `ssh:"rest" sshtype:"82"`
}

type GlobalRequestMsg

type GlobalRequestMsg struct {
	Type      string `sshtype:"80"`
	WantReply bool
	Data      []byte `ssh:"rest"`
}

type GlobalRequestSuccessMsg

type GlobalRequestSuccessMsg struct {
	Data []byte `ssh:"rest" sshtype:"81"`
}

type KexDHGexGroupMsg

type KexDHGexGroupMsg struct {
	P *big.Int `sshtype:"31"`
	G *big.Int
}

type KexDHGexInitMsg

type KexDHGexInitMsg struct {
	X *big.Int `sshtype:"32"`
}

type KexDHGexReplyMsg

type KexDHGexReplyMsg struct {
	HostKey   []byte `sshtype:"33"`
	Y         *big.Int
	Signature []byte
}

type KexDHGexRequestMsg

type KexDHGexRequestMsg struct {
	MinBits      uint32 `sshtype:"34"`
	PreferedBits uint32
	MaxBits      uint32
}

type KexDHInitMsg

type KexDHInitMsg struct {
	X *big.Int `sshtype:"30"`
}

type KexDHReplyMsg

type KexDHReplyMsg struct {
	HostKey   []byte `sshtype:"31"`
	Y         *big.Int
	Signature []byte
}

type KexECDHInitMsg

type KexECDHInitMsg struct {
	ClientPubKey []byte `sshtype:"30"`
}

type KexECDHReplyMsg

type KexECDHReplyMsg struct {
	HostKey         []byte `sshtype:"31"`
	EphemeralPubKey []byte
	Signature       []byte
}

type KexInitMsg

type KexInitMsg struct {
	Cookie                  [16]byte `sshtype:"20"`
	KexAlgos                []string
	ServerHostKeyAlgos      []string
	CiphersClientServer     []string
	CiphersServerClient     []string
	MACsClientServer        []string
	MACsServerClient        []string
	CompressionClientServer []string
	CompressionServerClient []string
	LanguagesClientServer   []string
	LanguagesServerClient   []string
	FirstKexFollows         bool
	Reserved                uint32
}

type RejectionReason

type RejectionReason uint32

RejectionReason is an enumeration used when rejecting channel creation requests. See RFC 4254, section 5.1.

const (
	Prohibited RejectionReason = iota + 1
	ConnectionFailed
	UnknownChannelType
	ResourceShortage
)

func (RejectionReason) String

func (r RejectionReason) String() string

String converts the rejection reason to human readable form.

type ServiceAcceptMsg

type ServiceAcceptMsg struct {
	Service string `sshtype:"6"`
}

type ServiceRequestMsg

type ServiceRequestMsg struct {
	Service string `sshtype:"5"`
}

type UserAuthBannerMsg

type UserAuthBannerMsg struct {
	Message string `sshtype:"53"`
	// unused, but required to allow message parsing
	Language string
}

type UserAuthFailureMsg

type UserAuthFailureMsg struct {
	Methods        []string `sshtype:"51"`
	PartialSuccess bool
}

type UserAuthGSSAPIErrTok

type UserAuthGSSAPIErrTok struct {
	ErrorToken []byte `sshtype:"64"`
}

type UserAuthGSSAPIError

type UserAuthGSSAPIError struct {
	MajorStatus uint32 `sshtype:"65"`
	MinorStatus uint32
	Message     string
	LanguageTag string
}

type UserAuthGSSAPIMIC

type UserAuthGSSAPIMIC struct {
	MIC []byte `sshtype:"66"`
}

type UserAuthGSSAPIToken

type UserAuthGSSAPIToken struct {
	Token []byte `sshtype:"61"`
}

type UserAuthInfoRequestMsg

type UserAuthInfoRequestMsg struct {
	User               string `sshtype:"60"`
	Instruction        string
	DeprecatedLanguage string
	NumPrompts         uint32
	Prompts            []byte `ssh:"rest"`
}

type UserAuthPubKeyOkMsg

type UserAuthPubKeyOkMsg struct {
	Algo   string `sshtype:"60"`
	PubKey []byte
}

type UserAuthRequestMsg

type UserAuthRequestMsg struct {
	User    string `sshtype:"50"`
	Service string
	Method  string
	Payload []byte `ssh:"rest"`
}

type UserAuthSuccessMsg

type UserAuthSuccessMsg struct {
}

Used for debug printouts of packets.

type WindowAdjustMsg

type WindowAdjustMsg struct {
	PeersID         uint32 `sshtype:"93"`
	AdditionalBytes uint32
}

Jump to

Keyboard shortcuts

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