glide error
This commit is contained in:
parent
f5dffb050d
commit
464eeb2094
@ -1,17 +1,21 @@
|
|||||||
package activedirectory_protocol_crawler
|
package activedirectory_protocol_crawler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
"git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"log"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//import (
|
||||||
|
// "encoding/json"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
|
// "github.com/stretchr/testify/assert"
|
||||||
|
// "log"
|
||||||
|
// "testing"
|
||||||
|
// "time"
|
||||||
|
//)
|
||||||
|
|
||||||
//import (
|
//import (
|
||||||
// "encoding/json"
|
// "encoding/json"
|
||||||
// "github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
@ -65,45 +69,45 @@ func setConfig() crawler.Crawler {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMatch(t *testing.T) {
|
//func TestMatch(t *testing.T) {
|
||||||
// test config
|
// // test config
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
out := param.Output{}
|
// out := param.Output{}
|
||||||
r.Get("ad", &out)
|
// r.Get("ad", &out)
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(out.Data, &check)
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func start() {
|
//func start() {
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
of_rpc.AddDelegate("ad", r)
|
// of_rpc.AddDelegate("ad", r)
|
||||||
err := of_rpc.StartJSONRPC()
|
// err := of_rpc.StartJSONRPC()
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Fatal(err)
|
// log.Fatal(err)
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestRPC(t *testing.T) {
|
//func TestRPC(t *testing.T) {
|
||||||
go start()
|
// go start()
|
||||||
time.Sleep(2 * time.Second)
|
// time.Sleep(2 * time.Second)
|
||||||
|
//
|
||||||
in := param.Input{
|
// in := param.Input{
|
||||||
Name: "ad",
|
// Name: "ad",
|
||||||
Id: "ad",
|
// Id: "ad",
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
result, err := client.InvokeJSONRPCGet("50000", in)
|
// result, err := client.InvokeJSONRPCGet("50000", in)
|
||||||
|
//
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
t.Fatal(err)
|
// t.Fatal(err)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(result.Data, &check)
|
// json.Unmarshal(result.Data, &check)
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
@ -1,104 +1,104 @@
|
|||||||
package cassandra_protocol_crawler
|
package cassandra_protocol_crawler
|
||||||
|
//
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"log"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setConfig() crawler.Crawler {
|
|
||||||
|
|
||||||
r := NewCassandraHealthCrawler()
|
|
||||||
|
|
||||||
m := make(map[string]interface{}, 0)
|
|
||||||
|
|
||||||
m["ip"] = "192.168.1.104"
|
|
||||||
m["port"] = "9042"
|
|
||||||
m["portType"] = "tcp"
|
|
||||||
m["ssl"] = false
|
|
||||||
|
|
||||||
r.PutConfig("ad", m)
|
|
||||||
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatch(t *testing.T) {
|
|
||||||
// test config
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
out := param.Output{}
|
|
||||||
r.Get("ad", &out)
|
|
||||||
|
|
||||||
var check bool
|
|
||||||
json.Unmarshal(out.Data, &check)
|
|
||||||
|
|
||||||
assert.Equal(t, true, check)
|
|
||||||
}
|
|
||||||
|
|
||||||
func start() {
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
of_rpc.AddDelegate("ad", r)
|
|
||||||
err := of_rpc.StartJSONRPC()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRPC(t *testing.T) {
|
|
||||||
go start()
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
|
|
||||||
in := param.Input{
|
|
||||||
Name: "ad",
|
|
||||||
Id: "ad",
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
//import (
|
//import (
|
||||||
// "encoding/json"
|
// "encoding/json"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
// "github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
// "git.loafle.net/overflow/of_rpc/json/client"
|
// "log"
|
||||||
// "git.loafle.net/overflow/of_rpc/models/param"
|
|
||||||
// "git.loafle.net/overflow/of_rpc/models/protocol"
|
|
||||||
// "testing"
|
// "testing"
|
||||||
// "time"
|
// "time"
|
||||||
//)
|
//)
|
||||||
//
|
//
|
||||||
//func TestCheck(t *testing.T) {
|
//func setConfig() crawler.Crawler {
|
||||||
// b, _ := check("192.168.1.104", 9042, true)
|
//
|
||||||
// assert.Equal(t, true, b)
|
// r := NewCassandraHealthCrawler()
|
||||||
|
//
|
||||||
|
// m := make(map[string]interface{}, 0)
|
||||||
|
//
|
||||||
|
// m["ip"] = "192.168.1.104"
|
||||||
|
// m["port"] = "9042"
|
||||||
|
// m["portType"] = "tcp"
|
||||||
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
|
// r.PutConfig("ad", m)
|
||||||
|
//
|
||||||
|
// return r
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func TestMatch(t *testing.T) {
|
||||||
|
// // test config
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// out := param.Output{}
|
||||||
|
// r.Get("ad", &out)
|
||||||
|
//
|
||||||
|
// var check bool
|
||||||
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func start() {
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// of_rpc.AddDelegate("ad", r)
|
||||||
|
// err := of_rpc.StartJSONRPC()
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// }
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//func TestRPC(t *testing.T) {
|
//func TestRPC(t *testing.T) {
|
||||||
//
|
|
||||||
// go start()
|
// go start()
|
||||||
// time.Sleep(time.Second * 2)
|
// time.Sleep(2 * time.Second)
|
||||||
//
|
//
|
||||||
// p := protocol.HealthRequest{IsSSL: true}
|
// in := param.Input{
|
||||||
// b, _ := json.Marshal(p)
|
// Name: "ad",
|
||||||
|
// Id: "ad",
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// in := param.Input{Ip: "192.168.1.104", Port: 9042, Data: b}
|
// result, err := client.InvokeJSONRPCGet("50000", in)
|
||||||
//
|
//
|
||||||
// re, _ := client.InvokeJSONRPC("50000", in)
|
// if err != nil {
|
||||||
// var m protocol.HeahthResponse
|
// t.Fatal(err)
|
||||||
// json.Unmarshal(re.Data, &m)
|
// }
|
||||||
//
|
//
|
||||||
// assert.Equal(t, true, m.IsMatch)
|
// var check bool
|
||||||
|
// json.Unmarshal(result.Data, &check)
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
|
////import (
|
||||||
|
//// "encoding/json"
|
||||||
|
//// "github.com/stretchr/testify/assert"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/json/client"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/models/param"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/models/protocol"
|
||||||
|
//// "testing"
|
||||||
|
//// "time"
|
||||||
|
////)
|
||||||
|
////
|
||||||
|
////func TestCheck(t *testing.T) {
|
||||||
|
//// b, _ := check("192.168.1.104", 9042, true)
|
||||||
|
//// assert.Equal(t, true, b)
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func TestRPC(t *testing.T) {
|
||||||
|
////
|
||||||
|
//// go start()
|
||||||
|
//// time.Sleep(time.Second * 2)
|
||||||
|
////
|
||||||
|
//// p := protocol.HealthRequest{IsSSL: true}
|
||||||
|
//// b, _ := json.Marshal(p)
|
||||||
|
////
|
||||||
|
//// in := param.Input{Ip: "192.168.1.104", Port: 9042, Data: b}
|
||||||
|
////
|
||||||
|
//// re, _ := client.InvokeJSONRPC("50000", in)
|
||||||
|
//// var m protocol.HeahthResponse
|
||||||
|
//// json.Unmarshal(re.Data, &m)
|
||||||
|
////
|
||||||
|
//// assert.Equal(t, true, m.IsMatch)
|
||||||
|
////}
|
||||||
|
@ -1,104 +1,104 @@
|
|||||||
package dns_protocol_crawler
|
package dns_protocol_crawler
|
||||||
|
//
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"log"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setConfig() crawler.Crawler {
|
|
||||||
|
|
||||||
r := NewDNSHealthCrawler()
|
|
||||||
|
|
||||||
m := make(map[string]interface{}, 0)
|
|
||||||
|
|
||||||
m["ip"] = "192.168.1.215"
|
|
||||||
m["port"] = "53"
|
|
||||||
m["portType"] = "udp"
|
|
||||||
m["ssl"] = false
|
|
||||||
|
|
||||||
r.PutConfig("ad", m)
|
|
||||||
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatch(t *testing.T) {
|
|
||||||
// test config
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
out := param.Output{}
|
|
||||||
r.Get("ad", &out)
|
|
||||||
|
|
||||||
var check bool
|
|
||||||
json.Unmarshal(out.Data, &check)
|
|
||||||
|
|
||||||
assert.Equal(t, true, check)
|
|
||||||
}
|
|
||||||
|
|
||||||
func start() {
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
of_rpc.AddDelegate("ad", r)
|
|
||||||
err := of_rpc.StartJSONRPC()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRPC(t *testing.T) {
|
|
||||||
go start()
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
|
|
||||||
in := param.Input{
|
|
||||||
Name: "ad",
|
|
||||||
Id: "ad",
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
//import (
|
//import (
|
||||||
// "encoding/json"
|
// "encoding/json"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
// "github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
// "git.loafle.net/overflow/of_rpc/json/client"
|
// "log"
|
||||||
// "git.loafle.net/overflow/of_rpc/models/param"
|
|
||||||
// "git.loafle.net/overflow/of_rpc/models/protocol"
|
|
||||||
// "testing"
|
// "testing"
|
||||||
// "time"
|
// "time"
|
||||||
//)
|
//)
|
||||||
//
|
//
|
||||||
//func TestCheck(t *testing.T) {
|
//func setConfig() crawler.Crawler {
|
||||||
// b, _ := check("192.168.1.215", 53, false)
|
//
|
||||||
// assert.Equal(t, true, b)
|
// r := NewDNSHealthCrawler()
|
||||||
|
//
|
||||||
|
// m := make(map[string]interface{}, 0)
|
||||||
|
//
|
||||||
|
// m["ip"] = "192.168.1.215"
|
||||||
|
// m["port"] = "53"
|
||||||
|
// m["portType"] = "udp"
|
||||||
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
|
// r.PutConfig("ad", m)
|
||||||
|
//
|
||||||
|
// return r
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func TestMatch(t *testing.T) {
|
||||||
|
// // test config
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// out := param.Output{}
|
||||||
|
// r.Get("ad", &out)
|
||||||
|
//
|
||||||
|
// var check bool
|
||||||
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func start() {
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// of_rpc.AddDelegate("ad", r)
|
||||||
|
// err := of_rpc.StartJSONRPC()
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// }
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//func TestRPC(t *testing.T) {
|
//func TestRPC(t *testing.T) {
|
||||||
//
|
|
||||||
// go start()
|
// go start()
|
||||||
// time.Sleep(time.Second * 2)
|
// time.Sleep(2 * time.Second)
|
||||||
//
|
//
|
||||||
// p := protocol.HealthRequest{IsSSL: false}
|
// in := param.Input{
|
||||||
// b, _ := json.Marshal(p)
|
// Name: "ad",
|
||||||
|
// Id: "ad",
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// in := param.Input{Ip: "192.168.1.215", Port: 53, Data: b}
|
// result, err := client.InvokeJSONRPCGet("50000", in)
|
||||||
//
|
//
|
||||||
// re, _ := client.InvokeJSONRPC("50000", in)
|
// if err != nil {
|
||||||
// var m protocol.HealthResponse
|
// t.Fatal(err)
|
||||||
// json.Unmarshal(re.Data, &m)
|
// }
|
||||||
//
|
//
|
||||||
// assert.Equal(t, true, m.IsMatch)
|
// var check bool
|
||||||
|
// json.Unmarshal(result.Data, &check)
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
|
////import (
|
||||||
|
//// "encoding/json"
|
||||||
|
//// "github.com/stretchr/testify/assert"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/json/client"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/models/param"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/models/protocol"
|
||||||
|
//// "testing"
|
||||||
|
//// "time"
|
||||||
|
////)
|
||||||
|
////
|
||||||
|
////func TestCheck(t *testing.T) {
|
||||||
|
//// b, _ := check("192.168.1.215", 53, false)
|
||||||
|
//// assert.Equal(t, true, b)
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func TestRPC(t *testing.T) {
|
||||||
|
////
|
||||||
|
//// go start()
|
||||||
|
//// time.Sleep(time.Second * 2)
|
||||||
|
////
|
||||||
|
//// p := protocol.HealthRequest{IsSSL: false}
|
||||||
|
//// b, _ := json.Marshal(p)
|
||||||
|
////
|
||||||
|
//// in := param.Input{Ip: "192.168.1.215", Port: 53, Data: b}
|
||||||
|
////
|
||||||
|
//// re, _ := client.InvokeJSONRPC("50000", in)
|
||||||
|
//// var m protocol.HealthResponse
|
||||||
|
//// json.Unmarshal(re.Data, &m)
|
||||||
|
////
|
||||||
|
//// assert.Equal(t, true, m.IsMatch)
|
||||||
|
////}
|
||||||
|
@ -1,93 +1,93 @@
|
|||||||
package ftp_protocol_crawler
|
package ftp_protocol_crawler
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"log"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setConfig() crawler.Crawler {
|
|
||||||
r := NewFTPHealthCrawler()
|
|
||||||
m := make(map[string]interface{}, 0)
|
|
||||||
|
|
||||||
m["ip"] = "192.168.1.215"
|
|
||||||
m["port"] = "21"
|
|
||||||
m["portType"] = "tcp"
|
|
||||||
m["ssl"] = false
|
|
||||||
|
|
||||||
r.PutConfig("ftp", m)
|
|
||||||
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatch(t *testing.T) {
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
out := param.Output{}
|
|
||||||
r.Get("ftp", &out)
|
|
||||||
|
|
||||||
var check bool
|
|
||||||
json.Unmarshal(out.Data, &check)
|
|
||||||
|
|
||||||
assert.Equal(t, true, check)
|
|
||||||
}
|
|
||||||
|
|
||||||
func start() {
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
of_rpc.AddDelegate("ftp", r)
|
|
||||||
err := of_rpc.StartJSONRPC()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRPC(t *testing.T) {
|
|
||||||
go start()
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
|
|
||||||
in := param.Input{
|
|
||||||
Name: "ftp",
|
|
||||||
Id: "ftp",
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//func TestCheck(t *testing.T) {
|
//import (
|
||||||
// b, _ := check("192.168.1.215", 21, false)
|
// "encoding/json"
|
||||||
// assert.Equal(t, true, b)
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
|
// "github.com/stretchr/testify/assert"
|
||||||
|
// "log"
|
||||||
|
// "testing"
|
||||||
|
// "time"
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//func setConfig() crawler.Crawler {
|
||||||
|
// r := NewFTPHealthCrawler()
|
||||||
|
// m := make(map[string]interface{}, 0)
|
||||||
|
//
|
||||||
|
// m["ip"] = "192.168.1.215"
|
||||||
|
// m["port"] = "21"
|
||||||
|
// m["portType"] = "tcp"
|
||||||
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
|
// r.PutConfig("ftp", m)
|
||||||
|
//
|
||||||
|
// return r
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
|
//func TestMatch(t *testing.T) {
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// out := param.Output{}
|
||||||
|
// r.Get("ftp", &out)
|
||||||
|
//
|
||||||
|
// var check bool
|
||||||
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func start() {
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// of_rpc.AddDelegate("ftp", r)
|
||||||
|
// err := of_rpc.StartJSONRPC()
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// }
|
||||||
|
//}
|
||||||
//
|
//
|
||||||
//func TestRPC(t *testing.T) {
|
//func TestRPC(t *testing.T) {
|
||||||
//
|
|
||||||
// go start()
|
// go start()
|
||||||
// time.Sleep(time.Second * 2)
|
// time.Sleep(2 * time.Second)
|
||||||
//
|
//
|
||||||
// p := protocol.HealthRequest{IsSSL: false}
|
// in := param.Input{
|
||||||
// b, _ := json.Marshal(p)
|
// Name: "ftp",
|
||||||
|
// Id: "ftp",
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// in := param.Input{Ip: "192.168.1.215", Port: 21, Data: b}
|
// result, err := client.InvokeJSONRPCGet("50000", in)
|
||||||
//
|
//
|
||||||
// re, _ := client.InvokeJSONRPC("50000", in)
|
// if err != nil {
|
||||||
// var m protocol.HealthResponse
|
// t.Fatal(err)
|
||||||
// json.Unmarshal(re.Data, &m)
|
// }
|
||||||
//
|
//
|
||||||
// assert.Equal(t, true, m.IsMatch)
|
// var check bool
|
||||||
|
// json.Unmarshal(result.Data, &check)
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
|
////
|
||||||
|
////func TestCheck(t *testing.T) {
|
||||||
|
//// b, _ := check("192.168.1.215", 21, false)
|
||||||
|
//// assert.Equal(t, true, b)
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////
|
||||||
|
////func TestRPC(t *testing.T) {
|
||||||
|
////
|
||||||
|
//// go start()
|
||||||
|
//// time.Sleep(time.Second * 2)
|
||||||
|
////
|
||||||
|
//// p := protocol.HealthRequest{IsSSL: false}
|
||||||
|
//// b, _ := json.Marshal(p)
|
||||||
|
////
|
||||||
|
//// in := param.Input{Ip: "192.168.1.215", Port: 21, Data: b}
|
||||||
|
////
|
||||||
|
//// re, _ := client.InvokeJSONRPC("50000", in)
|
||||||
|
//// var m protocol.HealthResponse
|
||||||
|
//// json.Unmarshal(re.Data, &m)
|
||||||
|
////
|
||||||
|
//// assert.Equal(t, true, m.IsMatch)
|
||||||
|
////}
|
||||||
|
@ -1,87 +1,87 @@
|
|||||||
package ftps_protocol_crawler
|
package ftps_protocol_crawler
|
||||||
|
//
|
||||||
import (
|
//import (
|
||||||
"encoding/json"
|
// "encoding/json"
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
"github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
"log"
|
// "log"
|
||||||
"testing"
|
// "testing"
|
||||||
"time"
|
// "time"
|
||||||
)
|
//)
|
||||||
|
//
|
||||||
func setConfig() crawler.Crawler {
|
//func setConfig() crawler.Crawler {
|
||||||
r := NewFTPSHealthCrawler()
|
// r := NewFTPSHealthCrawler()
|
||||||
m := make(map[string]interface{}, 0)
|
// m := make(map[string]interface{}, 0)
|
||||||
|
//
|
||||||
m["ip"] = "192.168.1.103"
|
// m["ip"] = "192.168.1.103"
|
||||||
m["port"] = "2121"
|
// m["port"] = "2121"
|
||||||
m["portType"] = "tcp"
|
// m["portType"] = "tcp"
|
||||||
m["ssl"] = false
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
r.PutConfig("ftps", m)
|
// r.PutConfig("ftps", m)
|
||||||
|
//
|
||||||
return r
|
// return r
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestMatch(t *testing.T) {
|
//func TestMatch(t *testing.T) {
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
out := param.Output{}
|
// out := param.Output{}
|
||||||
r.Get("ftps", &out)
|
// r.Get("ftps", &out)
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(out.Data, &check)
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func start() {
|
//func start() {
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
of_rpc.AddDelegate("ftps", r)
|
// of_rpc.AddDelegate("ftps", r)
|
||||||
err := of_rpc.StartJSONRPC()
|
// err := of_rpc.StartJSONRPC()
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Fatal(err)
|
// log.Fatal(err)
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
func TestRPC(t *testing.T) {
|
|
||||||
go start()
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
|
|
||||||
in := param.Input{
|
|
||||||
Name: "ftps",
|
|
||||||
Id: "ftps",
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//func TestRPC(t *testing.T) {
|
//func TestRPC(t *testing.T) {
|
||||||
//
|
|
||||||
// go start()
|
// go start()
|
||||||
// time.Sleep(time.Second * 2)
|
// time.Sleep(2 * time.Second)
|
||||||
//
|
//
|
||||||
// p := protocol.HealthRequest{IsSSL: false}
|
// in := param.Input{
|
||||||
// b, _ := json.Marshal(p)
|
// Name: "ftps",
|
||||||
|
// Id: "ftps",
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// in := param.Input{Ip: "192.168.1.215", Port: 21, Data: b}
|
// result, err := client.InvokeJSONRPCGet("50000", in)
|
||||||
//
|
//
|
||||||
// re, _ := client.InvokeJSONRPC("50000", in)
|
// if err != nil {
|
||||||
// var m protocol.HealthResponse
|
// t.Fatal(err)
|
||||||
// json.Unmarshal(re.Data, &m)
|
// }
|
||||||
//
|
//
|
||||||
// assert.Equal(t, false, m.IsMatch)
|
// var check bool
|
||||||
|
// json.Unmarshal(result.Data, &check)
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
|
////
|
||||||
|
////func TestRPC(t *testing.T) {
|
||||||
|
////
|
||||||
|
//// go start()
|
||||||
|
//// time.Sleep(time.Second * 2)
|
||||||
|
////
|
||||||
|
//// p := protocol.HealthRequest{IsSSL: false}
|
||||||
|
//// b, _ := json.Marshal(p)
|
||||||
|
////
|
||||||
|
//// in := param.Input{Ip: "192.168.1.215", Port: 21, Data: b}
|
||||||
|
////
|
||||||
|
//// re, _ := client.InvokeJSONRPC("50000", in)
|
||||||
|
//// var m protocol.HealthResponse
|
||||||
|
//// json.Unmarshal(re.Data, &m)
|
||||||
|
////
|
||||||
|
//// assert.Equal(t, false, m.IsMatch)
|
||||||
|
////}
|
||||||
|
@ -1,87 +1,87 @@
|
|||||||
package http_protocol_crawler
|
package http_protocol_crawler
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"log"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setConfig() crawler.Crawler {
|
|
||||||
|
|
||||||
r := NewHTTPHealthCrawler()
|
|
||||||
|
|
||||||
m := make(map[string]interface{}, 0)
|
|
||||||
|
|
||||||
m["ip"] = "192.168.1.105"
|
|
||||||
m["port"] = "80"
|
|
||||||
m["portType"] = "tcp"
|
|
||||||
m["ssl"] = false
|
|
||||||
|
|
||||||
r.PutConfig("ad", m)
|
|
||||||
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatch(t *testing.T) {
|
|
||||||
// test config
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
out := param.Output{}
|
|
||||||
r.Get("ad", &out)
|
|
||||||
|
|
||||||
var check bool
|
|
||||||
json.Unmarshal(out.Data, &check)
|
|
||||||
|
|
||||||
assert.Equal(t, true, check)
|
|
||||||
}
|
|
||||||
|
|
||||||
func start() {
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
of_rpc.AddDelegate("ad", r)
|
|
||||||
err := of_rpc.StartJSONRPC()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRPC(t *testing.T) {
|
|
||||||
go start()
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
|
|
||||||
in := param.Input{
|
|
||||||
Name: "ad",
|
|
||||||
Id: "ad",
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
//package main
|
|
||||||
//
|
//
|
||||||
//import (
|
//import (
|
||||||
// "testing"
|
// "encoding/json"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
// "github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
|
// "log"
|
||||||
|
// "testing"
|
||||||
|
// "time"
|
||||||
//)
|
//)
|
||||||
//
|
//
|
||||||
//func TestHttpProtocol_Get(t *testing.T) {
|
//func setConfig() crawler.Crawler {
|
||||||
// b, err := check("192.168.1.105", 80)
|
//
|
||||||
// if err != nil {
|
// r := NewHTTPHealthCrawler()
|
||||||
// t.Error(err)
|
//
|
||||||
// }
|
// m := make(map[string]interface{}, 0)
|
||||||
// assert.Equal(t, true, b)
|
//
|
||||||
|
// m["ip"] = "192.168.1.105"
|
||||||
|
// m["port"] = "80"
|
||||||
|
// m["portType"] = "tcp"
|
||||||
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
|
// r.PutConfig("ad", m)
|
||||||
|
//
|
||||||
|
// return r
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
|
//func TestMatch(t *testing.T) {
|
||||||
|
// // test config
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// out := param.Output{}
|
||||||
|
// r.Get("ad", &out)
|
||||||
|
//
|
||||||
|
// var check bool
|
||||||
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func start() {
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// of_rpc.AddDelegate("ad", r)
|
||||||
|
// err := of_rpc.StartJSONRPC()
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func TestRPC(t *testing.T) {
|
||||||
|
// go start()
|
||||||
|
// time.Sleep(2 * time.Second)
|
||||||
|
//
|
||||||
|
// in := param.Input{
|
||||||
|
// Name: "ad",
|
||||||
|
// Id: "ad",
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// 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)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
////package main
|
||||||
|
////
|
||||||
|
////import (
|
||||||
|
//// "testing"
|
||||||
|
//// "github.com/stretchr/testify/assert"
|
||||||
|
////)
|
||||||
|
////
|
||||||
|
////func TestHttpProtocol_Get(t *testing.T) {
|
||||||
|
//// b, err := check("192.168.1.105", 80)
|
||||||
|
//// if err != nil {
|
||||||
|
//// t.Error(err)
|
||||||
|
//// }
|
||||||
|
//// assert.Equal(t, true, b)
|
||||||
|
////}
|
||||||
|
@ -1,75 +1,75 @@
|
|||||||
package imap_protocol_crawler
|
package imap_protocol_crawler
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"encoding/json"
|
// "encoding/json"
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
"github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
"log"
|
// "log"
|
||||||
"testing"
|
// "testing"
|
||||||
"time"
|
// "time"
|
||||||
)
|
//)
|
||||||
|
//
|
||||||
func setConfig() crawler.Crawler {
|
//func setConfig() crawler.Crawler {
|
||||||
|
//
|
||||||
r := NewIMAPHealthCrawler()
|
// r := NewIMAPHealthCrawler()
|
||||||
|
//
|
||||||
m := make(map[string]interface{}, 0)
|
// m := make(map[string]interface{}, 0)
|
||||||
|
//
|
||||||
m["ip"] = "192.168.1.215"
|
// m["ip"] = "192.168.1.215"
|
||||||
m["port"] = "993"
|
// m["port"] = "993"
|
||||||
m["portType"] = "tcp"
|
// m["portType"] = "tcp"
|
||||||
m["ssl"] = true
|
// m["ssl"] = true
|
||||||
|
//
|
||||||
r.PutConfig("ad", m)
|
// r.PutConfig("ad", m)
|
||||||
|
//
|
||||||
return r
|
// return r
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestMatch(t *testing.T) {
|
//func TestMatch(t *testing.T) {
|
||||||
// test config
|
// // test config
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
out := param.Output{}
|
// out := param.Output{}
|
||||||
r.Get("ad", &out)
|
// r.Get("ad", &out)
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(out.Data, &check)
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func start() {
|
//func start() {
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
of_rpc.AddDelegate("ad", r)
|
// of_rpc.AddDelegate("ad", r)
|
||||||
err := of_rpc.StartJSONRPC()
|
// err := of_rpc.StartJSONRPC()
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Fatal(err)
|
// log.Fatal(err)
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestRPC(t *testing.T) {
|
//func TestRPC(t *testing.T) {
|
||||||
go start()
|
// go start()
|
||||||
time.Sleep(2 * time.Second)
|
// time.Sleep(2 * time.Second)
|
||||||
|
//
|
||||||
in := param.Input{
|
// in := param.Input{
|
||||||
Name: "ad",
|
// Name: "ad",
|
||||||
Id: "ad",
|
// Id: "ad",
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
result, err := client.InvokeJSONRPCGet("50000", in)
|
// result, err := client.InvokeJSONRPCGet("50000", in)
|
||||||
|
//
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
t.Fatal(err)
|
// t.Fatal(err)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(result.Data, &check)
|
// json.Unmarshal(result.Data, &check)
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
|
||||||
//
|
//
|
||||||
//import (
|
//import (
|
||||||
|
@ -1,75 +1,75 @@
|
|||||||
package ldap_protocol_crawler
|
package ldap_protocol_crawler
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"encoding/json"
|
// "encoding/json"
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
"github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
"log"
|
// "log"
|
||||||
"testing"
|
// "testing"
|
||||||
"time"
|
// "time"
|
||||||
)
|
//)
|
||||||
|
//
|
||||||
func setConfig() crawler.Crawler {
|
//func setConfig() crawler.Crawler {
|
||||||
|
//
|
||||||
r := NewLDAPHealthCrawler()
|
// r := NewLDAPHealthCrawler()
|
||||||
|
//
|
||||||
m := make(map[string]interface{}, 0)
|
// m := make(map[string]interface{}, 0)
|
||||||
|
//
|
||||||
m["ip"] = "192.168.1.215"
|
// m["ip"] = "192.168.1.215"
|
||||||
m["port"] = "389"
|
// m["port"] = "389"
|
||||||
m["portType"] = "tcp"
|
// m["portType"] = "tcp"
|
||||||
m["ssl"] = false
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
r.PutConfig("ad", m)
|
// r.PutConfig("ad", m)
|
||||||
|
//
|
||||||
return r
|
// return r
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestMatch(t *testing.T) {
|
//func TestMatch(t *testing.T) {
|
||||||
// test config
|
// // test config
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
out := param.Output{}
|
// out := param.Output{}
|
||||||
r.Get("ad", &out)
|
// r.Get("ad", &out)
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(out.Data, &check)
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func start() {
|
//func start() {
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
of_rpc.AddDelegate("ad", r)
|
// of_rpc.AddDelegate("ad", r)
|
||||||
err := of_rpc.StartJSONRPC()
|
// err := of_rpc.StartJSONRPC()
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Fatal(err)
|
// log.Fatal(err)
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestRPC(t *testing.T) {
|
//func TestRPC(t *testing.T) {
|
||||||
go start()
|
// go start()
|
||||||
time.Sleep(2 * time.Second)
|
// time.Sleep(2 * time.Second)
|
||||||
|
//
|
||||||
in := param.Input{
|
// in := param.Input{
|
||||||
Name: "ad",
|
// Name: "ad",
|
||||||
Id: "ad",
|
// Id: "ad",
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
result, err := client.InvokeJSONRPCGet("50000", in)
|
// result, err := client.InvokeJSONRPCGet("50000", in)
|
||||||
|
//
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
t.Fatal(err)
|
// t.Fatal(err)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(result.Data, &check)
|
// json.Unmarshal(result.Data, &check)
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
|
||||||
//
|
//
|
||||||
//import (
|
//import (
|
||||||
|
@ -1,105 +1,105 @@
|
|||||||
package mongodb_protocol_crawler
|
package mongodb_protocol_crawler
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"log"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setConfig() crawler.Crawler {
|
|
||||||
|
|
||||||
r := NewMongoDBHealthCrawler()
|
|
||||||
|
|
||||||
m := make(map[string]interface{}, 0)
|
|
||||||
|
|
||||||
m["ip"] = "192.168.1.104"
|
|
||||||
m["port"] = "27017"
|
|
||||||
m["portType"] = "tcp"
|
|
||||||
m["ssl"] = false
|
|
||||||
|
|
||||||
r.PutConfig("ad", m)
|
|
||||||
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatch(t *testing.T) {
|
|
||||||
// test config
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
out := param.Output{}
|
|
||||||
r.Get("ad", &out)
|
|
||||||
|
|
||||||
var check bool
|
|
||||||
json.Unmarshal(out.Data, &check)
|
|
||||||
|
|
||||||
assert.Equal(t, true, check)
|
|
||||||
}
|
|
||||||
|
|
||||||
func start() {
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
of_rpc.AddDelegate("ad", r)
|
|
||||||
err := of_rpc.StartJSONRPC()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRPC(t *testing.T) {
|
|
||||||
go start()
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
|
|
||||||
in := param.Input{
|
|
||||||
Name: "ad",
|
|
||||||
Id: "ad",
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//import (
|
//import (
|
||||||
// "encoding/json"
|
// "encoding/json"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
// "github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
// "git.loafle.net/overflow/of_rpc/json/client"
|
// "log"
|
||||||
// "git.loafle.net/overflow/of_rpc/models/param"
|
|
||||||
// "git.loafle.net/overflow/of_rpc/models/protocol"
|
|
||||||
// "testing"
|
// "testing"
|
||||||
// "time"
|
// "time"
|
||||||
//)
|
//)
|
||||||
//
|
//
|
||||||
//func TestCheck(t *testing.T) {
|
//func setConfig() crawler.Crawler {
|
||||||
// b, _ := check("192.168.1.104", 27017, true)
|
//
|
||||||
// assert.Equal(t, true, b)
|
// r := NewMongoDBHealthCrawler()
|
||||||
|
//
|
||||||
|
// m := make(map[string]interface{}, 0)
|
||||||
|
//
|
||||||
|
// m["ip"] = "192.168.1.104"
|
||||||
|
// m["port"] = "27017"
|
||||||
|
// m["portType"] = "tcp"
|
||||||
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
|
// r.PutConfig("ad", m)
|
||||||
|
//
|
||||||
|
// return r
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func TestMatch(t *testing.T) {
|
||||||
|
// // test config
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// out := param.Output{}
|
||||||
|
// r.Get("ad", &out)
|
||||||
|
//
|
||||||
|
// var check bool
|
||||||
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func start() {
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// of_rpc.AddDelegate("ad", r)
|
||||||
|
// err := of_rpc.StartJSONRPC()
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// }
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//func TestRPC(t *testing.T) {
|
//func TestRPC(t *testing.T) {
|
||||||
//
|
|
||||||
// go start()
|
// go start()
|
||||||
// time.Sleep(time.Second * 2)
|
// time.Sleep(2 * time.Second)
|
||||||
//
|
//
|
||||||
// p := protocol.HealthRequest{IsSSL: true}
|
// in := param.Input{
|
||||||
// b, _ := json.Marshal(p)
|
// Name: "ad",
|
||||||
|
// Id: "ad",
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// in := param.Input{Ip: "192.168.1.104", Port: 27017, Data: b}
|
// result, err := client.InvokeJSONRPCGet("50000", in)
|
||||||
//
|
//
|
||||||
// re, _ := client.InvokeJSONRPC("50000", in)
|
// if err != nil {
|
||||||
// var m protocol.HealthResponse
|
// t.Fatal(err)
|
||||||
// json.Unmarshal(re.Data, &m)
|
// }
|
||||||
//
|
//
|
||||||
// assert.Equal(t, true, m.IsMatch)
|
// var check bool
|
||||||
|
// json.Unmarshal(result.Data, &check)
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
|
////
|
||||||
|
////import (
|
||||||
|
//// "encoding/json"
|
||||||
|
//// "github.com/stretchr/testify/assert"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/json/client"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/models/param"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/models/protocol"
|
||||||
|
//// "testing"
|
||||||
|
//// "time"
|
||||||
|
////)
|
||||||
|
////
|
||||||
|
////func TestCheck(t *testing.T) {
|
||||||
|
//// b, _ := check("192.168.1.104", 27017, true)
|
||||||
|
//// assert.Equal(t, true, b)
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func TestRPC(t *testing.T) {
|
||||||
|
////
|
||||||
|
//// go start()
|
||||||
|
//// time.Sleep(time.Second * 2)
|
||||||
|
////
|
||||||
|
//// p := protocol.HealthRequest{IsSSL: true}
|
||||||
|
//// b, _ := json.Marshal(p)
|
||||||
|
////
|
||||||
|
//// in := param.Input{Ip: "192.168.1.104", Port: 27017, Data: b}
|
||||||
|
////
|
||||||
|
//// re, _ := client.InvokeJSONRPC("50000", in)
|
||||||
|
//// var m protocol.HealthResponse
|
||||||
|
//// json.Unmarshal(re.Data, &m)
|
||||||
|
////
|
||||||
|
//// assert.Equal(t, true, m.IsMatch)
|
||||||
|
////}
|
||||||
|
@ -1,86 +1,86 @@
|
|||||||
package mssql_protocol_crawler
|
package mssql_protocol_crawler
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"log"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setConfig() crawler.Crawler {
|
|
||||||
|
|
||||||
r := NewMSSqlHeahthCrawler()
|
|
||||||
|
|
||||||
m := make(map[string]interface{}, 0)
|
|
||||||
|
|
||||||
m["ip"] = "192.168.1.106"
|
|
||||||
m["port"] = "1433"
|
|
||||||
m["portType"] = "tcp"
|
|
||||||
m["ssl"] = false
|
|
||||||
|
|
||||||
r.PutConfig("r", m)
|
|
||||||
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatch(t *testing.T) {
|
|
||||||
// test config
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
out := param.Output{}
|
|
||||||
r.Get("r", &out)
|
|
||||||
|
|
||||||
var check bool
|
|
||||||
json.Unmarshal(out.Data, &check)
|
|
||||||
|
|
||||||
assert.Equal(t, true, check)
|
|
||||||
}
|
|
||||||
|
|
||||||
func start() {
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
of_rpc.AddDelegate("r", r)
|
|
||||||
err := of_rpc.StartJSONRPC()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRPC(t *testing.T) {
|
|
||||||
go start()
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
|
|
||||||
in := param.Input{
|
|
||||||
Name: "r",
|
|
||||||
Id: "r",
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//import (
|
//import (
|
||||||
// "testing"
|
// "encoding/json"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
// "github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
|
// "log"
|
||||||
|
// "testing"
|
||||||
|
// "time"
|
||||||
//)
|
//)
|
||||||
//
|
//
|
||||||
//func TestMatch(t *testing.T) {
|
//func setConfig() crawler.Crawler {
|
||||||
// b, err := check("192.168.1.106", 1433)
|
//
|
||||||
// if err != nil {
|
// r := NewMSSqlHeahthCrawler()
|
||||||
// t.Error(err)
|
//
|
||||||
// }
|
// m := make(map[string]interface{}, 0)
|
||||||
// assert.Equal(t, true, b)
|
//
|
||||||
|
// m["ip"] = "192.168.1.106"
|
||||||
|
// m["port"] = "1433"
|
||||||
|
// m["portType"] = "tcp"
|
||||||
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
|
// r.PutConfig("r", m)
|
||||||
|
//
|
||||||
|
// return r
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
|
//func TestMatch(t *testing.T) {
|
||||||
|
// // test config
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// out := param.Output{}
|
||||||
|
// r.Get("r", &out)
|
||||||
|
//
|
||||||
|
// var check bool
|
||||||
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func start() {
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// of_rpc.AddDelegate("r", r)
|
||||||
|
// err := of_rpc.StartJSONRPC()
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func TestRPC(t *testing.T) {
|
||||||
|
// go start()
|
||||||
|
// time.Sleep(2 * time.Second)
|
||||||
|
//
|
||||||
|
// in := param.Input{
|
||||||
|
// Name: "r",
|
||||||
|
// Id: "r",
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// 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)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
////
|
||||||
|
////import (
|
||||||
|
//// "testing"
|
||||||
|
//// "github.com/stretchr/testify/assert"
|
||||||
|
////)
|
||||||
|
////
|
||||||
|
////func TestMatch(t *testing.T) {
|
||||||
|
//// b, err := check("192.168.1.106", 1433)
|
||||||
|
//// if err != nil {
|
||||||
|
//// t.Error(err)
|
||||||
|
//// }
|
||||||
|
//// assert.Equal(t, true, b)
|
||||||
|
////}
|
||||||
|
@ -1,86 +1,86 @@
|
|||||||
package mysql_protocol_crawler
|
package mysql_protocol_crawler
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"log"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setConfig() crawler.Crawler {
|
|
||||||
|
|
||||||
r := NewMysqlHeahthCrawler()
|
|
||||||
|
|
||||||
m := make(map[string]interface{}, 0)
|
|
||||||
|
|
||||||
m["ip"] = "192.168.1.103"
|
|
||||||
m["port"] = "3306"
|
|
||||||
m["portType"] = "tcp"
|
|
||||||
m["ssl"] = false
|
|
||||||
|
|
||||||
r.PutConfig("redis", m)
|
|
||||||
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatch(t *testing.T) {
|
|
||||||
// test config
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
out := param.Output{}
|
|
||||||
r.Get("redis", &out)
|
|
||||||
|
|
||||||
var check bool
|
|
||||||
json.Unmarshal(out.Data, &check)
|
|
||||||
|
|
||||||
assert.Equal(t, true, check)
|
|
||||||
}
|
|
||||||
|
|
||||||
func start() {
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
of_rpc.AddDelegate("redis", r)
|
|
||||||
err := of_rpc.StartJSONRPC()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRPC(t *testing.T) {
|
|
||||||
go start()
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
|
|
||||||
in := param.Input{
|
|
||||||
Name: "redis",
|
|
||||||
Id: "redis",
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//import (
|
//import (
|
||||||
|
// "encoding/json"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
// "github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
|
// "log"
|
||||||
// "testing"
|
// "testing"
|
||||||
|
// "time"
|
||||||
//)
|
//)
|
||||||
//
|
//
|
||||||
//func TestMatch(t *testing.T) {
|
//func setConfig() crawler.Crawler {
|
||||||
// b, err := check("192.168.1.103", 3306)
|
//
|
||||||
// if err != nil {
|
// r := NewMysqlHeahthCrawler()
|
||||||
// t.Error(err)
|
//
|
||||||
// }
|
// m := make(map[string]interface{}, 0)
|
||||||
// assert.Equal(t, true, b)
|
//
|
||||||
|
// m["ip"] = "192.168.1.103"
|
||||||
|
// m["port"] = "3306"
|
||||||
|
// m["portType"] = "tcp"
|
||||||
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
|
// r.PutConfig("redis", m)
|
||||||
|
//
|
||||||
|
// return r
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
|
//func TestMatch(t *testing.T) {
|
||||||
|
// // test config
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// out := param.Output{}
|
||||||
|
// r.Get("redis", &out)
|
||||||
|
//
|
||||||
|
// var check bool
|
||||||
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func start() {
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// of_rpc.AddDelegate("redis", r)
|
||||||
|
// err := of_rpc.StartJSONRPC()
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func TestRPC(t *testing.T) {
|
||||||
|
// go start()
|
||||||
|
// time.Sleep(2 * time.Second)
|
||||||
|
//
|
||||||
|
// in := param.Input{
|
||||||
|
// Name: "redis",
|
||||||
|
// Id: "redis",
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// 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)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
////
|
||||||
|
////import (
|
||||||
|
//// "github.com/stretchr/testify/assert"
|
||||||
|
//// "testing"
|
||||||
|
////)
|
||||||
|
////
|
||||||
|
////func TestMatch(t *testing.T) {
|
||||||
|
//// b, err := check("192.168.1.103", 3306)
|
||||||
|
//// if err != nil {
|
||||||
|
//// t.Error(err)
|
||||||
|
//// }
|
||||||
|
//// assert.Equal(t, true, b)
|
||||||
|
////}
|
||||||
|
@ -1,105 +1,105 @@
|
|||||||
package netbios_protocol_crawler
|
package netbios_protocol_crawler
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"log"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setConfig() crawler.Crawler {
|
|
||||||
|
|
||||||
r := NewNetbiosHeahthCrawler()
|
|
||||||
|
|
||||||
m := make(map[string]interface{}, 0)
|
|
||||||
|
|
||||||
m["ip"] = "192.168.1.106"
|
|
||||||
m["port"] = "139"
|
|
||||||
m["portType"] = "tcp"
|
|
||||||
m["ssl"] = false
|
|
||||||
|
|
||||||
r.PutConfig("r", m)
|
|
||||||
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatch(t *testing.T) {
|
|
||||||
// test config
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
out := param.Output{}
|
|
||||||
r.Get("r", &out)
|
|
||||||
|
|
||||||
var check bool
|
|
||||||
json.Unmarshal(out.Data, &check)
|
|
||||||
|
|
||||||
assert.Equal(t, true, check)
|
|
||||||
}
|
|
||||||
|
|
||||||
func start() {
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
of_rpc.AddDelegate("r", r)
|
|
||||||
err := of_rpc.StartJSONRPC()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRPC(t *testing.T) {
|
|
||||||
go start()
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
|
|
||||||
in := param.Input{
|
|
||||||
Name: "r",
|
|
||||||
Id: "r",
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//import (
|
//import (
|
||||||
// "encoding/json"
|
// "encoding/json"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
// "github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
// "git.loafle.net/overflow/of_rpc/json/client"
|
// "log"
|
||||||
// "git.loafle.net/overflow/of_rpc/models/param"
|
|
||||||
// "git.loafle.net/overflow/of_rpc/models/protocol"
|
|
||||||
// "testing"
|
// "testing"
|
||||||
// "time"
|
// "time"
|
||||||
//)
|
//)
|
||||||
//
|
//
|
||||||
//func TestCheck(t *testing.T) {
|
//func setConfig() crawler.Crawler {
|
||||||
// b, _ := check("192.168.1.106", 139, false)
|
//
|
||||||
// assert.Equal(t, true, b)
|
// r := NewNetbiosHeahthCrawler()
|
||||||
|
//
|
||||||
|
// m := make(map[string]interface{}, 0)
|
||||||
|
//
|
||||||
|
// m["ip"] = "192.168.1.106"
|
||||||
|
// m["port"] = "139"
|
||||||
|
// m["portType"] = "tcp"
|
||||||
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
|
// r.PutConfig("r", m)
|
||||||
|
//
|
||||||
|
// return r
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func TestMatch(t *testing.T) {
|
||||||
|
// // test config
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// out := param.Output{}
|
||||||
|
// r.Get("r", &out)
|
||||||
|
//
|
||||||
|
// var check bool
|
||||||
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func start() {
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// of_rpc.AddDelegate("r", r)
|
||||||
|
// err := of_rpc.StartJSONRPC()
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// }
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//func TestRPC(t *testing.T) {
|
//func TestRPC(t *testing.T) {
|
||||||
//
|
|
||||||
// go start()
|
// go start()
|
||||||
// time.Sleep(time.Second * 2)
|
// time.Sleep(2 * time.Second)
|
||||||
//
|
//
|
||||||
// p := protocol.HealthRequest{IsSSL: false}
|
// in := param.Input{
|
||||||
// b, _ := json.Marshal(p)
|
// Name: "r",
|
||||||
|
// Id: "r",
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// in := param.Input{Ip: "192.168.1.106", Port: 139, Data: b}
|
// result, err := client.InvokeJSONRPCGet("50000", in)
|
||||||
//
|
//
|
||||||
// re, _ := client.InvokeJSONRPC("50000", in)
|
// if err != nil {
|
||||||
// var m protocol.HealthResponse
|
// t.Fatal(err)
|
||||||
// json.Unmarshal(re.Data, &m)
|
// }
|
||||||
//
|
//
|
||||||
// assert.Equal(t, true, m.IsMatch)
|
// var check bool
|
||||||
|
// json.Unmarshal(result.Data, &check)
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
|
////
|
||||||
|
////import (
|
||||||
|
//// "encoding/json"
|
||||||
|
//// "github.com/stretchr/testify/assert"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/json/client"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/models/param"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/models/protocol"
|
||||||
|
//// "testing"
|
||||||
|
//// "time"
|
||||||
|
////)
|
||||||
|
////
|
||||||
|
////func TestCheck(t *testing.T) {
|
||||||
|
//// b, _ := check("192.168.1.106", 139, false)
|
||||||
|
//// assert.Equal(t, true, b)
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func TestRPC(t *testing.T) {
|
||||||
|
////
|
||||||
|
//// go start()
|
||||||
|
//// time.Sleep(time.Second * 2)
|
||||||
|
////
|
||||||
|
//// p := protocol.HealthRequest{IsSSL: false}
|
||||||
|
//// b, _ := json.Marshal(p)
|
||||||
|
////
|
||||||
|
//// in := param.Input{Ip: "192.168.1.106", Port: 139, Data: b}
|
||||||
|
////
|
||||||
|
//// re, _ := client.InvokeJSONRPC("50000", in)
|
||||||
|
//// var m protocol.HealthResponse
|
||||||
|
//// json.Unmarshal(re.Data, &m)
|
||||||
|
////
|
||||||
|
//// assert.Equal(t, true, m.IsMatch)
|
||||||
|
////}
|
||||||
|
@ -1,127 +1,127 @@
|
|||||||
package oracle_protocol_crawler
|
package oracle_protocol_crawler
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"log"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setConfig() crawler.Crawler {
|
|
||||||
|
|
||||||
r := NewOracleHeahthCrawler()
|
|
||||||
|
|
||||||
m := make(map[string]interface{}, 0)
|
|
||||||
|
|
||||||
m["ip"] = "192.168.1.30"
|
|
||||||
m["port"] = "1521"
|
|
||||||
m["portType"] = "tcp"
|
|
||||||
m["ssl"] = false
|
|
||||||
|
|
||||||
r.PutConfig("r", m)
|
|
||||||
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatch(t *testing.T) {
|
|
||||||
// test config
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
out := param.Output{}
|
|
||||||
r.Get("r", &out)
|
|
||||||
|
|
||||||
var check bool
|
|
||||||
json.Unmarshal(out.Data, &check)
|
|
||||||
|
|
||||||
assert.Equal(t, true, check)
|
|
||||||
}
|
|
||||||
|
|
||||||
func start() {
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
of_rpc.AddDelegate("r", r)
|
|
||||||
err := of_rpc.StartJSONRPC()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRPC(t *testing.T) {
|
|
||||||
go start()
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
|
|
||||||
in := param.Input{
|
|
||||||
Name: "r",
|
|
||||||
Id: "r",
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
//import (
|
|
||||||
// "testing"
|
|
||||||
// "github.com/stretchr/testify/assert"
|
|
||||||
//)
|
|
||||||
//
|
|
||||||
//func TestMatch(t *testing.T) {
|
|
||||||
// b, err := check("192.168.1.106", 1433)
|
|
||||||
// if err != nil {
|
|
||||||
// t.Error(err)
|
|
||||||
// }
|
|
||||||
// assert.Equal(t, true, b)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//package oracle_protocol_crawler
|
|
||||||
//
|
|
||||||
//
|
//
|
||||||
//import (
|
//import (
|
||||||
// "encoding/json"
|
// "encoding/json"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
// "github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
// "git.loafle.net/overflow/of_rpc/json/client"
|
// "log"
|
||||||
// "git.loafle.net/overflow/of_rpc/models/param"
|
|
||||||
// "git.loafle.net/overflow/of_rpc/models/protocol"
|
|
||||||
// "testing"
|
// "testing"
|
||||||
// "time"
|
// "time"
|
||||||
//)
|
//)
|
||||||
//
|
//
|
||||||
//func TestCheck(t *testing.T) {
|
//func setConfig() crawler.Crawler {
|
||||||
// b, _ := check("192.168.1.30", 1521, false)
|
//
|
||||||
// assert.Equal(t, true, b)
|
// r := NewOracleHeahthCrawler()
|
||||||
|
//
|
||||||
|
// m := make(map[string]interface{}, 0)
|
||||||
|
//
|
||||||
|
// m["ip"] = "192.168.1.30"
|
||||||
|
// m["port"] = "1521"
|
||||||
|
// m["portType"] = "tcp"
|
||||||
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
|
// r.PutConfig("r", m)
|
||||||
|
//
|
||||||
|
// return r
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//func TestCheckTls(t *testing.T) {
|
//func TestMatch(t *testing.T) {
|
||||||
// b, _ := check("192.168.1.215", 22, true)
|
// // test config
|
||||||
// assert.Equal(t, true, b)
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// out := param.Output{}
|
||||||
|
// r.Get("r", &out)
|
||||||
|
//
|
||||||
|
// var check bool
|
||||||
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
|
//func start() {
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// of_rpc.AddDelegate("r", r)
|
||||||
|
// err := of_rpc.StartJSONRPC()
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// }
|
||||||
|
//}
|
||||||
//
|
//
|
||||||
//func TestRPC(t *testing.T) {
|
//func TestRPC(t *testing.T) {
|
||||||
//
|
|
||||||
// go start()
|
// go start()
|
||||||
// time.Sleep(time.Second * 2)
|
// time.Sleep(2 * time.Second)
|
||||||
//
|
//
|
||||||
// p := protocol.HealthRequest{IsSSL: false}
|
// in := param.Input{
|
||||||
// b, _ := json.Marshal(p)
|
// Name: "r",
|
||||||
|
// Id: "r",
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// in := param.Input{Ip: "192.168.1.30", Port: 1521, Data: b}
|
// result, err := client.InvokeJSONRPCGet("50000", in)
|
||||||
//
|
//
|
||||||
// re, _ := client.InvokeJSONRPC("50000", in)
|
// if err != nil {
|
||||||
// var m protocol.HealthResponse
|
// t.Fatal(err)
|
||||||
// json.Unmarshal(re.Data, &m)
|
// }
|
||||||
//
|
//
|
||||||
// assert.Equal(t, true, m.IsMatch)
|
// var check bool
|
||||||
|
// json.Unmarshal(result.Data, &check)
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
|
////
|
||||||
|
////import (
|
||||||
|
//// "testing"
|
||||||
|
//// "github.com/stretchr/testify/assert"
|
||||||
|
////)
|
||||||
|
////
|
||||||
|
////func TestMatch(t *testing.T) {
|
||||||
|
//// b, err := check("192.168.1.106", 1433)
|
||||||
|
//// if err != nil {
|
||||||
|
//// t.Error(err)
|
||||||
|
//// }
|
||||||
|
//// assert.Equal(t, true, b)
|
||||||
|
////}
|
||||||
|
//
|
||||||
|
////package oracle_protocol_crawler
|
||||||
|
////
|
||||||
|
////
|
||||||
|
////import (
|
||||||
|
//// "encoding/json"
|
||||||
|
//// "github.com/stretchr/testify/assert"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/json/client"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/models/param"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/models/protocol"
|
||||||
|
//// "testing"
|
||||||
|
//// "time"
|
||||||
|
////)
|
||||||
|
////
|
||||||
|
////func TestCheck(t *testing.T) {
|
||||||
|
//// b, _ := check("192.168.1.30", 1521, false)
|
||||||
|
//// assert.Equal(t, true, b)
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func TestCheckTls(t *testing.T) {
|
||||||
|
//// b, _ := check("192.168.1.215", 22, true)
|
||||||
|
//// assert.Equal(t, true, b)
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////
|
||||||
|
////func TestRPC(t *testing.T) {
|
||||||
|
////
|
||||||
|
//// go start()
|
||||||
|
//// time.Sleep(time.Second * 2)
|
||||||
|
////
|
||||||
|
//// p := protocol.HealthRequest{IsSSL: false}
|
||||||
|
//// b, _ := json.Marshal(p)
|
||||||
|
////
|
||||||
|
//// in := param.Input{Ip: "192.168.1.30", Port: 1521, Data: b}
|
||||||
|
////
|
||||||
|
//// re, _ := client.InvokeJSONRPC("50000", in)
|
||||||
|
//// var m protocol.HealthResponse
|
||||||
|
//// json.Unmarshal(re.Data, &m)
|
||||||
|
////
|
||||||
|
//// assert.Equal(t, true, m.IsMatch)
|
||||||
|
////}
|
||||||
|
@ -1,86 +1,86 @@
|
|||||||
package pgsql_protocol_crawler
|
package pgsql_protocol_crawler
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"log"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setConfig() crawler.Crawler {
|
|
||||||
|
|
||||||
r := NewPGSqlHeahthCrawler()
|
|
||||||
|
|
||||||
m := make(map[string]interface{}, 0)
|
|
||||||
|
|
||||||
m["ip"] = "192.168.1.107"
|
|
||||||
m["port"] = "5432"
|
|
||||||
m["portType"] = "tcp"
|
|
||||||
m["ssl"] = false
|
|
||||||
|
|
||||||
r.PutConfig("r", m)
|
|
||||||
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatch(t *testing.T) {
|
|
||||||
// test config
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
out := param.Output{}
|
|
||||||
r.Get("r", &out)
|
|
||||||
|
|
||||||
var check bool
|
|
||||||
json.Unmarshal(out.Data, &check)
|
|
||||||
|
|
||||||
assert.Equal(t, true, check)
|
|
||||||
}
|
|
||||||
|
|
||||||
func start() {
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
of_rpc.AddDelegate("r", r)
|
|
||||||
err := of_rpc.StartJSONRPC()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRPC(t *testing.T) {
|
|
||||||
go start()
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
|
|
||||||
in := param.Input{
|
|
||||||
Name: "r",
|
|
||||||
Id: "r",
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//import (
|
//import (
|
||||||
// "testing"
|
// "encoding/json"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
// "github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
|
// "log"
|
||||||
|
// "testing"
|
||||||
|
// "time"
|
||||||
//)
|
//)
|
||||||
//
|
//
|
||||||
//func TestMatch(t *testing.T) {
|
//func setConfig() crawler.Crawler {
|
||||||
// b, err := check("192.168.1.106", 1433)
|
//
|
||||||
// if err != nil {
|
// r := NewPGSqlHeahthCrawler()
|
||||||
// t.Error(err)
|
//
|
||||||
// }
|
// m := make(map[string]interface{}, 0)
|
||||||
// assert.Equal(t, true, b)
|
//
|
||||||
|
// m["ip"] = "192.168.1.107"
|
||||||
|
// m["port"] = "5432"
|
||||||
|
// m["portType"] = "tcp"
|
||||||
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
|
// r.PutConfig("r", m)
|
||||||
|
//
|
||||||
|
// return r
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
|
//func TestMatch(t *testing.T) {
|
||||||
|
// // test config
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// out := param.Output{}
|
||||||
|
// r.Get("r", &out)
|
||||||
|
//
|
||||||
|
// var check bool
|
||||||
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func start() {
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// of_rpc.AddDelegate("r", r)
|
||||||
|
// err := of_rpc.StartJSONRPC()
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func TestRPC(t *testing.T) {
|
||||||
|
// go start()
|
||||||
|
// time.Sleep(2 * time.Second)
|
||||||
|
//
|
||||||
|
// in := param.Input{
|
||||||
|
// Name: "r",
|
||||||
|
// Id: "r",
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// 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)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
////
|
||||||
|
////import (
|
||||||
|
//// "testing"
|
||||||
|
//// "github.com/stretchr/testify/assert"
|
||||||
|
////)
|
||||||
|
////
|
||||||
|
////func TestMatch(t *testing.T) {
|
||||||
|
//// b, err := check("192.168.1.106", 1433)
|
||||||
|
//// if err != nil {
|
||||||
|
//// t.Error(err)
|
||||||
|
//// }
|
||||||
|
//// assert.Equal(t, true, b)
|
||||||
|
////}
|
||||||
|
@ -1,111 +1,111 @@
|
|||||||
package pop3_protocol_crawler
|
package pop3_protocol_crawler
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"log"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setConfig() crawler.Crawler {
|
|
||||||
|
|
||||||
r := NewPOP3HeahthCrawler()
|
|
||||||
|
|
||||||
m := make(map[string]interface{}, 0)
|
|
||||||
|
|
||||||
m["ip"] = "192.168.1.215"
|
|
||||||
m["port"] = "110"
|
|
||||||
m["portType"] = "tcp"
|
|
||||||
m["ssl"] = false
|
|
||||||
|
|
||||||
r.PutConfig("r", m)
|
|
||||||
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatch(t *testing.T) {
|
|
||||||
// test config
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
out := param.Output{}
|
|
||||||
r.Get("r", &out)
|
|
||||||
|
|
||||||
var check bool
|
|
||||||
json.Unmarshal(out.Data, &check)
|
|
||||||
|
|
||||||
assert.Equal(t, true, check)
|
|
||||||
}
|
|
||||||
|
|
||||||
func start() {
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
of_rpc.AddDelegate("r", r)
|
|
||||||
err := of_rpc.StartJSONRPC()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRPC(t *testing.T) {
|
|
||||||
go start()
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
|
|
||||||
in := param.Input{
|
|
||||||
Name: "r",
|
|
||||||
Id: "r",
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
//package pop3
|
|
||||||
//
|
//
|
||||||
//import (
|
//import (
|
||||||
// "encoding/json"
|
// "encoding/json"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
// "github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
// "git.loafle.net/overflow/of_rpc/json/client"
|
// "log"
|
||||||
// "git.loafle.net/overflow/of_rpc/models/param"
|
|
||||||
// "git.loafle.net/overflow/of_rpc/models/protocol"
|
|
||||||
// "testing"
|
// "testing"
|
||||||
// "time"
|
// "time"
|
||||||
//)
|
//)
|
||||||
//
|
//
|
||||||
//func TestCheck(t *testing.T) {
|
//func setConfig() crawler.Crawler {
|
||||||
// b, _ := check("192.168.1.215", 110, false)
|
//
|
||||||
// assert.Equal(t, true, b)
|
// r := NewPOP3HeahthCrawler()
|
||||||
|
//
|
||||||
|
// m := make(map[string]interface{}, 0)
|
||||||
|
//
|
||||||
|
// m["ip"] = "192.168.1.215"
|
||||||
|
// m["port"] = "110"
|
||||||
|
// m["portType"] = "tcp"
|
||||||
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
|
// r.PutConfig("r", m)
|
||||||
|
//
|
||||||
|
// return r
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//func TestCheckSSL(t *testing.T) {
|
//func TestMatch(t *testing.T) {
|
||||||
// b, _ := check("192.168.1.215", 995, true)
|
// // test config
|
||||||
// assert.Equal(t, true, b)
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// out := param.Output{}
|
||||||
|
// r.Get("r", &out)
|
||||||
|
//
|
||||||
|
// var check bool
|
||||||
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func start() {
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// of_rpc.AddDelegate("r", r)
|
||||||
|
// err := of_rpc.StartJSONRPC()
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// }
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//func TestRPC(t *testing.T) {
|
//func TestRPC(t *testing.T) {
|
||||||
//
|
|
||||||
// go start()
|
// go start()
|
||||||
// time.Sleep(time.Second * 2)
|
// time.Sleep(2 * time.Second)
|
||||||
//
|
//
|
||||||
// p := protocol.HealthRequest{IsSSL: false}
|
// in := param.Input{
|
||||||
// b, _ := json.Marshal(p)
|
// Name: "r",
|
||||||
|
// Id: "r",
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// in := param.Input{Ip: "192.168.1.215", Port: 143, Data: b}
|
// result, err := client.InvokeJSONRPCGet("50000", in)
|
||||||
//
|
//
|
||||||
// re, _ := client.InvokeJSONRPC("50000", in)
|
// if err != nil {
|
||||||
// var m protocol.HealthResponse
|
// t.Fatal(err)
|
||||||
// json.Unmarshal(re.Data, &m)
|
// }
|
||||||
//
|
//
|
||||||
// assert.Equal(t, true, m.IsMatch)
|
// var check bool
|
||||||
|
// json.Unmarshal(result.Data, &check)
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
|
////package pop3
|
||||||
|
////
|
||||||
|
////import (
|
||||||
|
//// "encoding/json"
|
||||||
|
//// "github.com/stretchr/testify/assert"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/json/client"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/models/param"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/models/protocol"
|
||||||
|
//// "testing"
|
||||||
|
//// "time"
|
||||||
|
////)
|
||||||
|
////
|
||||||
|
////func TestCheck(t *testing.T) {
|
||||||
|
//// b, _ := check("192.168.1.215", 110, false)
|
||||||
|
//// assert.Equal(t, true, b)
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func TestCheckSSL(t *testing.T) {
|
||||||
|
//// b, _ := check("192.168.1.215", 995, true)
|
||||||
|
//// assert.Equal(t, true, b)
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func TestRPC(t *testing.T) {
|
||||||
|
////
|
||||||
|
//// go start()
|
||||||
|
//// time.Sleep(time.Second * 2)
|
||||||
|
////
|
||||||
|
//// p := protocol.HealthRequest{IsSSL: false}
|
||||||
|
//// b, _ := json.Marshal(p)
|
||||||
|
////
|
||||||
|
//// in := param.Input{Ip: "192.168.1.215", Port: 143, Data: b}
|
||||||
|
////
|
||||||
|
//// re, _ := client.InvokeJSONRPC("50000", in)
|
||||||
|
//// var m protocol.HealthResponse
|
||||||
|
//// json.Unmarshal(re.Data, &m)
|
||||||
|
////
|
||||||
|
//// assert.Equal(t, true, m.IsMatch)
|
||||||
|
////}
|
||||||
|
@ -1,41 +1,41 @@
|
|||||||
package redis_protocol_crawler
|
package redis_protocol_crawler
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"encoding/json"
|
// "encoding/json"
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler/config"
|
// "git.loafle.net/overflow/overflow_probe/crawler/config"
|
||||||
"github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
"testing"
|
// "testing"
|
||||||
)
|
//)
|
||||||
|
//
|
||||||
func setConfig() crawler.Crawler {
|
//func setConfig() crawler.Crawler {
|
||||||
|
//
|
||||||
r := NewRedisHeahthCrawler()
|
// r := NewRedisHeahthCrawler()
|
||||||
|
//
|
||||||
m := config.Config{}
|
// m := config.Config{}
|
||||||
m.Target = config.Target{}
|
// m.Target = config.Target{}
|
||||||
m.Target.Connection = config.Connection{}
|
// m.Target.Connection = config.Connection{}
|
||||||
m.Target.Connection.Ip = "192.168.1.104"
|
// m.Target.Connection.Ip = "192.168.1.104"
|
||||||
m.Target.Connection.Port = "6379"
|
// m.Target.Connection.Port = "6379"
|
||||||
m.Target.Connection.PortType = "tcp"
|
// m.Target.Connection.PortType = "tcp"
|
||||||
m.Target.Connection.SSL = false
|
// m.Target.Connection.SSL = false
|
||||||
|
//
|
||||||
r.PutConfig("redis", m)
|
// r.PutConfig("redis", m)
|
||||||
|
//
|
||||||
return r
|
// return r
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestMatch(t *testing.T) {
|
//func TestMatch(t *testing.T) {
|
||||||
// test config
|
// // test config
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
b, _ := r.Get("redis")
|
// b, _ := r.Get("redis")
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(b, &check)
|
// json.Unmarshal(b, &check)
|
||||||
|
//
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
|
||||||
//
|
//
|
||||||
//func start() {
|
//func start() {
|
||||||
|
@ -1,75 +1,75 @@
|
|||||||
package rmi_protocol_crawler
|
package rmi_protocol_crawler
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"encoding/json"
|
// "encoding/json"
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
"github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
"log"
|
// "log"
|
||||||
"testing"
|
// "testing"
|
||||||
"time"
|
// "time"
|
||||||
)
|
//)
|
||||||
|
//
|
||||||
func setConfig() crawler.Crawler {
|
//func setConfig() crawler.Crawler {
|
||||||
|
//
|
||||||
r := NewRMIHeahthCrawler()
|
// r := NewRMIHeahthCrawler()
|
||||||
|
//
|
||||||
m := make(map[string]interface{}, 0)
|
// m := make(map[string]interface{}, 0)
|
||||||
|
//
|
||||||
m["ip"] = "192.168.1.103"
|
// m["ip"] = "192.168.1.103"
|
||||||
m["port"] = "9840"
|
// m["port"] = "9840"
|
||||||
m["portType"] = "tcp"
|
// m["portType"] = "tcp"
|
||||||
m["ssl"] = false
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
r.PutConfig("r", m)
|
// r.PutConfig("r", m)
|
||||||
|
//
|
||||||
return r
|
// return r
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestMatch(t *testing.T) {
|
//func TestMatch(t *testing.T) {
|
||||||
// test config
|
// // test config
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
out := param.Output{}
|
// out := param.Output{}
|
||||||
r.Get("r", &out)
|
// r.Get("r", &out)
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(out.Data, &check)
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func start() {
|
//func start() {
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
of_rpc.AddDelegate("r", r)
|
// of_rpc.AddDelegate("r", r)
|
||||||
err := of_rpc.StartJSONRPC()
|
// err := of_rpc.StartJSONRPC()
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Fatal(err)
|
// log.Fatal(err)
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestRPC(t *testing.T) {
|
//func TestRPC(t *testing.T) {
|
||||||
go start()
|
// go start()
|
||||||
time.Sleep(2 * time.Second)
|
// time.Sleep(2 * time.Second)
|
||||||
|
//
|
||||||
in := param.Input{
|
// in := param.Input{
|
||||||
Name: "r",
|
// Name: "r",
|
||||||
Id: "r",
|
// Id: "r",
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
result, err := client.InvokeJSONRPCGet("50000", in)
|
// result, err := client.InvokeJSONRPCGet("50000", in)
|
||||||
|
//
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
t.Fatal(err)
|
// t.Fatal(err)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(result.Data, &check)
|
// json.Unmarshal(result.Data, &check)
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
|
||||||
//package imap
|
//package imap
|
||||||
//
|
//
|
||||||
|
@ -1,75 +1,75 @@
|
|||||||
package smb_protocol_crawler
|
package smb_protocol_crawler
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"encoding/json"
|
// "encoding/json"
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
"github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
"log"
|
// "log"
|
||||||
"testing"
|
// "testing"
|
||||||
"time"
|
// "time"
|
||||||
)
|
//)
|
||||||
|
//
|
||||||
func setConfig() crawler.Crawler {
|
//func setConfig() crawler.Crawler {
|
||||||
|
//
|
||||||
r := NewSMBHeahthCrawler()
|
// r := NewSMBHeahthCrawler()
|
||||||
|
//
|
||||||
m := make(map[string]interface{}, 0)
|
// m := make(map[string]interface{}, 0)
|
||||||
|
//
|
||||||
m["ip"] = "192.168.1.106"
|
// m["ip"] = "192.168.1.106"
|
||||||
m["port"] = "445"
|
// m["port"] = "445"
|
||||||
m["portType"] = "tcp"
|
// m["portType"] = "tcp"
|
||||||
m["ssl"] = false
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
r.PutConfig("r", m)
|
// r.PutConfig("r", m)
|
||||||
|
//
|
||||||
return r
|
// return r
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestMatch(t *testing.T) {
|
//func TestMatch(t *testing.T) {
|
||||||
// test config
|
// // test config
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
out := param.Output{}
|
// out := param.Output{}
|
||||||
r.Get("r", &out)
|
// r.Get("r", &out)
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(out.Data, &check)
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func start() {
|
//func start() {
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
of_rpc.AddDelegate("r", r)
|
// of_rpc.AddDelegate("r", r)
|
||||||
err := of_rpc.StartJSONRPC()
|
// err := of_rpc.StartJSONRPC()
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Fatal(err)
|
// log.Fatal(err)
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestRPC(t *testing.T) {
|
//func TestRPC(t *testing.T) {
|
||||||
go start()
|
// go start()
|
||||||
time.Sleep(2 * time.Second)
|
// time.Sleep(2 * time.Second)
|
||||||
|
//
|
||||||
in := param.Input{
|
// in := param.Input{
|
||||||
Name: "r",
|
// Name: "r",
|
||||||
Id: "r",
|
// Id: "r",
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
result, err := client.InvokeJSONRPCGet("50000", in)
|
// result, err := client.InvokeJSONRPCGet("50000", in)
|
||||||
|
//
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
t.Fatal(err)
|
// t.Fatal(err)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(result.Data, &check)
|
// json.Unmarshal(result.Data, &check)
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
|
||||||
//package smb_protocol_crawler
|
//package smb_protocol_crawler
|
||||||
//
|
//
|
||||||
|
@ -1,111 +1,111 @@
|
|||||||
package smtp_protocol_crawler
|
package smtp_protocol_crawler
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"log"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setConfig() crawler.Crawler {
|
|
||||||
|
|
||||||
r := NewSMTPHeahthCrawler()
|
|
||||||
|
|
||||||
m := make(map[string]interface{}, 0)
|
|
||||||
|
|
||||||
m["ip"] = "192.168.1.215"
|
|
||||||
m["port"] = "25"
|
|
||||||
m["portType"] = "tcp"
|
|
||||||
m["ssl"] = false
|
|
||||||
|
|
||||||
r.PutConfig("r", m)
|
|
||||||
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatch(t *testing.T) {
|
|
||||||
// test config
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
out := param.Output{}
|
|
||||||
r.Get("r", &out)
|
|
||||||
|
|
||||||
var check bool
|
|
||||||
json.Unmarshal(out.Data, &check)
|
|
||||||
|
|
||||||
assert.Equal(t, true, check)
|
|
||||||
}
|
|
||||||
|
|
||||||
func start() {
|
|
||||||
r := setConfig()
|
|
||||||
|
|
||||||
of_rpc.AddDelegate("r", r)
|
|
||||||
err := of_rpc.StartJSONRPC()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRPC(t *testing.T) {
|
|
||||||
go start()
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
|
|
||||||
in := param.Input{
|
|
||||||
Name: "r",
|
|
||||||
Id: "r",
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
//package smtp
|
|
||||||
//
|
//
|
||||||
//import (
|
//import (
|
||||||
// "encoding/json"
|
// "encoding/json"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
// "github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
// "git.loafle.net/overflow/of_rpc/json/client"
|
// "log"
|
||||||
// "git.loafle.net/overflow/of_rpc/models/param"
|
|
||||||
// "git.loafle.net/overflow/of_rpc/models/protocol"
|
|
||||||
// "testing"
|
// "testing"
|
||||||
// "time"
|
// "time"
|
||||||
//)
|
//)
|
||||||
//
|
//
|
||||||
//func TestCheck(t *testing.T) {
|
//func setConfig() crawler.Crawler {
|
||||||
// b, _ := check("192.168.1.215", 25, false)
|
//
|
||||||
// assert.Equal(t, true, b)
|
// r := NewSMTPHeahthCrawler()
|
||||||
|
//
|
||||||
|
// m := make(map[string]interface{}, 0)
|
||||||
|
//
|
||||||
|
// m["ip"] = "192.168.1.215"
|
||||||
|
// m["port"] = "25"
|
||||||
|
// m["portType"] = "tcp"
|
||||||
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
|
// r.PutConfig("r", m)
|
||||||
|
//
|
||||||
|
// return r
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//func TestCheckSSL(t *testing.T) {
|
//func TestMatch(t *testing.T) {
|
||||||
// b, _ := check("192.168.1.215", 465, true)
|
// // test config
|
||||||
// assert.Equal(t, true, b)
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// out := param.Output{}
|
||||||
|
// r.Get("r", &out)
|
||||||
|
//
|
||||||
|
// var check bool
|
||||||
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func start() {
|
||||||
|
// r := setConfig()
|
||||||
|
//
|
||||||
|
// of_rpc.AddDelegate("r", r)
|
||||||
|
// err := of_rpc.StartJSONRPC()
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// }
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//func TestRPC(t *testing.T) {
|
//func TestRPC(t *testing.T) {
|
||||||
//
|
|
||||||
// go start()
|
// go start()
|
||||||
// time.Sleep(time.Second * 2)
|
// time.Sleep(2 * time.Second)
|
||||||
//
|
//
|
||||||
// p := protocol.HealthRequest{IsSSL: false}
|
// in := param.Input{
|
||||||
// b, _ := json.Marshal(p)
|
// Name: "r",
|
||||||
|
// Id: "r",
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// in := param.Input{Ip: "192.168.1.215", Port: 25, Data: b}
|
// result, err := client.InvokeJSONRPCGet("50000", in)
|
||||||
//
|
//
|
||||||
// re, _ := client.InvokeJSONRPC("50000", in)
|
// if err != nil {
|
||||||
// var m protocol.HealthResponse
|
// t.Fatal(err)
|
||||||
// json.Unmarshal(re.Data, &m)
|
// }
|
||||||
//
|
//
|
||||||
// assert.Equal(t, true, m.IsMatch)
|
// var check bool
|
||||||
|
// json.Unmarshal(result.Data, &check)
|
||||||
|
// assert.Equal(t, true, check)
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
|
////package smtp
|
||||||
|
////
|
||||||
|
////import (
|
||||||
|
//// "encoding/json"
|
||||||
|
//// "github.com/stretchr/testify/assert"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/json/client"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/models/param"
|
||||||
|
//// "git.loafle.net/overflow/of_rpc/models/protocol"
|
||||||
|
//// "testing"
|
||||||
|
//// "time"
|
||||||
|
////)
|
||||||
|
////
|
||||||
|
////func TestCheck(t *testing.T) {
|
||||||
|
//// b, _ := check("192.168.1.215", 25, false)
|
||||||
|
//// assert.Equal(t, true, b)
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func TestCheckSSL(t *testing.T) {
|
||||||
|
//// b, _ := check("192.168.1.215", 465, true)
|
||||||
|
//// assert.Equal(t, true, b)
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func TestRPC(t *testing.T) {
|
||||||
|
////
|
||||||
|
//// go start()
|
||||||
|
//// time.Sleep(time.Second * 2)
|
||||||
|
////
|
||||||
|
//// p := protocol.HealthRequest{IsSSL: false}
|
||||||
|
//// b, _ := json.Marshal(p)
|
||||||
|
////
|
||||||
|
//// in := param.Input{Ip: "192.168.1.215", Port: 25, Data: b}
|
||||||
|
////
|
||||||
|
//// re, _ := client.InvokeJSONRPC("50000", in)
|
||||||
|
//// var m protocol.HealthResponse
|
||||||
|
//// json.Unmarshal(re.Data, &m)
|
||||||
|
////
|
||||||
|
//// assert.Equal(t, true, m.IsMatch)
|
||||||
|
////}
|
||||||
|
@ -1,75 +1,75 @@
|
|||||||
package snmpv2c_protocol_crawler
|
package snmpv2c_protocol_crawler
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"encoding/json"
|
// "encoding/json"
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
"github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
"log"
|
// "log"
|
||||||
"testing"
|
// "testing"
|
||||||
"time"
|
// "time"
|
||||||
)
|
//)
|
||||||
|
//
|
||||||
func setConfig() crawler.Crawler {
|
//func setConfig() crawler.Crawler {
|
||||||
|
//
|
||||||
r := NewSNMPV2CHeahthCrawler()
|
// r := NewSNMPV2CHeahthCrawler()
|
||||||
|
//
|
||||||
m := make(map[string]interface{}, 0)
|
// m := make(map[string]interface{}, 0)
|
||||||
|
//
|
||||||
m["ip"] = "192.168.1.215"
|
// m["ip"] = "192.168.1.215"
|
||||||
m["port"] = "161"
|
// m["port"] = "161"
|
||||||
m["portType"] = "udp"
|
// m["portType"] = "udp"
|
||||||
m["ssl"] = false
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
r.PutConfig("r", m)
|
// r.PutConfig("r", m)
|
||||||
|
//
|
||||||
return r
|
// return r
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestMatch(t *testing.T) {
|
//func TestMatch(t *testing.T) {
|
||||||
// test config
|
// // test config
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
out := param.Output{}
|
// out := param.Output{}
|
||||||
r.Get("r", &out)
|
// r.Get("r", &out)
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(out.Data, &check)
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func start() {
|
//func start() {
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
of_rpc.AddDelegate("r", r)
|
// of_rpc.AddDelegate("r", r)
|
||||||
err := of_rpc.StartJSONRPC()
|
// err := of_rpc.StartJSONRPC()
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Fatal(err)
|
// log.Fatal(err)
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestRPC(t *testing.T) {
|
//func TestRPC(t *testing.T) {
|
||||||
go start()
|
// go start()
|
||||||
time.Sleep(2 * time.Second)
|
// time.Sleep(2 * time.Second)
|
||||||
|
//
|
||||||
in := param.Input{
|
// in := param.Input{
|
||||||
Name: "r",
|
// Name: "r",
|
||||||
Id: "r",
|
// Id: "r",
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
result, err := client.InvokeJSONRPCGet("50000", in)
|
// result, err := client.InvokeJSONRPCGet("50000", in)
|
||||||
|
//
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
t.Fatal(err)
|
// t.Fatal(err)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(result.Data, &check)
|
// json.Unmarshal(result.Data, &check)
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
|
||||||
//package snmpv2c_protocol_crawler
|
//package snmpv2c_protocol_crawler
|
||||||
//
|
//
|
||||||
|
@ -1,75 +1,75 @@
|
|||||||
package snmpv3_protocol_crawler
|
package snmpv3_protocol_crawler
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"encoding/json"
|
// "encoding/json"
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
"github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
"log"
|
// "log"
|
||||||
"testing"
|
// "testing"
|
||||||
"time"
|
// "time"
|
||||||
)
|
//)
|
||||||
|
//
|
||||||
func setConfig() crawler.Crawler {
|
//func setConfig() crawler.Crawler {
|
||||||
|
//
|
||||||
r := NewSNMPV3HeahthCrawler()
|
// r := NewSNMPV3HeahthCrawler()
|
||||||
|
//
|
||||||
m := make(map[string]interface{}, 0)
|
// m := make(map[string]interface{}, 0)
|
||||||
|
//
|
||||||
m["ip"] = "192.168.1.254"
|
// m["ip"] = "192.168.1.254"
|
||||||
m["port"] = "161"
|
// m["port"] = "161"
|
||||||
m["portType"] = "udp"
|
// m["portType"] = "udp"
|
||||||
m["ssl"] = false
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
r.PutConfig("r", m)
|
// r.PutConfig("r", m)
|
||||||
|
//
|
||||||
return r
|
// return r
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestMatch(t *testing.T) {
|
//func TestMatch(t *testing.T) {
|
||||||
// test config
|
// // test config
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
out := param.Output{}
|
// out := param.Output{}
|
||||||
r.Get("r", &out)
|
// r.Get("r", &out)
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(out.Data, &check)
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func start() {
|
//func start() {
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
of_rpc.AddDelegate("r", r)
|
// of_rpc.AddDelegate("r", r)
|
||||||
err := of_rpc.StartJSONRPC()
|
// err := of_rpc.StartJSONRPC()
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Fatal(err)
|
// log.Fatal(err)
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestRPC(t *testing.T) {
|
//func TestRPC(t *testing.T) {
|
||||||
go start()
|
// go start()
|
||||||
time.Sleep(2 * time.Second)
|
// time.Sleep(2 * time.Second)
|
||||||
|
//
|
||||||
in := param.Input{
|
// in := param.Input{
|
||||||
Name: "r",
|
// Name: "r",
|
||||||
Id: "r",
|
// Id: "r",
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
result, err := client.InvokeJSONRPCGet("50000", in)
|
// result, err := client.InvokeJSONRPCGet("50000", in)
|
||||||
|
//
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
t.Fatal(err)
|
// t.Fatal(err)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(result.Data, &check)
|
// json.Unmarshal(result.Data, &check)
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
|
||||||
//package snmpv3_protocol_crawler
|
//package snmpv3_protocol_crawler
|
||||||
//
|
//
|
||||||
|
@ -1,75 +1,75 @@
|
|||||||
package ssh_protocol_crawler
|
package ssh_protocol_crawler
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"encoding/json"
|
// "encoding/json"
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
"github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
"log"
|
// "log"
|
||||||
"testing"
|
// "testing"
|
||||||
"time"
|
// "time"
|
||||||
)
|
//)
|
||||||
|
//
|
||||||
func setConfig() crawler.Crawler {
|
//func setConfig() crawler.Crawler {
|
||||||
|
//
|
||||||
r := NewSSHHeahthCrawler()
|
// r := NewSSHHeahthCrawler()
|
||||||
|
//
|
||||||
m := make(map[string]interface{}, 0)
|
// m := make(map[string]interface{}, 0)
|
||||||
|
//
|
||||||
m["ip"] = "192.168.1.215"
|
// m["ip"] = "192.168.1.215"
|
||||||
m["port"] = "22"
|
// m["port"] = "22"
|
||||||
m["portType"] = "tcp"
|
// m["portType"] = "tcp"
|
||||||
m["ssl"] = false
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
r.PutConfig("r", m)
|
// r.PutConfig("r", m)
|
||||||
|
//
|
||||||
return r
|
// return r
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestMatch(t *testing.T) {
|
//func TestMatch(t *testing.T) {
|
||||||
// test config
|
// // test config
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
out := param.Output{}
|
// out := param.Output{}
|
||||||
r.Get("r", &out)
|
// r.Get("r", &out)
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(out.Data, &check)
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func start() {
|
//func start() {
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
of_rpc.AddDelegate("r", r)
|
// of_rpc.AddDelegate("r", r)
|
||||||
err := of_rpc.StartJSONRPC()
|
// err := of_rpc.StartJSONRPC()
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Fatal(err)
|
// log.Fatal(err)
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestRPC(t *testing.T) {
|
//func TestRPC(t *testing.T) {
|
||||||
go start()
|
// go start()
|
||||||
time.Sleep(2 * time.Second)
|
// time.Sleep(2 * time.Second)
|
||||||
|
//
|
||||||
in := param.Input{
|
// in := param.Input{
|
||||||
Name: "r",
|
// Name: "r",
|
||||||
Id: "r",
|
// Id: "r",
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
result, err := client.InvokeJSONRPCGet("50000", in)
|
// result, err := client.InvokeJSONRPCGet("50000", in)
|
||||||
|
//
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
t.Fatal(err)
|
// t.Fatal(err)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(result.Data, &check)
|
// json.Unmarshal(result.Data, &check)
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
|
||||||
//package ssh_protocol_crawler
|
//package ssh_protocol_crawler
|
||||||
//
|
//
|
||||||
|
@ -1,75 +1,75 @@
|
|||||||
package telnet_protocol_crawler
|
package telnet_protocol_crawler
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"encoding/json"
|
// "encoding/json"
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
"github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
"log"
|
// "log"
|
||||||
"testing"
|
// "testing"
|
||||||
"time"
|
// "time"
|
||||||
)
|
//)
|
||||||
|
//
|
||||||
func setConfig() crawler.Crawler {
|
//func setConfig() crawler.Crawler {
|
||||||
|
//
|
||||||
r := NewTelnetHeahthCrawler()
|
// r := NewTelnetHeahthCrawler()
|
||||||
|
//
|
||||||
m := make(map[string]interface{}, 0)
|
// m := make(map[string]interface{}, 0)
|
||||||
|
//
|
||||||
m["ip"] = "192.168.1.215"
|
// m["ip"] = "192.168.1.215"
|
||||||
m["port"] = "23"
|
// m["port"] = "23"
|
||||||
m["portType"] = "tcp"
|
// m["portType"] = "tcp"
|
||||||
m["ssl"] = false
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
r.PutConfig("r", m)
|
// r.PutConfig("r", m)
|
||||||
|
//
|
||||||
return r
|
// return r
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestMatch(t *testing.T) {
|
//func TestMatch(t *testing.T) {
|
||||||
// test config
|
// // test config
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
out := param.Output{}
|
// out := param.Output{}
|
||||||
r.Get("r", &out)
|
// r.Get("r", &out)
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(out.Data, &check)
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func start() {
|
//func start() {
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
of_rpc.AddDelegate("r", r)
|
// of_rpc.AddDelegate("r", r)
|
||||||
err := of_rpc.StartJSONRPC()
|
// err := of_rpc.StartJSONRPC()
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Fatal(err)
|
// log.Fatal(err)
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestRPC(t *testing.T) {
|
//func TestRPC(t *testing.T) {
|
||||||
go start()
|
// go start()
|
||||||
time.Sleep(2 * time.Second)
|
// time.Sleep(2 * time.Second)
|
||||||
|
//
|
||||||
in := param.Input{
|
// in := param.Input{
|
||||||
Name: "r",
|
// Name: "r",
|
||||||
Id: "r",
|
// Id: "r",
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
result, err := client.InvokeJSONRPCGet("50000", in)
|
// result, err := client.InvokeJSONRPCGet("50000", in)
|
||||||
|
//
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
t.Fatal(err)
|
// t.Fatal(err)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(result.Data, &check)
|
// json.Unmarshal(result.Data, &check)
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
|
||||||
//package main
|
//package main
|
||||||
//
|
//
|
||||||
|
@ -1,75 +1,75 @@
|
|||||||
package wmi_protocol_crawler
|
package wmi_protocol_crawler
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"encoding/json"
|
// "encoding/json"
|
||||||
"git.loafle.net/overflow/of_rpc_go"
|
// "git.loafle.net/overflow/of_rpc_go"
|
||||||
"git.loafle.net/overflow/of_rpc_go/client"
|
// "git.loafle.net/overflow/of_rpc_go/client"
|
||||||
"git.loafle.net/overflow/of_rpc_go/models/param"
|
// "git.loafle.net/overflow/of_rpc_go/models/param"
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
// "git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
"github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
"log"
|
// "log"
|
||||||
"testing"
|
// "testing"
|
||||||
"time"
|
// "time"
|
||||||
)
|
//)
|
||||||
|
//
|
||||||
func setConfig() crawler.Crawler {
|
//func setConfig() crawler.Crawler {
|
||||||
|
//
|
||||||
r := NewWMIHeahthCrawler()
|
// r := NewWMIHeahthCrawler()
|
||||||
|
//
|
||||||
m := make(map[string]interface{}, 0)
|
// m := make(map[string]interface{}, 0)
|
||||||
|
//
|
||||||
m["ip"] = "192.168.1.1"
|
// m["ip"] = "192.168.1.1"
|
||||||
m["port"] = "135"
|
// m["port"] = "135"
|
||||||
m["portType"] = "tcp"
|
// m["portType"] = "tcp"
|
||||||
m["ssl"] = false
|
// m["ssl"] = false
|
||||||
|
//
|
||||||
r.PutConfig("r", m)
|
// r.PutConfig("r", m)
|
||||||
|
//
|
||||||
return r
|
// return r
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestMatch(t *testing.T) {
|
//func TestMatch(t *testing.T) {
|
||||||
// test config
|
// // test config
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
out := param.Output{}
|
// out := param.Output{}
|
||||||
r.Get("r", &out)
|
// r.Get("r", &out)
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(out.Data, &check)
|
// json.Unmarshal(out.Data, &check)
|
||||||
|
//
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func start() {
|
//func start() {
|
||||||
r := setConfig()
|
// r := setConfig()
|
||||||
|
//
|
||||||
of_rpc.AddDelegate("r", r)
|
// of_rpc.AddDelegate("r", r)
|
||||||
err := of_rpc.StartJSONRPC()
|
// err := of_rpc.StartJSONRPC()
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Fatal(err)
|
// log.Fatal(err)
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestRPC(t *testing.T) {
|
//func TestRPC(t *testing.T) {
|
||||||
go start()
|
// go start()
|
||||||
time.Sleep(2 * time.Second)
|
// time.Sleep(2 * time.Second)
|
||||||
|
//
|
||||||
in := param.Input{
|
// in := param.Input{
|
||||||
Name: "r",
|
// Name: "r",
|
||||||
Id: "r",
|
// Id: "r",
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
result, err := client.InvokeJSONRPCGet("50000", in)
|
// result, err := client.InvokeJSONRPCGet("50000", in)
|
||||||
|
//
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
t.Fatal(err)
|
// t.Fatal(err)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
var check bool
|
// var check bool
|
||||||
json.Unmarshal(result.Data, &check)
|
// json.Unmarshal(result.Data, &check)
|
||||||
assert.Equal(t, true, check)
|
// assert.Equal(t, true, check)
|
||||||
}
|
//}
|
||||||
|
|
||||||
//package wmi_protocol_crawler
|
//package wmi_protocol_crawler
|
||||||
//
|
//
|
||||||
|
@ -3,11 +3,11 @@ package test
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler"
|
"git.loafle.net/overflow/overflow_probe/crawler"
|
||||||
"git.loafle.net/overflow/overflow_probe/crawler/health_crawler/redis_protocol_crawler"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"git.loafle.net/overflow/overflow_probe/crawler/health_crawler/redis_protocol_crawler_go"
|
||||||
)
|
)
|
||||||
|
|
||||||
func initConfig() crawler.CrawlerImpl {
|
func initConfig() crawler.CrawlerImpl {
|
||||||
|
@ -1,83 +1,83 @@
|
|||||||
package communicate
|
package communicate
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"bytes"
|
// "bytes"
|
||||||
"encoding/json"
|
// "encoding/json"
|
||||||
"fmt"
|
// "fmt"
|
||||||
"github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
"gopkg.in/gin-gonic/gin.v1"
|
// "gopkg.in/gin-gonic/gin.v1"
|
||||||
"io/ioutil"
|
// "io/ioutil"
|
||||||
|
//
|
||||||
"git.loafle.net/overflow/overflow_probe/central/client/events"
|
// "git.loafle.net/overflow/overflow_probe/central/client/events"
|
||||||
"net/http"
|
// "net/http"
|
||||||
"net/http/httptest"
|
// "net/http/httptest"
|
||||||
"testing"
|
// "testing"
|
||||||
)
|
//)
|
||||||
|
//
|
||||||
func TestCommunicatorInit(t *testing.T) {
|
//func TestCommunicatorInit(t *testing.T) {
|
||||||
assert.NotNil(t, _c)
|
// assert.NotNil(t, _c)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func makeGin() *gin.Engine {
|
//func makeGin() *gin.Engine {
|
||||||
r := gin.New()
|
// r := gin.New()
|
||||||
api := r.Group("/_api")
|
// api := r.Group("/_api")
|
||||||
{
|
// {
|
||||||
collector := api.Group("/collector")
|
// collector := api.Group("/collector")
|
||||||
{
|
// {
|
||||||
event := collector.Group("/event")
|
// event := collector.Group("/event")
|
||||||
{
|
// {
|
||||||
{
|
// {
|
||||||
types := event.Group("/status")
|
// types := event.Group("/status")
|
||||||
{
|
// {
|
||||||
types.POST("/:type", func(c *gin.Context) {
|
// types.POST("/:type", func(c *gin.Context) {
|
||||||
fmt.Println("called /_api/collector/event/status/:type")
|
// fmt.Println("called /_api/collector/event/status/:type")
|
||||||
var j events.Event
|
// var j events.Event
|
||||||
c.BindJSON(&j)
|
// c.BindJSON(&j)
|
||||||
fmt.Println(j)
|
// fmt.Println(j)
|
||||||
c.JSON(http.StatusOK, gin.H{"status": "ok"})
|
// c.JSON(http.StatusOK, gin.H{"status": "ok"})
|
||||||
})
|
// })
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return r
|
// return r
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestSend(t *testing.T) {
|
//func TestSend(t *testing.T) {
|
||||||
|
//
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
// ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
}))
|
// }))
|
||||||
defer ts.Close()
|
// defer ts.Close()
|
||||||
for i := 0; i < 10; i++ {
|
// for i := 0; i < 10; i++ {
|
||||||
e := events.NewEvent(events.CENTRAL_EVENT, events.CollectorInstallEvent{Version: "Test"})
|
// e := events.NewEvent(events.CENTRAL_EVENT, events.CollectorInstallEvent{Version: "Test"})
|
||||||
Send(e)
|
// Send(e)
|
||||||
// t.Log(e.GetResult())
|
// // t.Log(e.GetResult())
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestRealSendByGin(t *testing.T) {
|
//func TestRealSendByGin(t *testing.T) {
|
||||||
|
//
|
||||||
SetRootURL("http://localhost:8080")
|
// SetRootURL("http://localhost:8080")
|
||||||
|
//
|
||||||
e := events.NewEvent(events.CENTRAL_EVENT, events.NewInstallEvent("TestInstallEvent"))
|
// e := events.NewEvent(events.CENTRAL_EVENT, events.NewInstallEvent("TestInstallEvent"))
|
||||||
data, _ := json.Marshal(&e)
|
// data, _ := json.Marshal(&e)
|
||||||
|
//
|
||||||
var u events.URLMaker
|
// var u events.URLMaker
|
||||||
u = e.Data.(events.URLMaker)
|
// u = e.Data.(events.URLMaker)
|
||||||
t.Log(GetRootURL() + u.GetUrl())
|
// t.Log(GetRootURL() + u.GetUrl())
|
||||||
req := httptest.NewRequest("POST", u.GetUrl(), bytes.NewReader(data))
|
// req := httptest.NewRequest("POST", u.GetUrl(), bytes.NewReader(data))
|
||||||
w := httptest.NewRecorder()
|
// w := httptest.NewRecorder()
|
||||||
|
//
|
||||||
g := makeGin()
|
// g := makeGin()
|
||||||
g.ServeHTTP(w, req)
|
// g.ServeHTTP(w, req)
|
||||||
|
//
|
||||||
if w.Code != http.StatusOK {
|
// if w.Code != http.StatusOK {
|
||||||
t.Errorf("Home page didn't return %v", http.StatusOK)
|
// t.Errorf("Home page didn't return %v", http.StatusOK)
|
||||||
} else {
|
// } else {
|
||||||
t.Log("OKOKOK")
|
// t.Log("OKOKOK")
|
||||||
data, _ := ioutil.ReadAll(w.Body)
|
// data, _ := ioutil.ReadAll(w.Body)
|
||||||
t.Log(string(data))
|
// t.Log(string(data))
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
package communicate
|
package communicate
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"bytes"
|
// "bytes"
|
||||||
"encoding/json"
|
// "encoding/json"
|
||||||
|
//
|
||||||
"git.loafle.net/overflow/overflow_probe/central/client/events"
|
// "git.loafle.net/overflow/overflow_probe/central/client/events"
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/types/timestamp"
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/types/timestamp"
|
||||||
"net/http"
|
// "net/http"
|
||||||
"testing"
|
// "testing"
|
||||||
)
|
//)
|
||||||
|
//
|
||||||
func TestEventCollector(t *testing.T) {
|
//func TestEventCollector(t *testing.T) {
|
||||||
ev := events.Event{}
|
// ev := events.Event{}
|
||||||
|
//
|
||||||
ev.EventType = "install"
|
// ev.EventType = "install"
|
||||||
ev.Time = timestamp.Now()
|
// ev.Time = timestamp.Now()
|
||||||
ev.Collector_id = "1111111"
|
// ev.Collector_id = "1111111"
|
||||||
ev.Data = events.CollectorInstallEvent{Version: "2.2"}
|
// ev.Data = events.CollectorInstallEvent{Version: "2.2"}
|
||||||
|
//
|
||||||
bb, _ := json.Marshal(ev)
|
// bb, _ := json.Marshal(ev)
|
||||||
|
//
|
||||||
//com := CompressTest(CompressDataGzip, UnCompressDataGzip, bb)
|
// //com := CompressTest(CompressDataGzip, UnCompressDataGzip, bb)
|
||||||
|
//
|
||||||
http.Post("http://localhost:9090/_api/collector/event/status/install", "application/json", bytes.NewBuffer(bb))
|
// http.Post("http://localhost:9090/_api/collector/event/status/install", "application/json", bytes.NewBuffer(bb))
|
||||||
}
|
//}
|
||||||
|
@ -1,235 +1,235 @@
|
|||||||
package ftp
|
package ftp
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"fmt"
|
// "fmt"
|
||||||
"testing"
|
// "testing"
|
||||||
|
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
|
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/scaninfo"
|
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/types"
|
|
||||||
log "github.com/cihub/seelog"
|
|
||||||
"net"
|
|
||||||
)
|
|
||||||
|
|
||||||
//type FTP struct {
|
|
||||||
// conn net.Conn
|
|
||||||
// addr string
|
|
||||||
//
|
//
|
||||||
// reader *bufio.Reader
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
|
||||||
// writer *bufio.Writer
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/scaninfo"
|
||||||
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/types"
|
||||||
|
// log "github.com/cihub/seelog"
|
||||||
|
// "net"
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
////type FTP struct {
|
||||||
|
//// conn net.Conn
|
||||||
|
//// addr string
|
||||||
|
////
|
||||||
|
//// reader *bufio.Reader
|
||||||
|
//// writer *bufio.Writer
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func (ftp *FTP) Close() {
|
||||||
|
//// ftp.conn.Close()
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func Connect(addr string) (*FTP, error) {
|
||||||
|
//// var err error
|
||||||
|
//// var conn net.Conn
|
||||||
|
////
|
||||||
|
//// if conn, err = net.Dial("tcp", addr); err != nil {
|
||||||
|
//// return nil, err
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// writer := bufio.NewWriter(conn)
|
||||||
|
//// reader := bufio.NewReader(conn)
|
||||||
|
////
|
||||||
|
//// obj := &FTP{
|
||||||
|
//// conn:conn,
|
||||||
|
//// addr:addr,
|
||||||
|
//// reader:reader,
|
||||||
|
//// writer:writer,
|
||||||
|
//// }
|
||||||
|
//// recv, _ := obj.receive()
|
||||||
|
////
|
||||||
|
//// fmt.Println(recv)
|
||||||
|
////
|
||||||
|
//// return obj, nil
|
||||||
|
////
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func (ftp *FTP) receive() (string, error) {
|
||||||
|
//// line, err := ftp.receiveLine()
|
||||||
|
////
|
||||||
|
//// if err != nil {
|
||||||
|
//// return line, err
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// fmt.Println("len : ", len(line))
|
||||||
|
//// fmt.Println("line[3] :", line[3])
|
||||||
|
//// //
|
||||||
|
//// //if (len(line) >= 4) && (line[3] == '-') {
|
||||||
|
//// // closingCode := line[:3] + " "
|
||||||
|
//// //
|
||||||
|
//// // for {
|
||||||
|
//// // str, err := ftp.receiveLine()
|
||||||
|
//// // fmt.Println("str pre: ", str)
|
||||||
|
//// // line = line + str
|
||||||
|
//// // fmt.Println("str after: ", line)
|
||||||
|
//// // if err != nil {
|
||||||
|
//// // return line, err
|
||||||
|
//// // }
|
||||||
|
//// //
|
||||||
|
//// // if len(str) < 4 {
|
||||||
|
//// // fmt.Println("Uncorrectly terminated response")
|
||||||
|
//// // }else {
|
||||||
|
//// // if str[:4] == closingCode {
|
||||||
|
//// // break
|
||||||
|
//// // }
|
||||||
|
//// // }
|
||||||
|
//// // }
|
||||||
|
//// //}
|
||||||
|
////
|
||||||
|
//// ftp.ReadAndDiscard()
|
||||||
|
////
|
||||||
|
//// fmt.Println("receive line: ", line)
|
||||||
|
//// return line, err
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func (ftp *FTP) ReadAndDiscard() (int, error) {
|
||||||
|
//// var i int
|
||||||
|
//// bufferSize := ftp.reader.Buffered()
|
||||||
|
////
|
||||||
|
//// for i = 0; i < bufferSize ; i++ {
|
||||||
|
//// if _, err := ftp.reader.ReadByte(); err != nil {
|
||||||
|
//// return i, err
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// return i, nil
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func (ftp *FTP) send(command string, arguments ...interface{}) error {
|
||||||
|
////
|
||||||
|
//// command = fmt.Sprintf(command)
|
||||||
|
//// command += "\r\n"
|
||||||
|
////
|
||||||
|
//// if _, err := ftp.writer.WriteString(command); err != nil {
|
||||||
|
//// return err
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// if err := ftp.writer.Flush(); err != nil {
|
||||||
|
//// return err
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// return nil
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func (ftp *FTP) cmd(expects string, command string, args ...interface{}) (line string, err error) {
|
||||||
|
////
|
||||||
|
//// if err = ftp.send(command, args); err != nil {
|
||||||
|
//// return
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// if line, err = ftp.receive(); err != nil {
|
||||||
|
//// return
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
////
|
||||||
|
//// if !strings.HasPrefix(line, expects) {
|
||||||
|
//// err = errors.New(line)
|
||||||
|
//// return
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// return
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func (ftp *FTP) receiveLine() (string, error) {
|
||||||
|
//// line, err := ftp.reader.ReadString('\n')
|
||||||
|
////
|
||||||
|
//// log.Printf("< %s", line)
|
||||||
|
////
|
||||||
|
//// return line, err
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func (ftp *FTP) Syst() (line string, err error) {
|
||||||
|
//// if err := ftp.send("SYST"); err != nil {
|
||||||
|
//// return "", err
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// if line, err = ftp.receive(); err != nil {
|
||||||
|
//// return
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// if !strings.HasPrefix(line, "215") {
|
||||||
|
//// err = errors.New(line)
|
||||||
|
//// return
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// return strings.SplitN(strings.TrimSpace(line), " ", 2)[1], nil
|
||||||
|
////}
|
||||||
|
//
|
||||||
|
////func TestFtp(t *testing.T) {
|
||||||
|
//// var err error
|
||||||
|
//// var ftp *FTP
|
||||||
|
//// //var f *FTPMatcher
|
||||||
|
////
|
||||||
|
//// if ftp, err = Connect("192.168.1.202:21"); err != nil {
|
||||||
|
//// panic(err)
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// //f.Match(0, nil,nil)
|
||||||
|
//// ftp.Syst()
|
||||||
|
//// ftp.cmd("503","PASS ")
|
||||||
|
//// ftp.cmd("221","QUIT")
|
||||||
|
//// defer ftp.Close()
|
||||||
|
////}
|
||||||
|
//
|
||||||
|
//func TestMatchFTP(t *testing.T) {
|
||||||
|
// ftm := NewFTPMatcher()
|
||||||
|
// //fmt.Println(ftm)
|
||||||
|
// //fmt.Println(ftm.sendPackets[0])
|
||||||
|
//
|
||||||
|
// //log.LoadLogConfig("../../../../../../../../bin/log.xml")
|
||||||
|
// //defer log.Flush()
|
||||||
|
//
|
||||||
|
// port := types.NewPort("21", types.NewHost("192.168.1.202"), types.TYPE_TCP)
|
||||||
|
// info := scaninfo.NewServiceScanInfo(port)
|
||||||
|
//
|
||||||
|
// var ipport string
|
||||||
|
// ipport = port.Host.Ip + ":" + string(port.Port)
|
||||||
|
//
|
||||||
|
// log.Debug(ipport)
|
||||||
|
//
|
||||||
|
// client, _ := net.Dial("tcp", ipport)
|
||||||
|
//
|
||||||
|
// defer client.Close()
|
||||||
|
//
|
||||||
|
// //reader := bufio.NewReader(client)
|
||||||
|
// //writer := bufio.NewWriter(client)
|
||||||
|
//
|
||||||
|
// fmt.Println(ftm.PacketCount())
|
||||||
|
// //fmt.Println(reader.ReadString('\n'))
|
||||||
|
//
|
||||||
|
// bytes := make([]byte, 512)
|
||||||
|
//
|
||||||
|
// le, _ := client.Read(bytes)
|
||||||
|
//
|
||||||
|
// fmt.Println(bytes)
|
||||||
|
//
|
||||||
|
// b := ftm.Match(0, packet.NewPacket(bytes, le), nil)
|
||||||
|
//
|
||||||
|
// fmt.Println(b)
|
||||||
|
//
|
||||||
|
// for ii := 0; ii < ftm.PacketCount(); ii++ {
|
||||||
|
// pack := ftm.Packet(ii)
|
||||||
|
//
|
||||||
|
// fmt.Println(pack)
|
||||||
|
//
|
||||||
|
// //writer.WriteString(pack)
|
||||||
|
// client.Write(pack.Buffer)
|
||||||
|
// //fmt.Println(reader.ReadString('\n'))
|
||||||
|
// bytes := make([]byte, 512)
|
||||||
|
//
|
||||||
|
// l, _ := client.Read(bytes)
|
||||||
|
//
|
||||||
|
// //fmt.Println(bytes)
|
||||||
|
//
|
||||||
|
// b := ftm.Match(ii+1, packet.NewPacket(bytes, l), info)
|
||||||
|
//
|
||||||
|
// fmt.Println(b)
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// fmt.Println("Service Name : ", ftm.ServiceName())
|
||||||
//}
|
//}
|
||||||
//
|
|
||||||
//func (ftp *FTP) Close() {
|
|
||||||
// ftp.conn.Close()
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func Connect(addr string) (*FTP, error) {
|
|
||||||
// var err error
|
|
||||||
// var conn net.Conn
|
|
||||||
//
|
|
||||||
// if conn, err = net.Dial("tcp", addr); err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// writer := bufio.NewWriter(conn)
|
|
||||||
// reader := bufio.NewReader(conn)
|
|
||||||
//
|
|
||||||
// obj := &FTP{
|
|
||||||
// conn:conn,
|
|
||||||
// addr:addr,
|
|
||||||
// reader:reader,
|
|
||||||
// writer:writer,
|
|
||||||
// }
|
|
||||||
// recv, _ := obj.receive()
|
|
||||||
//
|
|
||||||
// fmt.Println(recv)
|
|
||||||
//
|
|
||||||
// return obj, nil
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (ftp *FTP) receive() (string, error) {
|
|
||||||
// line, err := ftp.receiveLine()
|
|
||||||
//
|
|
||||||
// if err != nil {
|
|
||||||
// return line, err
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// fmt.Println("len : ", len(line))
|
|
||||||
// fmt.Println("line[3] :", line[3])
|
|
||||||
// //
|
|
||||||
// //if (len(line) >= 4) && (line[3] == '-') {
|
|
||||||
// // closingCode := line[:3] + " "
|
|
||||||
// //
|
|
||||||
// // for {
|
|
||||||
// // str, err := ftp.receiveLine()
|
|
||||||
// // fmt.Println("str pre: ", str)
|
|
||||||
// // line = line + str
|
|
||||||
// // fmt.Println("str after: ", line)
|
|
||||||
// // if err != nil {
|
|
||||||
// // return line, err
|
|
||||||
// // }
|
|
||||||
// //
|
|
||||||
// // if len(str) < 4 {
|
|
||||||
// // fmt.Println("Uncorrectly terminated response")
|
|
||||||
// // }else {
|
|
||||||
// // if str[:4] == closingCode {
|
|
||||||
// // break
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
// //}
|
|
||||||
//
|
|
||||||
// ftp.ReadAndDiscard()
|
|
||||||
//
|
|
||||||
// fmt.Println("receive line: ", line)
|
|
||||||
// return line, err
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (ftp *FTP) ReadAndDiscard() (int, error) {
|
|
||||||
// var i int
|
|
||||||
// bufferSize := ftp.reader.Buffered()
|
|
||||||
//
|
|
||||||
// for i = 0; i < bufferSize ; i++ {
|
|
||||||
// if _, err := ftp.reader.ReadByte(); err != nil {
|
|
||||||
// return i, err
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return i, nil
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (ftp *FTP) send(command string, arguments ...interface{}) error {
|
|
||||||
//
|
|
||||||
// command = fmt.Sprintf(command)
|
|
||||||
// command += "\r\n"
|
|
||||||
//
|
|
||||||
// if _, err := ftp.writer.WriteString(command); err != nil {
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if err := ftp.writer.Flush(); err != nil {
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return nil
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (ftp *FTP) cmd(expects string, command string, args ...interface{}) (line string, err error) {
|
|
||||||
//
|
|
||||||
// if err = ftp.send(command, args); err != nil {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if line, err = ftp.receive(); err != nil {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// if !strings.HasPrefix(line, expects) {
|
|
||||||
// err = errors.New(line)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (ftp *FTP) receiveLine() (string, error) {
|
|
||||||
// line, err := ftp.reader.ReadString('\n')
|
|
||||||
//
|
|
||||||
// log.Printf("< %s", line)
|
|
||||||
//
|
|
||||||
// return line, err
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (ftp *FTP) Syst() (line string, err error) {
|
|
||||||
// if err := ftp.send("SYST"); err != nil {
|
|
||||||
// return "", err
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if line, err = ftp.receive(); err != nil {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if !strings.HasPrefix(line, "215") {
|
|
||||||
// err = errors.New(line)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return strings.SplitN(strings.TrimSpace(line), " ", 2)[1], nil
|
|
||||||
//}
|
|
||||||
|
|
||||||
//func TestFtp(t *testing.T) {
|
|
||||||
// var err error
|
|
||||||
// var ftp *FTP
|
|
||||||
// //var f *FTPMatcher
|
|
||||||
//
|
|
||||||
// if ftp, err = Connect("192.168.1.202:21"); err != nil {
|
|
||||||
// panic(err)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //f.Match(0, nil,nil)
|
|
||||||
// ftp.Syst()
|
|
||||||
// ftp.cmd("503","PASS ")
|
|
||||||
// ftp.cmd("221","QUIT")
|
|
||||||
// defer ftp.Close()
|
|
||||||
//}
|
|
||||||
|
|
||||||
func TestMatchFTP(t *testing.T) {
|
|
||||||
ftm := NewFTPMatcher()
|
|
||||||
//fmt.Println(ftm)
|
|
||||||
//fmt.Println(ftm.sendPackets[0])
|
|
||||||
|
|
||||||
//log.LoadLogConfig("../../../../../../../../bin/log.xml")
|
|
||||||
//defer log.Flush()
|
|
||||||
|
|
||||||
port := types.NewPort("21", types.NewHost("192.168.1.202"), types.TYPE_TCP)
|
|
||||||
info := scaninfo.NewServiceScanInfo(port)
|
|
||||||
|
|
||||||
var ipport string
|
|
||||||
ipport = port.Host.Ip + ":" + string(port.Port)
|
|
||||||
|
|
||||||
log.Debug(ipport)
|
|
||||||
|
|
||||||
client, _ := net.Dial("tcp", ipport)
|
|
||||||
|
|
||||||
defer client.Close()
|
|
||||||
|
|
||||||
//reader := bufio.NewReader(client)
|
|
||||||
//writer := bufio.NewWriter(client)
|
|
||||||
|
|
||||||
fmt.Println(ftm.PacketCount())
|
|
||||||
//fmt.Println(reader.ReadString('\n'))
|
|
||||||
|
|
||||||
bytes := make([]byte, 512)
|
|
||||||
|
|
||||||
le, _ := client.Read(bytes)
|
|
||||||
|
|
||||||
fmt.Println(bytes)
|
|
||||||
|
|
||||||
b := ftm.Match(0, packet.NewPacket(bytes, le), nil)
|
|
||||||
|
|
||||||
fmt.Println(b)
|
|
||||||
|
|
||||||
for ii := 0; ii < ftm.PacketCount(); ii++ {
|
|
||||||
pack := ftm.Packet(ii)
|
|
||||||
|
|
||||||
fmt.Println(pack)
|
|
||||||
|
|
||||||
//writer.WriteString(pack)
|
|
||||||
client.Write(pack.Buffer)
|
|
||||||
//fmt.Println(reader.ReadString('\n'))
|
|
||||||
bytes := make([]byte, 512)
|
|
||||||
|
|
||||||
l, _ := client.Read(bytes)
|
|
||||||
|
|
||||||
//fmt.Println(bytes)
|
|
||||||
|
|
||||||
b := ftm.Match(ii+1, packet.NewPacket(bytes, l), info)
|
|
||||||
|
|
||||||
fmt.Println(b)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("Service Name : ", ftm.ServiceName())
|
|
||||||
}
|
|
||||||
|
@ -1,55 +1,55 @@
|
|||||||
package http
|
package http
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"crypto/tls"
|
// "crypto/tls"
|
||||||
"fmt"
|
// "fmt"
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
|
||||||
"log"
|
// "log"
|
||||||
"net"
|
// "net"
|
||||||
"testing"
|
// "testing"
|
||||||
"time"
|
// "time"
|
||||||
)
|
//)
|
||||||
|
//
|
||||||
func TestHTTPSMatcher_Match(t *testing.T) {
|
//func TestHTTPSMatcher_Match(t *testing.T) {
|
||||||
netinfo := "192.168.1.1:443"
|
// netinfo := "192.168.1.1:443"
|
||||||
dialer := &net.Dialer{
|
// dialer := &net.Dialer{
|
||||||
Timeout: 5 * time.Second,
|
// Timeout: 5 * time.Second,
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
conn, err := tls.DialWithDialer(
|
// conn, err := tls.DialWithDialer(
|
||||||
dialer,
|
// dialer,
|
||||||
"tcp",
|
// "tcp",
|
||||||
netinfo,
|
// netinfo,
|
||||||
&tls.Config{
|
// &tls.Config{
|
||||||
InsecureSkipVerify: true,
|
// InsecureSkipVerify: true,
|
||||||
ServerName: "192.168.1.103",
|
// ServerName: "192.168.1.103",
|
||||||
},
|
// },
|
||||||
)
|
// )
|
||||||
|
//
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Println(err)
|
// log.Println(err)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
defer conn.Close()
|
// defer conn.Close()
|
||||||
|
//
|
||||||
//fmt.Println(conn)
|
// //fmt.Println(conn)
|
||||||
h := NewHTTPMatcher()
|
// h := NewHTTPMatcher()
|
||||||
|
//
|
||||||
pac := h.Packet(0)
|
// pac := h.Packet(0)
|
||||||
|
//
|
||||||
//fmt.Println(pac)
|
// //fmt.Println(pac)
|
||||||
//fmt.Println(pac.Buffer)
|
// //fmt.Println(pac.Buffer)
|
||||||
|
//
|
||||||
//bytes := make([]byte, 1024)
|
// //bytes := make([]byte, 1024)
|
||||||
|
//
|
||||||
l, _ := conn.Write(pac.Buffer)
|
// l, _ := conn.Write(pac.Buffer)
|
||||||
|
//
|
||||||
buf := make([]byte, 1024)
|
// buf := make([]byte, 1024)
|
||||||
l, _ = conn.Read(buf)
|
// l, _ = conn.Read(buf)
|
||||||
|
//
|
||||||
fmt.Println(string(buf))
|
// fmt.Println(string(buf))
|
||||||
fmt.Println(l)
|
// fmt.Println(l)
|
||||||
is := h.Match(0, packet.NewPacket(buf, l), nil)
|
// is := h.Match(0, packet.NewPacket(buf, l), nil)
|
||||||
fmt.Println(is)
|
// fmt.Println(is)
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
@ -1,147 +1,147 @@
|
|||||||
package imap
|
package imap
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"crypto/tls"
|
// "crypto/tls"
|
||||||
"fmt"
|
// "fmt"
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/scaninfo"
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/scaninfo"
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/types"
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/types"
|
||||||
"net"
|
// "net"
|
||||||
"testing"
|
// "testing"
|
||||||
)
|
//)
|
||||||
|
//
|
||||||
func ImapRun(client net.Conn, t *testing.T) {
|
//func ImapRun(client net.Conn, t *testing.T) {
|
||||||
|
//
|
||||||
lm := NewIMAPMatcher()
|
// lm := NewIMAPMatcher()
|
||||||
|
//
|
||||||
port := types.NewPort("143", types.NewHost("192.168.1.215"), types.TYPE_TCP)
|
// port := types.NewPort("143", types.NewHost("192.168.1.215"), types.TYPE_TCP)
|
||||||
|
//
|
||||||
scanInfo := scaninfo.NewServiceScanInfo(port)
|
// scanInfo := scaninfo.NewServiceScanInfo(port)
|
||||||
|
//
|
||||||
var ipport string
|
// var ipport string
|
||||||
ipport = port.Host.Ip + ":" + string(port.Port)
|
// ipport = port.Host.Ip + ":" + string(port.Port)
|
||||||
|
//
|
||||||
fmt.Println(ipport)
|
// fmt.Println(ipport)
|
||||||
//client, _ := net.Dial("tcp", ipport)
|
// //client, _ := net.Dial("tcp", ipport)
|
||||||
|
//
|
||||||
//defer client.Close()
|
// //defer client.Close()
|
||||||
|
//
|
||||||
bytett := make([]byte, 1024)
|
// bytett := make([]byte, 1024)
|
||||||
|
//
|
||||||
rr, _ := client.Read(bytett)
|
// rr, _ := client.Read(bytett)
|
||||||
|
//
|
||||||
bb := lm.Match(0, packet.NewPacket(bytett, rr), scanInfo)
|
// bb := lm.Match(0, packet.NewPacket(bytett, rr), scanInfo)
|
||||||
|
//
|
||||||
if bb {
|
// if bb {
|
||||||
t.Log("good!")
|
// t.Log("good!")
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
fmt.Println(lm.PacketCount())
|
// fmt.Println(lm.PacketCount())
|
||||||
|
//
|
||||||
for ii := 0; ii < lm.PacketCount(); ii++ {
|
// for ii := 0; ii < lm.PacketCount(); ii++ {
|
||||||
|
//
|
||||||
pack := lm.Packet(ii)
|
// pack := lm.Packet(ii)
|
||||||
|
//
|
||||||
//fmt.Println(pack)
|
// //fmt.Println(pack)
|
||||||
|
//
|
||||||
client.Write(pack.Buffer)
|
// client.Write(pack.Buffer)
|
||||||
|
//
|
||||||
bytes := make([]byte, 1024)
|
// bytes := make([]byte, 1024)
|
||||||
|
//
|
||||||
read, _ := client.Read(bytes)
|
// read, _ := client.Read(bytes)
|
||||||
|
//
|
||||||
fmt.Println(cap(bytes))
|
// fmt.Println(cap(bytes))
|
||||||
|
//
|
||||||
//fmt.Println(bytes)
|
// //fmt.Println(bytes)
|
||||||
|
//
|
||||||
b := lm.Match(ii+1, packet.NewPacket(bytes, read), scanInfo)
|
// b := lm.Match(ii+1, packet.NewPacket(bytes, read), scanInfo)
|
||||||
|
//
|
||||||
if b {
|
// if b {
|
||||||
t.Log("send Good!")
|
// t.Log("send Good!")
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
t.Log(scanInfo)
|
// t.Log(scanInfo)
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestIMapTls(t *testing.T) {
|
//func TestIMapTls(t *testing.T) {
|
||||||
|
//
|
||||||
conn, _ := tls.Dial(
|
// conn, _ := tls.Dial(
|
||||||
"tcp",
|
// "tcp",
|
||||||
"192.168.1.215:993",
|
// "192.168.1.215:993",
|
||||||
&tls.Config{
|
// &tls.Config{
|
||||||
InsecureSkipVerify: true,
|
// InsecureSkipVerify: true,
|
||||||
ServerName: "192.168.1.215",
|
// ServerName: "192.168.1.215",
|
||||||
},
|
// },
|
||||||
)
|
// )
|
||||||
|
//
|
||||||
defer conn.Close()
|
// defer conn.Close()
|
||||||
|
//
|
||||||
ImapRun(conn, t)
|
// ImapRun(conn, t)
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestIMapNormal(t *testing.T) {
|
//func TestIMapNormal(t *testing.T) {
|
||||||
|
//
|
||||||
client, _ := net.Dial("tcp", "192.168.1.215:143")
|
// client, _ := net.Dial("tcp", "192.168.1.215:143")
|
||||||
|
//
|
||||||
defer client.Close()
|
// defer client.Close()
|
||||||
|
//
|
||||||
ImapRun(client, t)
|
// ImapRun(client, t)
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func TestImap(t *testing.T) {
|
//func TestImap(t *testing.T) {
|
||||||
|
//
|
||||||
lm := NewIMAPMatcher()
|
// lm := NewIMAPMatcher()
|
||||||
|
//
|
||||||
port := types.NewPort("143", types.NewHost("192.168.1.215"), types.TYPE_TCP)
|
// port := types.NewPort("143", types.NewHost("192.168.1.215"), types.TYPE_TCP)
|
||||||
|
//
|
||||||
scanInfo := scaninfo.NewServiceScanInfo(port)
|
// scanInfo := scaninfo.NewServiceScanInfo(port)
|
||||||
|
//
|
||||||
var ipport string
|
// var ipport string
|
||||||
ipport = port.Host.Ip + ":" + string(port.Port)
|
// ipport = port.Host.Ip + ":" + string(port.Port)
|
||||||
|
//
|
||||||
fmt.Println(ipport)
|
// fmt.Println(ipport)
|
||||||
client, _ := net.Dial("tcp", ipport)
|
// client, _ := net.Dial("tcp", ipport)
|
||||||
|
//
|
||||||
defer client.Close()
|
// defer client.Close()
|
||||||
|
//
|
||||||
bytett := make([]byte, 1024)
|
// bytett := make([]byte, 1024)
|
||||||
|
//
|
||||||
rr, _ := client.Read(bytett)
|
// rr, _ := client.Read(bytett)
|
||||||
|
//
|
||||||
bb := lm.Match(0, packet.NewPacket(bytett, rr), scanInfo)
|
// bb := lm.Match(0, packet.NewPacket(bytett, rr), scanInfo)
|
||||||
|
//
|
||||||
if bb {
|
// if bb {
|
||||||
t.Log("good!")
|
// t.Log("good!")
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
fmt.Println(lm.PacketCount())
|
// fmt.Println(lm.PacketCount())
|
||||||
|
//
|
||||||
for ii := 0; ii < lm.PacketCount(); ii++ {
|
// for ii := 0; ii < lm.PacketCount(); ii++ {
|
||||||
|
//
|
||||||
pack := lm.Packet(ii)
|
// pack := lm.Packet(ii)
|
||||||
|
//
|
||||||
//fmt.Println(pack)
|
// //fmt.Println(pack)
|
||||||
|
//
|
||||||
client.Write(pack.Buffer)
|
// client.Write(pack.Buffer)
|
||||||
|
//
|
||||||
bytes := make([]byte, 1024)
|
// bytes := make([]byte, 1024)
|
||||||
|
//
|
||||||
read, _ := client.Read(bytes)
|
// read, _ := client.Read(bytes)
|
||||||
|
//
|
||||||
fmt.Println(cap(bytes))
|
// fmt.Println(cap(bytes))
|
||||||
|
//
|
||||||
//fmt.Println(bytes)
|
// //fmt.Println(bytes)
|
||||||
|
//
|
||||||
b := lm.Match(ii+1, packet.NewPacket(bytes, read), scanInfo)
|
// b := lm.Match(ii+1, packet.NewPacket(bytes, read), scanInfo)
|
||||||
|
//
|
||||||
if b {
|
// if b {
|
||||||
t.Log("send Good!")
|
// t.Log("send Good!")
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
t.Log(scanInfo)
|
// t.Log(scanInfo)
|
||||||
}
|
//}
|
||||||
|
@ -1,109 +1,109 @@
|
|||||||
package ldap
|
package ldap
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"crypto/tls"
|
// "crypto/tls"
|
||||||
"fmt"
|
// "fmt"
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/scaninfo"
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/scaninfo"
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/types"
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/types"
|
||||||
"net"
|
// "net"
|
||||||
"testing"
|
// "testing"
|
||||||
)
|
//)
|
||||||
|
//
|
||||||
//func SetUp() {
|
////func SetUp() {
|
||||||
// fmt.Println("SetUp")
|
//// fmt.Println("SetUp")
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func TearDown() {
|
||||||
|
//// fmt.Println("TearDown")
|
||||||
|
////}
|
||||||
|
//
|
||||||
|
////func TestMain(m *testing.M) {
|
||||||
|
//// SetUp()
|
||||||
|
//// m.Run()
|
||||||
|
//// TearDown()
|
||||||
|
////}
|
||||||
|
//
|
||||||
|
//func TestAAAA(t *testing.T) {
|
||||||
|
// ///animals := []Animal{Dog{}, Cat{}, Llama{}, JavaProgrammer{}}
|
||||||
|
//
|
||||||
|
// var ttt [][]int = make([][]int, 10)
|
||||||
|
//
|
||||||
|
// var aaa []int
|
||||||
|
// aaa = append(aaa, 111)
|
||||||
|
//
|
||||||
|
// ttt = append(ttt, aaa)
|
||||||
|
//
|
||||||
|
// fmt.Println(cap(ttt))
|
||||||
|
//
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//func TearDown() {
|
//func ldapRun(client net.Conn, t *testing.T) {
|
||||||
// fmt.Println("TearDown")
|
// lm := NewLDAPMatcher()
|
||||||
|
//
|
||||||
|
// port := types.NewPort("389", types.NewHost("192.168.1.215"), types.TYPE_TCP)
|
||||||
|
// scanInfo := scaninfo.NewServiceScanInfo(port)
|
||||||
|
// var ipport string
|
||||||
|
// ipport = port.Host.Ip + ":" + string(port.Port)
|
||||||
|
//
|
||||||
|
// fmt.Println(ipport)
|
||||||
|
// //client, _ := net.Dial("tcp", ipport)
|
||||||
|
// //defer client.Close()
|
||||||
|
//
|
||||||
|
// fmt.Println(lm.PacketCount())
|
||||||
|
//
|
||||||
|
// for ii := 0; ii < lm.PacketCount(); ii++ {
|
||||||
|
//
|
||||||
|
// pack := lm.Packet(ii)
|
||||||
|
//
|
||||||
|
// bytes := make([]byte, 1024)
|
||||||
|
//
|
||||||
|
// client.Write(pack.Buffer)
|
||||||
|
//
|
||||||
|
// read, _ := client.Read(bytes)
|
||||||
|
//
|
||||||
|
// if read <= 0 {
|
||||||
|
// bb := lm.IsNoResponse(ii)
|
||||||
|
// if bb {
|
||||||
|
//
|
||||||
|
// t.Log("IsNoResponse good")
|
||||||
|
// break
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// fmt.Println(bytes)
|
||||||
|
//
|
||||||
|
// b := lm.Match(ii, packet.NewPacket(bytes, read), scanInfo)
|
||||||
|
//
|
||||||
|
// if b {
|
||||||
|
// t.Log("Good")
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// t.Log(scanInfo)
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
//func TestMain(m *testing.M) {
|
//func TestLdapTls(t *testing.T) {
|
||||||
// SetUp()
|
// conn, _ := tls.Dial(
|
||||||
// m.Run()
|
// "tcp",
|
||||||
// TearDown()
|
// "192.168.1.215:636",
|
||||||
|
// &tls.Config{
|
||||||
|
// InsecureSkipVerify: true,
|
||||||
|
// ServerName: "192.168.1.215",
|
||||||
|
// },
|
||||||
|
// )
|
||||||
|
//
|
||||||
|
// defer conn.Close()
|
||||||
|
//
|
||||||
|
// ldapRun(conn, t)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func TestLdapNormal(t *testing.T) {
|
||||||
|
// client, _ := net.Dial("tcp", "192.168.1.215:389")
|
||||||
|
//
|
||||||
|
// defer client.Close()
|
||||||
|
//
|
||||||
|
// ldapRun(client, t)
|
||||||
//}
|
//}
|
||||||
|
|
||||||
func TestAAAA(t *testing.T) {
|
|
||||||
///animals := []Animal{Dog{}, Cat{}, Llama{}, JavaProgrammer{}}
|
|
||||||
|
|
||||||
var ttt [][]int = make([][]int, 10)
|
|
||||||
|
|
||||||
var aaa []int
|
|
||||||
aaa = append(aaa, 111)
|
|
||||||
|
|
||||||
ttt = append(ttt, aaa)
|
|
||||||
|
|
||||||
fmt.Println(cap(ttt))
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func ldapRun(client net.Conn, t *testing.T) {
|
|
||||||
lm := NewLDAPMatcher()
|
|
||||||
|
|
||||||
port := types.NewPort("389", types.NewHost("192.168.1.215"), types.TYPE_TCP)
|
|
||||||
scanInfo := scaninfo.NewServiceScanInfo(port)
|
|
||||||
var ipport string
|
|
||||||
ipport = port.Host.Ip + ":" + string(port.Port)
|
|
||||||
|
|
||||||
fmt.Println(ipport)
|
|
||||||
//client, _ := net.Dial("tcp", ipport)
|
|
||||||
//defer client.Close()
|
|
||||||
|
|
||||||
fmt.Println(lm.PacketCount())
|
|
||||||
|
|
||||||
for ii := 0; ii < lm.PacketCount(); ii++ {
|
|
||||||
|
|
||||||
pack := lm.Packet(ii)
|
|
||||||
|
|
||||||
bytes := make([]byte, 1024)
|
|
||||||
|
|
||||||
client.Write(pack.Buffer)
|
|
||||||
|
|
||||||
read, _ := client.Read(bytes)
|
|
||||||
|
|
||||||
if read <= 0 {
|
|
||||||
bb := lm.IsNoResponse(ii)
|
|
||||||
if bb {
|
|
||||||
|
|
||||||
t.Log("IsNoResponse good")
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println(bytes)
|
|
||||||
|
|
||||||
b := lm.Match(ii, packet.NewPacket(bytes, read), scanInfo)
|
|
||||||
|
|
||||||
if b {
|
|
||||||
t.Log("Good")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Log(scanInfo)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestLdapTls(t *testing.T) {
|
|
||||||
conn, _ := tls.Dial(
|
|
||||||
"tcp",
|
|
||||||
"192.168.1.215:636",
|
|
||||||
&tls.Config{
|
|
||||||
InsecureSkipVerify: true,
|
|
||||||
ServerName: "192.168.1.215",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
defer conn.Close()
|
|
||||||
|
|
||||||
ldapRun(conn, t)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestLdapNormal(t *testing.T) {
|
|
||||||
client, _ := net.Dial("tcp", "192.168.1.215:389")
|
|
||||||
|
|
||||||
defer client.Close()
|
|
||||||
|
|
||||||
ldapRun(client, t)
|
|
||||||
}
|
|
||||||
|
@ -1,63 +1,63 @@
|
|||||||
package mssql
|
package mssql
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
|
||||||
"net"
|
// "net"
|
||||||
"testing"
|
// "testing"
|
||||||
)
|
//)
|
||||||
|
|
||||||
/*
|
|
||||||
192.168.1.106:1433 - normal
|
|
||||||
192.168.1.103:1433 - ssl
|
|
||||||
*/
|
|
||||||
func TestSqlNor(t *testing.T) {
|
|
||||||
|
|
||||||
conn, _ := net.Dial("tcp", "192.168.1.103:1433")
|
|
||||||
|
|
||||||
defer conn.Close()
|
|
||||||
|
|
||||||
sqlServerRun(conn, t)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//func TestSqlTLS(t *testing.T) {
|
|
||||||
// conn, err := tls.Dial(
|
|
||||||
// "tcp",
|
|
||||||
// "192.168.1.103:7680",
|
|
||||||
// &tls.Config{
|
|
||||||
// InsecureSkipVerify: true,
|
|
||||||
// ServerName: "192.168.1.103",
|
|
||||||
// },
|
|
||||||
// )
|
|
||||||
//
|
//
|
||||||
// if err != nil {
|
///*
|
||||||
// t.Log(err)
|
//192.168.1.106:1433 - normal
|
||||||
// return
|
//192.168.1.103:1433 - ssl
|
||||||
// }
|
//*/
|
||||||
|
//func TestSqlNor(t *testing.T) {
|
||||||
|
//
|
||||||
|
// conn, _ := net.Dial("tcp", "192.168.1.103:1433")
|
||||||
//
|
//
|
||||||
// defer conn.Close()
|
// defer conn.Close()
|
||||||
//
|
//
|
||||||
// sqlServerRun(conn, t)
|
// sqlServerRun(conn, t)
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
////func TestSqlTLS(t *testing.T) {
|
||||||
|
//// conn, err := tls.Dial(
|
||||||
|
//// "tcp",
|
||||||
|
//// "192.168.1.103:7680",
|
||||||
|
//// &tls.Config{
|
||||||
|
//// InsecureSkipVerify: true,
|
||||||
|
//// ServerName: "192.168.1.103",
|
||||||
|
//// },
|
||||||
|
//// )
|
||||||
|
////
|
||||||
|
//// if err != nil {
|
||||||
|
//// t.Log(err)
|
||||||
|
//// return
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// defer conn.Close()
|
||||||
|
////
|
||||||
|
//// sqlServerRun(conn, t)
|
||||||
|
////}
|
||||||
|
//
|
||||||
|
//func sqlServerRun(conn net.Conn, t *testing.T) {
|
||||||
|
//
|
||||||
|
// m := NewMSSqlMatcher()
|
||||||
|
//
|
||||||
|
// for i := 0; i < m.PacketCount(); i++ {
|
||||||
|
//
|
||||||
|
// pack := m.Packet(i)
|
||||||
|
// conn.Write(pack.Buffer)
|
||||||
|
// bytes := make([]byte, 1024)
|
||||||
|
// n, _ := conn.Read(bytes)
|
||||||
|
// p := packet.NewPacket(bytes, n)
|
||||||
|
//
|
||||||
|
// if m.Match(i, p, nil) {
|
||||||
|
// t.Log(m.ServiceName())
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// t.Error("MSSQL not found")
|
||||||
|
// }
|
||||||
|
//
|
||||||
//}
|
//}
|
||||||
|
|
||||||
func sqlServerRun(conn net.Conn, t *testing.T) {
|
|
||||||
|
|
||||||
m := NewMSSqlMatcher()
|
|
||||||
|
|
||||||
for i := 0; i < m.PacketCount(); i++ {
|
|
||||||
|
|
||||||
pack := m.Packet(i)
|
|
||||||
conn.Write(pack.Buffer)
|
|
||||||
bytes := make([]byte, 1024)
|
|
||||||
n, _ := conn.Read(bytes)
|
|
||||||
p := packet.NewPacket(bytes, n)
|
|
||||||
|
|
||||||
if m.Match(i, p, nil) {
|
|
||||||
t.Log(m.ServiceName())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Error("MSSQL not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
package netbios
|
package netbios
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
|
||||||
"net"
|
// "net"
|
||||||
"testing"
|
// "testing"
|
||||||
)
|
//)
|
||||||
|
//
|
||||||
func TestNBSS(t *testing.T) {
|
//func TestNBSS(t *testing.T) {
|
||||||
|
//
|
||||||
m := NewNetBiosMatcher()
|
// m := NewNetBiosMatcher()
|
||||||
|
//
|
||||||
conn, _ := net.Dial("tcp", "192.168.1.202:139")
|
// conn, _ := net.Dial("tcp", "192.168.1.202:139")
|
||||||
|
//
|
||||||
defer conn.Close()
|
// defer conn.Close()
|
||||||
|
//
|
||||||
for i := 0; i < m.PacketCount(); i++ {
|
// for i := 0; i < m.PacketCount(); i++ {
|
||||||
|
//
|
||||||
pack := m.Packet(i)
|
// pack := m.Packet(i)
|
||||||
conn.Write(pack)
|
// conn.Write(pack)
|
||||||
bytes := make([]byte, 1024)
|
// bytes := make([]byte, 1024)
|
||||||
n, _ := conn.Read(bytes)
|
// n, _ := conn.Read(bytes)
|
||||||
p := packet.NewPacket(bytes, n)
|
// p := packet.NewPacket(bytes, n)
|
||||||
|
//
|
||||||
if m.Match(i, p, nil) {
|
// if m.Match(i, p, nil) {
|
||||||
t.Log("NBSS found")
|
// t.Log("NBSS found")
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
t.Error("NBSS not found")
|
// t.Error("NBSS not found")
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
@ -1,52 +1,52 @@
|
|||||||
package oracle
|
package oracle
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"fmt"
|
// "fmt"
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/scaninfo"
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/scaninfo"
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/types"
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/types"
|
||||||
"net"
|
// "net"
|
||||||
"testing"
|
// "testing"
|
||||||
)
|
//)
|
||||||
|
//
|
||||||
func TestOracle(t *testing.T) {
|
//func TestOracle(t *testing.T) {
|
||||||
|
//
|
||||||
lm := NewOracleMatcher()
|
// lm := NewOracleMatcher()
|
||||||
|
//
|
||||||
port := types.NewPort("1521", types.NewHost("192.168.1.30"), types.TYPE_TCP)
|
// port := types.NewPort("1521", types.NewHost("192.168.1.30"), types.TYPE_TCP)
|
||||||
scanInfo := scaninfo.NewServiceScanInfo(port)
|
// scanInfo := scaninfo.NewServiceScanInfo(port)
|
||||||
var ipport string
|
// var ipport string
|
||||||
ipport = port.Host.Ip + ":" + string(port.Port)
|
// ipport = port.Host.Ip + ":" + string(port.Port)
|
||||||
|
//
|
||||||
fmt.Println(ipport)
|
// fmt.Println(ipport)
|
||||||
client, _ := net.Dial("tcp", ipport)
|
// client, _ := net.Dial("tcp", ipport)
|
||||||
|
//
|
||||||
defer client.Close()
|
// defer client.Close()
|
||||||
|
//
|
||||||
fmt.Println(lm.PacketCount())
|
// fmt.Println(lm.PacketCount())
|
||||||
|
//
|
||||||
for ii := 0; ii < lm.PacketCount(); ii++ {
|
// for ii := 0; ii < lm.PacketCount(); ii++ {
|
||||||
|
//
|
||||||
pack := lm.Packet(ii)
|
// pack := lm.Packet(ii)
|
||||||
|
//
|
||||||
fmt.Println(pack)
|
// fmt.Println(pack)
|
||||||
|
//
|
||||||
client.Write(pack.Buffer)
|
// client.Write(pack.Buffer)
|
||||||
|
//
|
||||||
bytes := make([]byte, 1024)
|
// bytes := make([]byte, 1024)
|
||||||
|
//
|
||||||
read, _ := client.Read(bytes)
|
// read, _ := client.Read(bytes)
|
||||||
|
//
|
||||||
fmt.Println(bytes)
|
// fmt.Println(bytes)
|
||||||
|
//
|
||||||
b := lm.Match(ii, packet.NewPacket(bytes, read), scanInfo)
|
// b := lm.Match(ii, packet.NewPacket(bytes, read), scanInfo)
|
||||||
|
//
|
||||||
if b {
|
// if b {
|
||||||
t.Log("Good")
|
// t.Log("Good")
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
t.Log(scanInfo)
|
// t.Log(scanInfo)
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
@ -1,85 +1,86 @@
|
|||||||
package pop
|
package pop
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"crypto/tls"
|
// "crypto/tls"
|
||||||
"fmt"
|
// "fmt"
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
|
//
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/scaninfo"
|
// "net"
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/types"
|
// "testing"
|
||||||
"net"
|
// "git.loafle.net/overflow/overflow_probe/model/scaninfo"
|
||||||
"testing"
|
// "git.loafle.net/overflow/overflow_probe/matcher/packet"
|
||||||
)
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/types"
|
||||||
|
//)
|
||||||
func TestPopTLS(t *testing.T) {
|
//
|
||||||
conn, _ := tls.Dial(
|
//func TestPopTLS(t *testing.T) {
|
||||||
"tcp",
|
// conn, _ := tls.Dial(
|
||||||
"192.168.1.215:995",
|
// "tcp",
|
||||||
&tls.Config{
|
// "192.168.1.215:995",
|
||||||
InsecureSkipVerify: true,
|
// &tls.Config{
|
||||||
ServerName: "192.168.1.215",
|
// InsecureSkipVerify: true,
|
||||||
},
|
// ServerName: "192.168.1.215",
|
||||||
)
|
// },
|
||||||
|
// )
|
||||||
defer conn.Close()
|
//
|
||||||
|
// defer conn.Close()
|
||||||
pop3Run(conn, t)
|
//
|
||||||
}
|
// pop3Run(conn, t)
|
||||||
|
//}
|
||||||
func TestPopNor(t *testing.T) {
|
//
|
||||||
|
//func TestPopNor(t *testing.T) {
|
||||||
client, _ := net.Dial("tcp", "192.168.1.215:110")
|
//
|
||||||
|
// client, _ := net.Dial("tcp", "192.168.1.215:110")
|
||||||
defer client.Close()
|
//
|
||||||
|
// defer client.Close()
|
||||||
pop3Run(client, t)
|
//
|
||||||
|
// pop3Run(client, t)
|
||||||
}
|
//
|
||||||
|
//}
|
||||||
func pop3Run(client net.Conn, t *testing.T) {
|
//
|
||||||
|
//func pop3Run(client net.Conn, t *testing.T) {
|
||||||
lm := NewPOPMatcher()
|
//
|
||||||
|
// lm := NewPOPMatcher()
|
||||||
port := types.NewPort("110", types.NewHost("192.168.1.215"), types.TYPE_TCP)
|
//
|
||||||
scanInfo := scaninfo.NewServiceScanInfo(port)
|
// port := types.NewPort("110", types.NewHost("192.168.1.215"), types.TYPE_TCP)
|
||||||
var ipport string
|
// scanInfo := scaninfo.NewServiceScanInfo(port)
|
||||||
ipport = port.Host.Ip + ":" + string(port.Port)
|
// var ipport string
|
||||||
|
// ipport = port.Host.Ip + ":" + string(port.Port)
|
||||||
fmt.Println(ipport)
|
//
|
||||||
|
// fmt.Println(ipport)
|
||||||
bytett := make([]byte, 1024)
|
//
|
||||||
|
// bytett := make([]byte, 1024)
|
||||||
read, _ := client.Read(bytett)
|
//
|
||||||
|
// read, _ := client.Read(bytett)
|
||||||
bb := lm.Match(0, packet.NewPacket(bytett, read), scanInfo)
|
//
|
||||||
|
// bb := lm.Match(0, packet.NewPacket(bytett, read), scanInfo)
|
||||||
if bb {
|
//
|
||||||
t.Log("good!")
|
// if bb {
|
||||||
}
|
// t.Log("good!")
|
||||||
|
// }
|
||||||
fmt.Println(lm.PacketCount())
|
//
|
||||||
|
// fmt.Println(lm.PacketCount())
|
||||||
for ii := 0; ii < lm.PacketCount(); ii++ {
|
//
|
||||||
|
// for ii := 0; ii < lm.PacketCount(); ii++ {
|
||||||
pack := lm.Packet(ii)
|
//
|
||||||
|
// pack := lm.Packet(ii)
|
||||||
//fmt.Println(pack)
|
//
|
||||||
|
// //fmt.Println(pack)
|
||||||
client.Write(pack.Buffer)
|
//
|
||||||
|
// client.Write(pack.Buffer)
|
||||||
bytes := make([]byte, 1024)
|
//
|
||||||
|
// bytes := make([]byte, 1024)
|
||||||
rr, _ := client.Read(bytes)
|
//
|
||||||
|
// rr, _ := client.Read(bytes)
|
||||||
//fmt.Println(bytes)
|
//
|
||||||
|
// //fmt.Println(bytes)
|
||||||
b := lm.Match(ii+1, packet.NewPacket(bytes, rr), scanInfo)
|
//
|
||||||
|
// b := lm.Match(ii+1, packet.NewPacket(bytes, rr), scanInfo)
|
||||||
if b {
|
//
|
||||||
t.Log("send Good!")
|
// if b {
|
||||||
}
|
// t.Log("send Good!")
|
||||||
|
// }
|
||||||
}
|
//
|
||||||
|
// }
|
||||||
t.Log(scanInfo)
|
//
|
||||||
|
// t.Log(scanInfo)
|
||||||
}
|
//
|
||||||
|
//}
|
||||||
|
@ -1,51 +1,51 @@
|
|||||||
package wmi
|
package wmi
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"fmt"
|
// "fmt"
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/scaninfo"
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/scaninfo"
|
||||||
"git.loafle.net/overflow/overflow_probe/discovery/discovery/types"
|
// "git.loafle.net/overflow/overflow_probe/discovery/discovery/types"
|
||||||
"net"
|
// "net"
|
||||||
"testing"
|
// "testing"
|
||||||
)
|
//)
|
||||||
|
//
|
||||||
func TestWMI(t *testing.T) {
|
//func TestWMI(t *testing.T) {
|
||||||
|
//
|
||||||
lm := NewWMIMatcher()
|
// lm := NewWMIMatcher()
|
||||||
|
//
|
||||||
port := types.NewPort("135", types.NewHost("192.168.1.1"), types.TYPE_TCP)
|
// port := types.NewPort("135", types.NewHost("192.168.1.1"), types.TYPE_TCP)
|
||||||
scanInfo := scaninfo.NewServiceScanInfo(port)
|
// scanInfo := scaninfo.NewServiceScanInfo(port)
|
||||||
var ipport string
|
// var ipport string
|
||||||
ipport = port.Host.Ip + ":" + string(port.Port)
|
// ipport = port.Host.Ip + ":" + string(port.Port)
|
||||||
|
//
|
||||||
fmt.Println(ipport)
|
// fmt.Println(ipport)
|
||||||
client, _ := net.Dial("tcp", ipport)
|
// client, _ := net.Dial("tcp", ipport)
|
||||||
|
//
|
||||||
defer client.Close()
|
// defer client.Close()
|
||||||
|
//
|
||||||
fmt.Println(lm.PacketCount())
|
// fmt.Println(lm.PacketCount())
|
||||||
|
//
|
||||||
for ii := 0; ii < lm.PacketCount(); ii++ {
|
// for ii := 0; ii < lm.PacketCount(); ii++ {
|
||||||
|
//
|
||||||
pack := lm.Packet(ii)
|
// pack := lm.Packet(ii)
|
||||||
|
//
|
||||||
fmt.Println(pack)
|
// fmt.Println(pack)
|
||||||
|
//
|
||||||
client.Write(pack.Buffer)
|
// client.Write(pack.Buffer)
|
||||||
|
//
|
||||||
bytes := make([]byte, 1024)
|
// bytes := make([]byte, 1024)
|
||||||
|
//
|
||||||
read, _ := client.Read(bytes)
|
// read, _ := client.Read(bytes)
|
||||||
|
//
|
||||||
//fmt.Println(bytes)
|
// //fmt.Println(bytes)
|
||||||
|
//
|
||||||
b := lm.Match(ii, packet.NewPacket(bytes, read), scanInfo)
|
// b := lm.Match(ii, packet.NewPacket(bytes, read), scanInfo)
|
||||||
|
//
|
||||||
if b {
|
// if b {
|
||||||
fmt.Println("Good")
|
// fmt.Println("Good")
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
t.Log(scanInfo)
|
// t.Log(scanInfo)
|
||||||
}
|
//}
|
||||||
|
@ -1,235 +1,235 @@
|
|||||||
package ftp
|
package ftp
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"fmt"
|
// "fmt"
|
||||||
"testing"
|
// "testing"
|
||||||
|
|
||||||
"git.loafle.net/overflow/overflow_probe/collector/discovery/scan/matcher/packet"
|
|
||||||
"git.loafle.net/overflow/overflow_probe/collector/discovery/scan/matcher/scaninfo"
|
|
||||||
"git.loafle.net/overflow/overflow_probe/collector/discovery/types"
|
|
||||||
log "github.com/cihub/seelog"
|
|
||||||
"net"
|
|
||||||
)
|
|
||||||
|
|
||||||
//type FTP struct {
|
|
||||||
// conn net.Conn
|
|
||||||
// addr string
|
|
||||||
//
|
//
|
||||||
// reader *bufio.Reader
|
// "git.loafle.net/overflow/overflow_probe/collector/discovery/scan/matcher/packet"
|
||||||
// writer *bufio.Writer
|
// "git.loafle.net/overflow/overflow_probe/collector/discovery/scan/matcher/scaninfo"
|
||||||
|
// "git.loafle.net/overflow/overflow_probe/collector/discovery/types"
|
||||||
|
// log "github.com/cihub/seelog"
|
||||||
|
// "net"
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
////type FTP struct {
|
||||||
|
//// conn net.Conn
|
||||||
|
//// addr string
|
||||||
|
////
|
||||||
|
//// reader *bufio.Reader
|
||||||
|
//// writer *bufio.Writer
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func (ftp *FTP) Close() {
|
||||||
|
//// ftp.conn.Close()
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func Connect(addr string) (*FTP, error) {
|
||||||
|
//// var err error
|
||||||
|
//// var conn net.Conn
|
||||||
|
////
|
||||||
|
//// if conn, err = net.Dial("tcp", addr); err != nil {
|
||||||
|
//// return nil, err
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// writer := bufio.NewWriter(conn)
|
||||||
|
//// reader := bufio.NewReader(conn)
|
||||||
|
////
|
||||||
|
//// obj := &FTP{
|
||||||
|
//// conn:conn,
|
||||||
|
//// addr:addr,
|
||||||
|
//// reader:reader,
|
||||||
|
//// writer:writer,
|
||||||
|
//// }
|
||||||
|
//// recv, _ := obj.receive()
|
||||||
|
////
|
||||||
|
//// fmt.Println(recv)
|
||||||
|
////
|
||||||
|
//// return obj, nil
|
||||||
|
////
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func (ftp *FTP) receive() (string, error) {
|
||||||
|
//// line, err := ftp.receiveLine()
|
||||||
|
////
|
||||||
|
//// if err != nil {
|
||||||
|
//// return line, err
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// fmt.Println("len : ", len(line))
|
||||||
|
//// fmt.Println("line[3] :", line[3])
|
||||||
|
//// //
|
||||||
|
//// //if (len(line) >= 4) && (line[3] == '-') {
|
||||||
|
//// // closingCode := line[:3] + " "
|
||||||
|
//// //
|
||||||
|
//// // for {
|
||||||
|
//// // str, err := ftp.receiveLine()
|
||||||
|
//// // fmt.Println("str pre: ", str)
|
||||||
|
//// // line = line + str
|
||||||
|
//// // fmt.Println("str after: ", line)
|
||||||
|
//// // if err != nil {
|
||||||
|
//// // return line, err
|
||||||
|
//// // }
|
||||||
|
//// //
|
||||||
|
//// // if len(str) < 4 {
|
||||||
|
//// // fmt.Println("Uncorrectly terminated response")
|
||||||
|
//// // }else {
|
||||||
|
//// // if str[:4] == closingCode {
|
||||||
|
//// // break
|
||||||
|
//// // }
|
||||||
|
//// // }
|
||||||
|
//// // }
|
||||||
|
//// //}
|
||||||
|
////
|
||||||
|
//// ftp.ReadAndDiscard()
|
||||||
|
////
|
||||||
|
//// fmt.Println("receive line: ", line)
|
||||||
|
//// return line, err
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func (ftp *FTP) ReadAndDiscard() (int, error) {
|
||||||
|
//// var i int
|
||||||
|
//// bufferSize := ftp.reader.Buffered()
|
||||||
|
////
|
||||||
|
//// for i = 0; i < bufferSize ; i++ {
|
||||||
|
//// if _, err := ftp.reader.ReadByte(); err != nil {
|
||||||
|
//// return i, err
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// return i, nil
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func (ftp *FTP) send(command string, arguments ...interface{}) error {
|
||||||
|
////
|
||||||
|
//// command = fmt.Sprintf(command)
|
||||||
|
//// command += "\r\n"
|
||||||
|
////
|
||||||
|
//// if _, err := ftp.writer.WriteString(command); err != nil {
|
||||||
|
//// return err
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// if err := ftp.writer.Flush(); err != nil {
|
||||||
|
//// return err
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// return nil
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func (ftp *FTP) cmd(expects string, command string, args ...interface{}) (line string, err error) {
|
||||||
|
////
|
||||||
|
//// if err = ftp.send(command, args); err != nil {
|
||||||
|
//// return
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// if line, err = ftp.receive(); err != nil {
|
||||||
|
//// return
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
////
|
||||||
|
//// if !strings.HasPrefix(line, expects) {
|
||||||
|
//// err = errors.New(line)
|
||||||
|
//// return
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// return
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func (ftp *FTP) receiveLine() (string, error) {
|
||||||
|
//// line, err := ftp.reader.ReadString('\n')
|
||||||
|
////
|
||||||
|
//// log.Printf("< %s", line)
|
||||||
|
////
|
||||||
|
//// return line, err
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
////func (ftp *FTP) Syst() (line string, err error) {
|
||||||
|
//// if err := ftp.send("SYST"); err != nil {
|
||||||
|
//// return "", err
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// if line, err = ftp.receive(); err != nil {
|
||||||
|
//// return
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// if !strings.HasPrefix(line, "215") {
|
||||||
|
//// err = errors.New(line)
|
||||||
|
//// return
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// return strings.SplitN(strings.TrimSpace(line), " ", 2)[1], nil
|
||||||
|
////}
|
||||||
|
//
|
||||||
|
////func TestFtp(t *testing.T) {
|
||||||
|
//// var err error
|
||||||
|
//// var ftp *FTP
|
||||||
|
//// //var f *FTPMatcher
|
||||||
|
////
|
||||||
|
//// if ftp, err = Connect("192.168.1.202:21"); err != nil {
|
||||||
|
//// panic(err)
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// //f.Match(0, nil,nil)
|
||||||
|
//// ftp.Syst()
|
||||||
|
//// ftp.cmd("503","PASS ")
|
||||||
|
//// ftp.cmd("221","QUIT")
|
||||||
|
//// defer ftp.Close()
|
||||||
|
////}
|
||||||
|
//
|
||||||
|
//func TestMatchFTP(t *testing.T) {
|
||||||
|
// ftm := NewFTPMatcher()
|
||||||
|
// //fmt.Println(ftm)
|
||||||
|
// //fmt.Println(ftm.sendPackets[0])
|
||||||
|
//
|
||||||
|
// //log.LoadLogConfig("../../../../../../../../bin/log.xml")
|
||||||
|
// //defer log.Flush()
|
||||||
|
//
|
||||||
|
// port := types.NewPort("21", types.NewHost("192.168.1.202"), types.TYPE_TCP)
|
||||||
|
// info := scaninfo.NewServiceScanInfo(port)
|
||||||
|
//
|
||||||
|
// var ipport string
|
||||||
|
// ipport = port.Host.Ip + ":" + string(port.Port)
|
||||||
|
//
|
||||||
|
// log.Debug(ipport)
|
||||||
|
//
|
||||||
|
// client, _ := net.Dial("tcp", ipport)
|
||||||
|
//
|
||||||
|
// defer client.Close()
|
||||||
|
//
|
||||||
|
// //reader := bufio.NewReader(client)
|
||||||
|
// //writer := bufio.NewWriter(client)
|
||||||
|
//
|
||||||
|
// fmt.Println(ftm.PacketCount())
|
||||||
|
// //fmt.Println(reader.ReadString('\n'))
|
||||||
|
//
|
||||||
|
// bytes := make([]byte, 512)
|
||||||
|
//
|
||||||
|
// le, _ := client.Read(bytes)
|
||||||
|
//
|
||||||
|
// fmt.Println(bytes)
|
||||||
|
//
|
||||||
|
// b := ftm.Match(0, packet.NewPacket(bytes, le), nil)
|
||||||
|
//
|
||||||
|
// fmt.Println(b)
|
||||||
|
//
|
||||||
|
// for ii := 0; ii < ftm.PacketCount(); ii++ {
|
||||||
|
// pack := ftm.Packet(ii)
|
||||||
|
//
|
||||||
|
// fmt.Println(pack)
|
||||||
|
//
|
||||||
|
// //writer.WriteString(pack)
|
||||||
|
// client.Write(pack.Buffer)
|
||||||
|
// //fmt.Println(reader.ReadString('\n'))
|
||||||
|
// bytes := make([]byte, 512)
|
||||||
|
//
|
||||||
|
// l, _ := client.Read(bytes)
|
||||||
|
//
|
||||||
|
// //fmt.Println(bytes)
|
||||||
|
//
|
||||||
|
// b := ftm.Match(ii+1, packet.NewPacket(bytes, l), info)
|
||||||
|
//
|
||||||
|
// fmt.Println(b)
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// fmt.Println("Service Name : ", ftm.ServiceName())
|
||||||
//}
|
//}
|
||||||
//
|
|
||||||
//func (ftp *FTP) Close() {
|
|
||||||
// ftp.conn.Close()
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func Connect(addr string) (*FTP, error) {
|
|
||||||
// var err error
|
|
||||||
// var conn net.Conn
|
|
||||||
//
|
|
||||||
// if conn, err = net.Dial("tcp", addr); err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// writer := bufio.NewWriter(conn)
|
|
||||||
// reader := bufio.NewReader(conn)
|
|
||||||
//
|
|
||||||
// obj := &FTP{
|
|
||||||
// conn:conn,
|
|
||||||
// addr:addr,
|
|
||||||
// reader:reader,
|
|
||||||
// writer:writer,
|
|
||||||
// }
|
|
||||||
// recv, _ := obj.receive()
|
|
||||||
//
|
|
||||||
// fmt.Println(recv)
|
|
||||||
//
|
|
||||||
// return obj, nil
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (ftp *FTP) receive() (string, error) {
|
|
||||||
// line, err := ftp.receiveLine()
|
|
||||||
//
|
|
||||||
// if err != nil {
|
|
||||||
// return line, err
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// fmt.Println("len : ", len(line))
|
|
||||||
// fmt.Println("line[3] :", line[3])
|
|
||||||
// //
|
|
||||||
// //if (len(line) >= 4) && (line[3] == '-') {
|
|
||||||
// // closingCode := line[:3] + " "
|
|
||||||
// //
|
|
||||||
// // for {
|
|
||||||
// // str, err := ftp.receiveLine()
|
|
||||||
// // fmt.Println("str pre: ", str)
|
|
||||||
// // line = line + str
|
|
||||||
// // fmt.Println("str after: ", line)
|
|
||||||
// // if err != nil {
|
|
||||||
// // return line, err
|
|
||||||
// // }
|
|
||||||
// //
|
|
||||||
// // if len(str) < 4 {
|
|
||||||
// // fmt.Println("Uncorrectly terminated response")
|
|
||||||
// // }else {
|
|
||||||
// // if str[:4] == closingCode {
|
|
||||||
// // break
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
// //}
|
|
||||||
//
|
|
||||||
// ftp.ReadAndDiscard()
|
|
||||||
//
|
|
||||||
// fmt.Println("receive line: ", line)
|
|
||||||
// return line, err
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (ftp *FTP) ReadAndDiscard() (int, error) {
|
|
||||||
// var i int
|
|
||||||
// bufferSize := ftp.reader.Buffered()
|
|
||||||
//
|
|
||||||
// for i = 0; i < bufferSize ; i++ {
|
|
||||||
// if _, err := ftp.reader.ReadByte(); err != nil {
|
|
||||||
// return i, err
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return i, nil
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (ftp *FTP) send(command string, arguments ...interface{}) error {
|
|
||||||
//
|
|
||||||
// command = fmt.Sprintf(command)
|
|
||||||
// command += "\r\n"
|
|
||||||
//
|
|
||||||
// if _, err := ftp.writer.WriteString(command); err != nil {
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if err := ftp.writer.Flush(); err != nil {
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return nil
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (ftp *FTP) cmd(expects string, command string, args ...interface{}) (line string, err error) {
|
|
||||||
//
|
|
||||||
// if err = ftp.send(command, args); err != nil {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if line, err = ftp.receive(); err != nil {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// if !strings.HasPrefix(line, expects) {
|
|
||||||
// err = errors.New(line)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (ftp *FTP) receiveLine() (string, error) {
|
|
||||||
// line, err := ftp.reader.ReadString('\n')
|
|
||||||
//
|
|
||||||
// log.Printf("< %s", line)
|
|
||||||
//
|
|
||||||
// return line, err
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (ftp *FTP) Syst() (line string, err error) {
|
|
||||||
// if err := ftp.send("SYST"); err != nil {
|
|
||||||
// return "", err
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if line, err = ftp.receive(); err != nil {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if !strings.HasPrefix(line, "215") {
|
|
||||||
// err = errors.New(line)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return strings.SplitN(strings.TrimSpace(line), " ", 2)[1], nil
|
|
||||||
//}
|
|
||||||
|
|
||||||
//func TestFtp(t *testing.T) {
|
|
||||||
// var err error
|
|
||||||
// var ftp *FTP
|
|
||||||
// //var f *FTPMatcher
|
|
||||||
//
|
|
||||||
// if ftp, err = Connect("192.168.1.202:21"); err != nil {
|
|
||||||
// panic(err)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //f.Match(0, nil,nil)
|
|
||||||
// ftp.Syst()
|
|
||||||
// ftp.cmd("503","PASS ")
|
|
||||||
// ftp.cmd("221","QUIT")
|
|
||||||
// defer ftp.Close()
|
|
||||||
//}
|
|
||||||
|
|
||||||
func TestMatchFTP(t *testing.T) {
|
|
||||||
ftm := NewFTPMatcher()
|
|
||||||
//fmt.Println(ftm)
|
|
||||||
//fmt.Println(ftm.sendPackets[0])
|
|
||||||
|
|
||||||
//log.LoadLogConfig("../../../../../../../../bin/log.xml")
|
|
||||||
//defer log.Flush()
|
|
||||||
|
|
||||||
port := types.NewPort("21", types.NewHost("192.168.1.202"), types.TYPE_TCP)
|
|
||||||
info := scaninfo.NewServiceScanInfo(port)
|
|
||||||
|
|
||||||
var ipport string
|
|
||||||
ipport = port.Host.Ip + ":" + string(port.Port)
|
|
||||||
|
|
||||||
log.Debug(ipport)
|
|
||||||
|
|
||||||
client, _ := net.Dial("tcp", ipport)
|
|
||||||
|
|
||||||
defer client.Close()
|
|
||||||
|
|
||||||
//reader := bufio.NewReader(client)
|
|
||||||
//writer := bufio.NewWriter(client)
|
|
||||||
|
|
||||||
fmt.Println(ftm.PacketCount())
|
|
||||||
//fmt.Println(reader.ReadString('\n'))
|
|
||||||
|
|
||||||
bytes := make([]byte, 512)
|
|
||||||
|
|
||||||
le, _ := client.Read(bytes)
|
|
||||||
|
|
||||||
fmt.Println(bytes)
|
|
||||||
|
|
||||||
b := ftm.Match(0, packet.NewPacket(bytes, le), nil)
|
|
||||||
|
|
||||||
fmt.Println(b)
|
|
||||||
|
|
||||||
for ii := 0; ii < ftm.PacketCount(); ii++ {
|
|
||||||
pack := ftm.Packet(ii)
|
|
||||||
|
|
||||||
fmt.Println(pack)
|
|
||||||
|
|
||||||
//writer.WriteString(pack)
|
|
||||||
client.Write(pack.Buffer)
|
|
||||||
//fmt.Println(reader.ReadString('\n'))
|
|
||||||
bytes := make([]byte, 512)
|
|
||||||
|
|
||||||
l, _ := client.Read(bytes)
|
|
||||||
|
|
||||||
//fmt.Println(bytes)
|
|
||||||
|
|
||||||
b := ftm.Match(ii+1, packet.NewPacket(bytes, l), info)
|
|
||||||
|
|
||||||
fmt.Println(b)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("Service Name : ", ftm.ServiceName())
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user