.
This commit is contained in:
commit
dcadee05a3
61
.gitignore
vendored
Normal file
61
.gitignore
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
# Created by .ignore support plugin (hsz.mobi)
|
||||
### Go template
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, build with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
|
||||
.glide/
|
||||
### JetBrains template
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff:
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/dictionaries
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.xml
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
|
||||
# Gradle:
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Mongo Explorer plugin:
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
## File-based project format:
|
||||
*.iws
|
||||
|
||||
## Plugin-specific files:
|
||||
|
||||
# IntelliJ
|
||||
/out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
67
network_crawler.go
Normal file
67
network_crawler.go
Normal file
|
@ -0,0 +1,67 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"loafle.com/overflow/activedirectory_protocol_crawler_go"
|
||||
"loafle.com/overflow/crawler_go"
|
||||
"loafle.com/overflow/dns_protocol_crawler_go"
|
||||
"loafle.com/overflow/ftp_protocol_crawler_go"
|
||||
"loafle.com/overflow/ftps_protocol_crawler_go"
|
||||
"loafle.com/overflow/imap_protocol_crawler_go"
|
||||
"loafle.com/overflow/ldap_protocol_crawler_go"
|
||||
"loafle.com/overflow/mongodb_protocol_crawler_go"
|
||||
"loafle.com/overflow/mssql_protocol_crawler_go"
|
||||
"loafle.com/overflow/mysql_protocol_crawler_go"
|
||||
"loafle.com/overflow/netbios_protocol_crawler_go"
|
||||
"loafle.com/overflow/of_rpc_go"
|
||||
"loafle.com/overflow/oracle_protocol_crawler_go"
|
||||
"loafle.com/overflow/pgsql_protocol_crawler_go"
|
||||
"loafle.com/overflow/pop3_protocol_crawler_go"
|
||||
"loafle.com/overflow/redis_protocol_crawler_go"
|
||||
"loafle.com/overflow/rmi_protocol_crawler_go"
|
||||
"loafle.com/overflow/smb_protocol_crawler_go"
|
||||
"loafle.com/overflow/smtp_protocol_crawler_go"
|
||||
"loafle.com/overflow/snmpv2c_protocol_crawler_go"
|
||||
"loafle.com/overflow/snmpv3_protocol_crawler_go"
|
||||
"loafle.com/overflow/ssh_protocol_crawler_go"
|
||||
"loafle.com/overflow/telnet_protocol_crawler_go"
|
||||
"loafle.com/overflow/wmi_protocol_crawler_go"
|
||||
"log"
|
||||
)
|
||||
|
||||
func initCrawlers() {
|
||||
of_rpc.AddDelegate(crawler.ACTIVEDIRECTORY.String(), activedirectory_protocol_crawler_go.NewActiveDirectoryHealthCrawler())
|
||||
of_rpc.AddDelegate(crawler.DNS.String(), dns_protocol_crawler_go.NewDNSHealthCrawler())
|
||||
of_rpc.AddDelegate(crawler.FTP.String(), ftp_protocol_crawler_go.NewFTPHealthCrawler())
|
||||
of_rpc.AddDelegate(crawler.FTPS.String(), ftps_protocol_crawler_go.NewFTPSHealthCrawler())
|
||||
of_rpc.AddDelegate(crawler.IMAP.String(), imap_protocol_crawler_go.NewIMAPHealthCrawler())
|
||||
of_rpc.AddDelegate(crawler.LDAP.String(), ldap_protocol_crawler_go.NewLDAPHealthCrawler())
|
||||
of_rpc.AddDelegate(crawler.MONGODB.String(), mongodb_protocol_crawler_go.NewMongoDBHealthCrawler())
|
||||
of_rpc.AddDelegate(crawler.MSSQL.String(), mssql_protocol_crawler_go.NewMSSqlHeahthCrawler())
|
||||
of_rpc.AddDelegate(crawler.MYSQL.String(), mysql_protocol_crawler_go.NewMysqlHeahthCrawler())
|
||||
of_rpc.AddDelegate(crawler.MARIADB.String(), mysql_protocol_crawler_go.NewMysqlHeahthCrawler())
|
||||
of_rpc.AddDelegate(crawler.PGSQL.String(), pgsql_protocol_crawler_go.NewPGSqlHeahthCrawler())
|
||||
of_rpc.AddDelegate(crawler.NETBIOS.String(), netbios_protocol_crawler_go.NewNetbiosHeahthCrawler())
|
||||
of_rpc.AddDelegate(crawler.ORACLE.String(), oracle_protocol_crawler_go.NewOracleHeahthCrawler())
|
||||
of_rpc.AddDelegate(crawler.POP3.String(), pop3_protocol_crawler_go.NewPOP3HeahthCrawler())
|
||||
of_rpc.AddDelegate(crawler.REDIS.String(), redis_protocol_crawler_go.NewRedisHeahthCrawler())
|
||||
of_rpc.AddDelegate(crawler.RMI.String(), rmi_protocol_crawler_go.NewRMIHeahthCrawler())
|
||||
of_rpc.AddDelegate(crawler.SMB.String(), smb_protocol_crawler_go.NewSMBHeahthCrawler())
|
||||
of_rpc.AddDelegate(crawler.SMTP.String(), smtp_protocol_crawler_go.NewSMTPHeahthCrawler())
|
||||
of_rpc.AddDelegate(crawler.SNMPV2C.String(), snmpv2c_protocol_crawler_go.NewSNMPV2CHeahthCrawler())
|
||||
of_rpc.AddDelegate(crawler.SNMPV3.String(), snmpv3_protocol_crawler_go.NewSNMPV3HeahthCrawler())
|
||||
of_rpc.AddDelegate(crawler.SSH.String(), ssh_protocol_crawler_go.NewSSHHeahthCrawler())
|
||||
of_rpc.AddDelegate(crawler.TELNET.String(), telnet_protocol_crawler_go.NewTelnetHeahthCrawler())
|
||||
of_rpc.AddDelegate(crawler.WMI.String(), wmi_protocol_crawler_go.NewWMIHeahthCrawler())
|
||||
}
|
||||
|
||||
func start() {
|
||||
err := of_rpc.StartJSONRPC()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
initCrawlers()
|
||||
start()
|
||||
}
|
97
network_crawler_test.go
Normal file
97
network_crawler_test.go
Normal file
|
@ -0,0 +1,97 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"loafle.com/overflow/crawler_go"
|
||||
"loafle.com/overflow/of_rpc_go"
|
||||
"loafle.com/overflow/of_rpc_go/client"
|
||||
"loafle.com/overflow/of_rpc_go/models/param"
|
||||
"loafle.com/overflow/redis_protocol_crawler_go"
|
||||
"testing"
|
||||
"time"
|
||||
"loafle.com/overflow/ftps_protocol_crawler_go"
|
||||
"loafle.com/overflow/imap_protocol_crawler_go"
|
||||
)
|
||||
|
||||
type configcall func()
|
||||
|
||||
////////////////////////////////////// redis rpc test start -->
|
||||
func TestRedis(t *testing.T) {
|
||||
go initTestServer(func() {
|
||||
c := of_rpc.GetCrawler(crawler.REDIS.String()).(*redis_protocol_crawler_go.RedisHeahthCrawler)
|
||||
m := make(map[string]interface{}, 0)
|
||||
m["ip"] = "192.168.1.104"
|
||||
m["port"] = "6379"
|
||||
m["portType"] = "tcp"
|
||||
m["ssl"] = false
|
||||
c.PutConfig("test_redis_sid", m)
|
||||
})
|
||||
time.Sleep(2 * time.Second)
|
||||
in := param.Input{
|
||||
Name: crawler.REDIS.String(),
|
||||
Id: "test_redis_sid",
|
||||
}
|
||||
checkhealth(t, in)
|
||||
}
|
||||
////////////////////////////////////// redis rpc test end <--
|
||||
|
||||
////////////////////////////////////// imap rpc test start -->
|
||||
func TestImap(t *testing.T) {
|
||||
go initTestServer(func() {
|
||||
c := of_rpc.GetCrawler(crawler.IMAP.String()).(*imap_protocol_crawler_go.IMAPHealthCrawler)
|
||||
m := make(map[string]interface{}, 0)
|
||||
m["ip"] = "192.168.1.215"
|
||||
m["port"] = "993"
|
||||
m["portType"] = "tcp"
|
||||
m["ssl"] = true
|
||||
c.PutConfig("test_imap_sid", m)
|
||||
})
|
||||
time.Sleep(2 * time.Second)
|
||||
in := param.Input{
|
||||
Name: crawler.IMAP.String(),
|
||||
Id: "test_imap_sid",
|
||||
}
|
||||
checkhealth(t, in)
|
||||
}
|
||||
////////////////////////////////////// imap rpc test end <--
|
||||
|
||||
////////////////////////////////////// ftp rpc test start -->
|
||||
func TestFTP(t *testing.T) {
|
||||
go initTestServer(func() {
|
||||
c := of_rpc.GetCrawler(crawler.FTPS.String()).(*ftps_protocol_crawler_go.FTPSHealthCrawler)
|
||||
m := make(map[string]interface{}, 0)
|
||||
m["ip"] = "192.168.1.103"
|
||||
m["port"] = "2121"
|
||||
m["portType"] = "tcp"
|
||||
m["ssl"] = false
|
||||
c.PutConfig("test_ftps_sid", m)
|
||||
})
|
||||
time.Sleep(2 * time.Second)
|
||||
in := param.Input{
|
||||
Name: crawler.FTPS.String(),
|
||||
Id: "test_ftps_sid",
|
||||
}
|
||||
checkhealth(t, in)
|
||||
}
|
||||
////////////////////////////////////// ftp rpc test end <--
|
||||
|
||||
|
||||
|
||||
func initTestServer(config configcall) {
|
||||
initCrawlers()
|
||||
config()
|
||||
start()
|
||||
}
|
||||
|
||||
func checkhealth(t *testing.T, in param.Input) {
|
||||
result, err := client.InvokeJSONRPCGet("50000", in)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
var check bool
|
||||
json.Unmarshal(result.Data, &check)
|
||||
assert.Equal(t, true, check)
|
||||
}
|
Loading…
Reference in New Issue
Block a user