105 lines
3.3 KiB
Go
105 lines
3.3 KiB
Go
|
package matcher
|
||
|
|
||
|
import (
|
||
|
cnsm "git.loafle.net/commons_go/network_service_matcher"
|
||
|
|
||
|
"git.loafle.net/commons_go/network_service_matcher/activedirectory"
|
||
|
"git.loafle.net/commons_go/network_service_matcher/cassandra"
|
||
|
"git.loafle.net/commons_go/network_service_matcher/dns"
|
||
|
"git.loafle.net/commons_go/network_service_matcher/ftp"
|
||
|
"git.loafle.net/commons_go/network_service_matcher/http"
|
||
|
"git.loafle.net/commons_go/network_service_matcher/imap"
|
||
|
"git.loafle.net/commons_go/network_service_matcher/ldap"
|
||
|
"git.loafle.net/commons_go/network_service_matcher/mongodb"
|
||
|
"git.loafle.net/commons_go/network_service_matcher/mssql"
|
||
|
"git.loafle.net/commons_go/network_service_matcher/mysql"
|
||
|
"git.loafle.net/commons_go/network_service_matcher/netbios"
|
||
|
"git.loafle.net/commons_go/network_service_matcher/oracle"
|
||
|
"git.loafle.net/commons_go/network_service_matcher/pop"
|
||
|
"git.loafle.net/commons_go/network_service_matcher/redis"
|
||
|
redis_protected "git.loafle.net/commons_go/network_service_matcher/redis/protected"
|
||
|
"git.loafle.net/commons_go/network_service_matcher/rmi"
|
||
|
"git.loafle.net/commons_go/network_service_matcher/smb"
|
||
|
"git.loafle.net/commons_go/network_service_matcher/smtp"
|
||
|
snmp_v2 "git.loafle.net/commons_go/network_service_matcher/snmp/v2"
|
||
|
snmp_v3 "git.loafle.net/commons_go/network_service_matcher/snmp/v3"
|
||
|
"git.loafle.net/commons_go/network_service_matcher/ssh"
|
||
|
"git.loafle.net/commons_go/network_service_matcher/telnet"
|
||
|
"git.loafle.net/commons_go/network_service_matcher/wmi"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
AllMatchers []cnsm.Matcher
|
||
|
|
||
|
TCPMatchers []cnsm.Matcher
|
||
|
UDPMatchers []cnsm.UDPMatcher
|
||
|
|
||
|
TCPPrePacketMatchers []cnsm.Matcher
|
||
|
TCPNotPrePacketMatchers []cnsm.Matcher
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
//TCP
|
||
|
registerTCPMatcher(smtp.NewMatcher())
|
||
|
registerTCPMatcher(ldap.NewMatcher())
|
||
|
registerTCPMatcher(activedirectory.NewMatcher())
|
||
|
registerTCPMatcher(mongodb.NewMatcher())
|
||
|
registerTCPMatcher(mysql.NewMatcher())
|
||
|
registerTCPMatcher(mssql.NewMatcher())
|
||
|
registerTCPMatcher(redis.NewMatcher())
|
||
|
registerTCPMatcher(redis_protected.NewMatcher())
|
||
|
registerTCPMatcher(netbios.NewMatcher())
|
||
|
registerTCPMatcher(smb.NewMatcher())
|
||
|
registerTCPMatcher(cassandra.NewMatcher())
|
||
|
registerTCPMatcher(imap.NewMatcher())
|
||
|
registerTCPMatcher(oracle.NewMatcher())
|
||
|
registerTCPMatcher(pop.NewMatcher())
|
||
|
registerTCPMatcher(wmi.NewMatcher())
|
||
|
registerTCPMatcher(ftp.NewMatcher())
|
||
|
registerTCPMatcher(http.NewMatcher())
|
||
|
registerTCPMatcher(rmi.NewMatcher())
|
||
|
registerTCPMatcher(ssh.NewMatcher())
|
||
|
registerTCPMatcher(telnet.NewMatcher())
|
||
|
|
||
|
// UDP
|
||
|
registerUDPMatcher(dns.NewMatcher())
|
||
|
registerUDPMatcher(snmp_v2.NewMatcher())
|
||
|
registerUDPMatcher(snmp_v3.NewMatcher())
|
||
|
}
|
||
|
|
||
|
func registerTCPMatcher(m cnsm.Matcher) {
|
||
|
AllMatchers = append(AllMatchers, m)
|
||
|
TCPMatchers = append(TCPMatchers, m)
|
||
|
if m.IsPrePacket() {
|
||
|
TCPPrePacketMatchers = append(TCPPrePacketMatchers, m)
|
||
|
} else {
|
||
|
TCPNotPrePacketMatchers = append(TCPNotPrePacketMatchers, m)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func registerUDPMatcher(m cnsm.UDPMatcher) {
|
||
|
AllMatchers = append(AllMatchers, m)
|
||
|
UDPMatchers = append(UDPMatchers, m)
|
||
|
}
|
||
|
|
||
|
func GetTCPMatchers(isPrePacket bool) []cnsm.Matcher {
|
||
|
if isPrePacket {
|
||
|
return TCPPrePacketMatchers
|
||
|
}
|
||
|
|
||
|
return TCPNotPrePacketMatchers
|
||
|
}
|
||
|
|
||
|
func GetUDPMatchers() []cnsm.UDPMatcher {
|
||
|
return UDPMatchers
|
||
|
}
|
||
|
|
||
|
func GetMatcherByName(serName string) cnsm.Matcher {
|
||
|
for _, m := range AllMatchers {
|
||
|
if m.ServiceName() == serName {
|
||
|
return m
|
||
|
}
|
||
|
}
|
||
|
return nil
|
||
|
}
|