This commit is contained in:
jackdaw@loafle.com 2017-04-11 17:42:02 +09:00
parent 55682d7d39
commit a1a8d24728
3 changed files with 50 additions and 7 deletions

37
const.go Normal file
View File

@ -0,0 +1,37 @@
package crawler
import (
"strconv"
)
type CrawlerName int
func (c CrawlerName) String() string {
return strconv.Itoa(int(c))
}
const (
ACTIVEDIRECTORY = CrawlerName(iota)
DNS
FTP
FTPS
IMAP
LDAP
MONGODB
MSSQL
MYSQL
MARIADB
PGSQL
NETBIOS
ORACLE
POP3
REDIS
RMI
SMB
SMTP
SNMPV2C
SNMPV3
SSH
TELNET
WMI
)

View File

@ -4,6 +4,8 @@ import (
"loafle.com/overflow/of_rpc_go/models/param"
)
type Internal interface {
Internal(params map[string]interface{}) (param.Output, error)
}

View File

@ -5,6 +5,7 @@ import (
"loafle.com/overflow/commons_go/matcher"
"loafle.com/overflow/commons_go/matcher/packet"
"net"
"loafle.com/overflow/commons_go/model/scaninfo"
)
type SocketHeahthCrawler struct {
@ -40,6 +41,7 @@ func (s *SocketHeahthCrawler) getConnection(params map[string]interface{}) (net.
&tls.Config{
InsecureSkipVerify: true,
ServerName: ip,
ClientAuth: tls.RequestClientCert,
},
)
if err != nil {
@ -57,26 +59,28 @@ func (s *SocketHeahthCrawler) CheckHeahth(params map[string]interface{}) (bool,
}
defer conn.Close()
info := scaninfo.NewScanInfoImpl(params["ip"].(string),params["port"].(string))
if s.m.IsPrePacket() == true {
bytes := make([]byte, 1024)
n, _ := conn.Read(bytes)
p := packet.NewPacket(bytes, n)
if s.m.Match(0, p, nil) == false {
if s.m.Match(0, p, info) == false {
return false, nil
} else {
for i := 1; i < s.m.PacketCount(); i++ {
pack := s.m.Packet(i-1)
for i := 0; i < s.m.PacketCount(); i++ {
pack := s.m.Packet(i)
conn.Write(pack.Buffer)
bytes := make([]byte, 1024)
n, _ := conn.Read(bytes)
if s.m.IsNoResponse(i) == true { // empty last response
if s.m.IsNoResponse(i+1) == true { // empty last response
break
}
p := packet.NewPacket(bytes, n)
if s.m.Match(i, p, nil) == false {
if s.m.Match(i+1, p, info) == false {
return false, nil
}
}
@ -95,7 +99,7 @@ func (s *SocketHeahthCrawler) CheckHeahth(params map[string]interface{}) (bool,
}
p := packet.NewPacket(bytes, n)
if s.m.Match(i, p, nil) == false {
if s.m.Match(i, p, info) == false {
return false, nil
}
}