overflow_discovery/service/service.go

105 lines
3.6 KiB
Go
Raw Normal View History

2017-11-21 12:47:55 +00:00
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 (
2017-11-22 02:52:13 +00:00
AllMatchers []matcher.Matcher
2017-11-21 12:47:55 +00:00
TCPMatchers []matcher.Matcher
UDPMatchers []matcher.UDPMatcher
TCPPrePacketMatchers []matcher.Matcher
TCPNotPrePacketMatchers []matcher.Matcher
)
func init() {
//TCP
2017-11-22 02:52:13 +00:00
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())
2017-11-21 12:47:55 +00:00
2017-11-22 02:52:13 +00:00
// UDP
registerUDPMatcher(dns.NewMatcher())
registerUDPMatcher(snmp_v2.NewMatcher())
registerUDPMatcher(snmp_v3.NewMatcher())
2017-11-21 12:47:55 +00:00
}
2017-11-22 02:52:13 +00:00
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)
2017-11-21 12:47:55 +00:00
}
}
2017-11-22 02:52:13 +00:00
func registerUDPMatcher(m matcher.UDPMatcher) {
AllMatchers = append(AllMatchers, m)
UDPMatchers = append(UDPMatchers, m)
}
2017-11-21 12:47:55 +00:00
2017-11-22 10:04:04 +00:00
func GetTCPMatchers(isPrePacket bool) []matcher.Matcher {
if isPrePacket {
2017-11-22 02:52:13 +00:00
return TCPPrePacketMatchers
2017-11-21 12:47:55 +00:00
}
2017-11-22 02:52:13 +00:00
return TCPNotPrePacketMatchers
}
func GetUDPMatchers() []matcher.UDPMatcher {
return UDPMatchers
2017-11-21 12:47:55 +00:00
}
2017-11-22 05:55:40 +00:00
func GetMatcherByName(serName string) matcher.Matcher {
2017-11-22 02:52:13 +00:00
for _, m := range AllMatchers {
2017-11-21 12:47:55 +00:00
if m.ServiceName() == serName {
return m
}
}
return nil
}