From a1a8d24728deedf89067e100da2ac1be58914f16 Mon Sep 17 00:00:00 2001 From: "jackdaw@loafle.com" Date: Tue, 11 Apr 2017 17:42:02 +0900 Subject: [PATCH] . --- const.go | 37 +++++++++++++++++++++++++++++++++++++ crawler.go | 2 ++ socket_health_crawler.go | 18 +++++++++++------- 3 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 const.go diff --git a/const.go b/const.go new file mode 100644 index 0000000..49af42c --- /dev/null +++ b/const.go @@ -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 +) diff --git a/crawler.go b/crawler.go index 7e8e2b6..4f63fb5 100644 --- a/crawler.go +++ b/crawler.go @@ -4,6 +4,8 @@ import ( "loafle.com/overflow/of_rpc_go/models/param" ) + + type Internal interface { Internal(params map[string]interface{}) (param.Output, error) } diff --git a/socket_health_crawler.go b/socket_health_crawler.go index d0421ac..a2584c7 100644 --- a/socket_health_crawler.go +++ b/socket_health_crawler.go @@ -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 { @@ -56,27 +58,29 @@ func (s *SocketHeahthCrawler) CheckHeahth(params map[string]interface{}) (bool, return false, err } 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 } }