105 lines
3.8 KiB
Go
105 lines
3.8 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 (
|
|
TCPMatchers []matcher.Matcher
|
|
UDPMatchers []matcher.UDPMatcher
|
|
|
|
TCPPrePacketMatchers []matcher.Matcher
|
|
TCPNotPrePacketMatchers []matcher.Matcher
|
|
)
|
|
|
|
func init() {
|
|
//TCP
|
|
TCPMatchers = append(TCPMatchers, smtp.NewMatcher())
|
|
TCPMatchers = append(TCPMatchers, ldap.NewMatcher())
|
|
TCPMatchers = append(TCPMatchers, activedirectory.NewMatcher())
|
|
TCPMatchers = append(TCPMatchers, mongodb.NewMatcher())
|
|
TCPMatchers = append(TCPMatchers, mysql.NewMatcher())
|
|
TCPMatchers = append(TCPMatchers, mssql.NewMatcher())
|
|
TCPMatchers = append(TCPMatchers, redis.NewMatcher())
|
|
TCPMatchers = append(TCPMatchers, redis_protected.NewMatcher())
|
|
TCPMatchers = append(TCPMatchers, netbios.NewMatcher())
|
|
TCPMatchers = append(TCPMatchers, smb.NewMatcher())
|
|
TCPMatchers = append(TCPMatchers, cassandra.NewMatcher())
|
|
TCPMatchers = append(TCPMatchers, imap.NewMatcher())
|
|
TCPMatchers = append(TCPMatchers, oracle.NewMatcher())
|
|
TCPMatchers = append(TCPMatchers, pop.NewMatcher())
|
|
TCPMatchers = append(TCPMatchers, wmi.NewMatcher())
|
|
TCPMatchers = append(TCPMatchers, ftp.NewMatcher())
|
|
TCPMatchers = append(TCPMatchers, http.NewMatcher())
|
|
TCPMatchers = append(TCPMatchers, rmi.NewMatcher())
|
|
TCPMatchers = append(TCPMatchers, ssh.NewMatcher())
|
|
TCPMatchers = append(TCPMatchers, telnet.NewMatcher())
|
|
|
|
UDPMatchers = append(UDPMatchers, dns.NewMatcher())
|
|
UDPMatchers = append(UDPMatchers, snmp_v2.NewMatcher())
|
|
UDPMatchers = append(UDPMatchers, snmp_v3.NewMatcher())
|
|
}
|
|
|
|
func GetTCPMatchers(ispre bool) []matcher.Matcher {
|
|
|
|
retMatchers := make([]matcher.Matcher, 0)
|
|
l := len(TCPMatchers)
|
|
for i := 0; i < l; i++ {
|
|
c := TCPMatchers[i].IsPrePacket()
|
|
if c == ispre {
|
|
retMatchers = append(retMatchers, TCPMatchers[i])
|
|
}
|
|
}
|
|
|
|
return retMatchers
|
|
}
|
|
|
|
func GetUDPMatchers() []matcher.UDPMatcher {
|
|
|
|
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 {
|
|
for _, m := range TCPMatchers {
|
|
if m.ServiceName() == serName {
|
|
return m
|
|
}
|
|
}
|
|
for _, m := range UDPMatchers {
|
|
if m.ServiceName() == serName {
|
|
return m
|
|
}
|
|
}
|
|
return nil
|
|
}
|