This commit is contained in:
crusader 2017-11-22 11:52:13 +09:00
parent 75999ef2fa
commit 3f730e1fe4

View File

@ -29,6 +29,8 @@ import (
) )
var ( var (
AllMatchers []matcher.Matcher
TCPMatchers []matcher.Matcher TCPMatchers []matcher.Matcher
UDPMatchers []matcher.UDPMatcher UDPMatchers []matcher.UDPMatcher
@ -38,64 +40,62 @@ var (
func init() { func init() {
//TCP //TCP
TCPMatchers = append(TCPMatchers, smtp.NewMatcher()) registerTCPMatcher(smtp.NewMatcher())
TCPMatchers = append(TCPMatchers, ldap.NewMatcher()) registerTCPMatcher(ldap.NewMatcher())
TCPMatchers = append(TCPMatchers, activedirectory.NewMatcher()) registerTCPMatcher(activedirectory.NewMatcher())
TCPMatchers = append(TCPMatchers, mongodb.NewMatcher()) registerTCPMatcher(mongodb.NewMatcher())
TCPMatchers = append(TCPMatchers, mysql.NewMatcher()) registerTCPMatcher(mysql.NewMatcher())
TCPMatchers = append(TCPMatchers, mssql.NewMatcher()) registerTCPMatcher(mssql.NewMatcher())
TCPMatchers = append(TCPMatchers, redis.NewMatcher()) registerTCPMatcher(redis.NewMatcher())
TCPMatchers = append(TCPMatchers, redis_protected.NewMatcher()) registerTCPMatcher(redis_protected.NewMatcher())
TCPMatchers = append(TCPMatchers, netbios.NewMatcher()) registerTCPMatcher(netbios.NewMatcher())
TCPMatchers = append(TCPMatchers, smb.NewMatcher()) registerTCPMatcher(smb.NewMatcher())
TCPMatchers = append(TCPMatchers, cassandra.NewMatcher()) registerTCPMatcher(cassandra.NewMatcher())
TCPMatchers = append(TCPMatchers, imap.NewMatcher()) registerTCPMatcher(imap.NewMatcher())
TCPMatchers = append(TCPMatchers, oracle.NewMatcher()) registerTCPMatcher(oracle.NewMatcher())
TCPMatchers = append(TCPMatchers, pop.NewMatcher()) registerTCPMatcher(pop.NewMatcher())
TCPMatchers = append(TCPMatchers, wmi.NewMatcher()) registerTCPMatcher(wmi.NewMatcher())
TCPMatchers = append(TCPMatchers, ftp.NewMatcher()) registerTCPMatcher(ftp.NewMatcher())
TCPMatchers = append(TCPMatchers, http.NewMatcher()) registerTCPMatcher(http.NewMatcher())
TCPMatchers = append(TCPMatchers, rmi.NewMatcher()) registerTCPMatcher(rmi.NewMatcher())
TCPMatchers = append(TCPMatchers, ssh.NewMatcher()) registerTCPMatcher(ssh.NewMatcher())
TCPMatchers = append(TCPMatchers, telnet.NewMatcher()) registerTCPMatcher(telnet.NewMatcher())
UDPMatchers = append(UDPMatchers, dns.NewMatcher()) // UDP
UDPMatchers = append(UDPMatchers, snmp_v2.NewMatcher()) registerUDPMatcher(dns.NewMatcher())
UDPMatchers = append(UDPMatchers, snmp_v3.NewMatcher()) registerUDPMatcher(snmp_v2.NewMatcher())
registerUDPMatcher(snmp_v3.NewMatcher())
}
func registerTCPMatcher(m matcher.Matcher) {
AllMatchers = append(AllMatchers, m)
TCPMatchers = append(TCPMatchers, m)
if m.IsPrePacket() {
TCPPrePacketMatchers = append(TCPPrePacketMatchers, m)
} else {
TCPNotPrePacketMatchers = append(TCPNotPrePacketMatchers, m)
}
}
func registerUDPMatcher(m matcher.UDPMatcher) {
AllMatchers = append(AllMatchers, m)
UDPMatchers = append(UDPMatchers, m)
} }
func GetTCPMatchers(ispre bool) []matcher.Matcher { func GetTCPMatchers(ispre bool) []matcher.Matcher {
if ispre {
retMatchers := make([]matcher.Matcher, 0) return TCPPrePacketMatchers
l := len(TCPMatchers)
for i := 0; i < l; i++ {
c := TCPMatchers[i].IsPrePacket()
if c == ispre {
retMatchers = append(retMatchers, TCPMatchers[i])
}
} }
return retMatchers return TCPNotPrePacketMatchers
} }
func GetUDPMatchers() []matcher.UDPMatcher { func GetUDPMatchers() []matcher.UDPMatcher {
return UDPMatchers
retMatchers := make([]matcher.UDPMatcher, 0)
l := len(UDPMatchers)
for i := 0; i < l; i++ {
retMatchers = append(retMatchers, UDPMatchers[i])
}
return retMatchers
} }
func GetMatcherByName(serName string) Matcher { func GetMatcherByName(serName string) Matcher {
for _, m := range TCPMatchers { for _, m := range AllMatchers {
if m.ServiceName() == serName {
return m
}
}
for _, m := range UDPMatchers {
if m.ServiceName() == serName { if m.ServiceName() == serName {
return m return m
} }