package ssh import ( "strings" cnsm "git.loafle.net/commons_go/network_service_matcher" ) type SSHMatcher struct { cnsm.Matchers } func (ssh *SSHMatcher) ServiceName() string { return "SSH" } func (ssh *SSHMatcher) IsPrePacket() bool { return true } func (ssh *SSHMatcher) HasResponse(index int) bool { return true } func (ssh *SSHMatcher) IsError(info cnsm.MatchInfo, index int, packet *cnsm.Packet) bool { return false } func (ssh *SSHMatcher) Match(info cnsm.MatchInfo, index int, packet *cnsm.Packet) bool { result := false if packet == nil || packet.Buffer == nil || packet.Len == 0 { return result } str := string(packet.Buffer) //fmt.Println(str) temps := strings.Split(str, " ") protocol := strings.Split(temps[0], "-") //osType := temps[1] if 0 == strings.Compare(protocol[0], "SSH") { majorVersion := protocol[1] //fmt.Println(majorVersion) if 0 == strings.Compare(majorVersion, "2.0") || 0 == strings.Compare(majorVersion, "1.0") { result = true } } return result } func NewMatcher() cnsm.Matcher { m := &SSHMatcher{} return m }