116 lines
3.8 KiB
Go
116 lines
3.8 KiB
Go
package matcher
|
|
|
|
import (
|
|
"git.loafle.net/overflow/overflow_probe/matcher/activedirectory"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/cassandra"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/dns"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/ftp"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/http"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/imap"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/ldap"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/mongodb"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/mssql"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/mysql"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/netbios"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/oracle"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/packet"
|
|
"git.loafle.net/overflow/overflow_probe/model/scaninfo"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/pop"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/redis"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/rmi"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/smb"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/smtp"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/snmp"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/ssh"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/telnet"
|
|
"git.loafle.net/overflow/overflow_probe/matcher/wmi"
|
|
)
|
|
|
|
var (
|
|
TcpMatchers []Matcher
|
|
UdpMatchers []UDPMatcher
|
|
)
|
|
|
|
func init() {
|
|
//TCP
|
|
TcpMatchers = append(TcpMatchers, smtp.NewSmtpMatcher())
|
|
TcpMatchers = append(TcpMatchers, ldap.NewLDAPMatcher())
|
|
TcpMatchers = append(TcpMatchers, activedirectory.NewActiveDirectoryMatcher())
|
|
TcpMatchers = append(TcpMatchers, mongodb.NewMongoDBMatcher())
|
|
TcpMatchers = append(TcpMatchers, mysql.NewMySqlMatcher())
|
|
TcpMatchers = append(TcpMatchers, mssql.NewMSSqlMatcher())
|
|
TcpMatchers = append(TcpMatchers, redis.NewRedisMatcher())
|
|
TcpMatchers = append(TcpMatchers, redis.NewRedisProtectedMatcher())
|
|
TcpMatchers = append(TcpMatchers, netbios.NewNetBiosMatcher())
|
|
TcpMatchers = append(TcpMatchers, smb.NewSMBMatcher())
|
|
TcpMatchers = append(TcpMatchers, cassandra.NewCassandraMatcher())
|
|
TcpMatchers = append(TcpMatchers, imap.NewIMAPMatcher())
|
|
TcpMatchers = append(TcpMatchers, oracle.NewOracleMatcher())
|
|
TcpMatchers = append(TcpMatchers, pop.NewPOPMatcher())
|
|
TcpMatchers = append(TcpMatchers, wmi.NewWMIMatcher())
|
|
TcpMatchers = append(TcpMatchers, ftp.NewFTPMatcher())
|
|
TcpMatchers = append(TcpMatchers, http.NewHTTPMatcher())
|
|
TcpMatchers = append(TcpMatchers, rmi.NewRMIMatcher())
|
|
TcpMatchers = append(TcpMatchers, ssh.NewSSHMatcher())
|
|
TcpMatchers = append(TcpMatchers, telnet.NewTelnetMatcher())
|
|
UdpMatchers = append(UdpMatchers, dns.NewDnsMatcher())
|
|
UdpMatchers = append(UdpMatchers, snmp.NewSNMPv2Matcher())
|
|
UdpMatchers = append(UdpMatchers, snmp.NewSNMPv3Matcher())
|
|
}
|
|
|
|
type Matcher interface {
|
|
Match(index int, packet *packet.Packet, info scaninfo.ServiceScanInfo) bool
|
|
|
|
PacketCount() int
|
|
Packet(index int) *packet.Packet
|
|
ServiceName() string
|
|
|
|
IsError(index int, packet *packet.Packet, info scaninfo.ServiceScanInfo) bool
|
|
IsNoResponse(index int) bool
|
|
IsPrePacket() bool
|
|
}
|
|
|
|
type UDPMatcher interface {
|
|
Matcher
|
|
IsSend(port int) bool
|
|
}
|
|
|
|
func GetTcpMatchers(ispre bool) []Matcher {
|
|
|
|
retMatchers := make([]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() []UDPMatcher {
|
|
|
|
retMatchers := make([]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
|
|
}
|