overflow_discovery/service/service.go
crusader 3f730e1fe4 ing
2017-11-22 11:52:13 +09:00

105 lines
3.5 KiB
Go

package service
import (
"git.loafle.net/overflow/overflow_discovery/service/matcher"
"git.loafle.net/overflow/overflow_discovery/service/matcher/activedirectory"
"git.loafle.net/overflow/overflow_discovery/service/matcher/cassandra"
"git.loafle.net/overflow/overflow_discovery/service/matcher/dns"
"git.loafle.net/overflow/overflow_discovery/service/matcher/ftp"
"git.loafle.net/overflow/overflow_discovery/service/matcher/http"
"git.loafle.net/overflow/overflow_discovery/service/matcher/imap"
"git.loafle.net/overflow/overflow_discovery/service/matcher/ldap"
"git.loafle.net/overflow/overflow_discovery/service/matcher/mongodb"
"git.loafle.net/overflow/overflow_discovery/service/matcher/mssql"
"git.loafle.net/overflow/overflow_discovery/service/matcher/mysql"
"git.loafle.net/overflow/overflow_discovery/service/matcher/netbios"
"git.loafle.net/overflow/overflow_discovery/service/matcher/oracle"
"git.loafle.net/overflow/overflow_discovery/service/matcher/pop"
"git.loafle.net/overflow/overflow_discovery/service/matcher/redis"
redis_protected "git.loafle.net/overflow/overflow_discovery/service/matcher/redis/protected"
"git.loafle.net/overflow/overflow_discovery/service/matcher/rmi"
"git.loafle.net/overflow/overflow_discovery/service/matcher/smb"
"git.loafle.net/overflow/overflow_discovery/service/matcher/smtp"
snmp_v2 "git.loafle.net/overflow/overflow_discovery/service/matcher/snmp/v2"
snmp_v3 "git.loafle.net/overflow/overflow_discovery/service/matcher/snmp/v3"
"git.loafle.net/overflow/overflow_discovery/service/matcher/ssh"
"git.loafle.net/overflow/overflow_discovery/service/matcher/telnet"
"git.loafle.net/overflow/overflow_discovery/service/matcher/wmi"
)
var (
AllMatchers []matcher.Matcher
TCPMatchers []matcher.Matcher
UDPMatchers []matcher.UDPMatcher
TCPPrePacketMatchers []matcher.Matcher
TCPNotPrePacketMatchers []matcher.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 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 {
if ispre {
return TCPPrePacketMatchers
}
return TCPNotPrePacketMatchers
}
func GetUDPMatchers() []matcher.UDPMatcher {
return UDPMatchers
}
func GetMatcherByName(serName string) Matcher {
for _, m := range AllMatchers {
if m.ServiceName() == serName {
return m
}
}
return nil
}