glide error
This commit is contained in:
		
							parent
							
								
									f5dffb050d
								
							
						
					
					
						commit
						464eeb2094
					
				@ -1,17 +1,21 @@
 | 
			
		||||
package activedirectory_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"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
//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 (
 | 
			
		||||
//	"encoding/json"
 | 
			
		||||
//	"github.com/stretchr/testify/assert"
 | 
			
		||||
@ -65,45 +69,45 @@ func setConfig() crawler.Crawler {
 | 
			
		||||
	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)
 | 
			
		||||
}
 | 
			
		||||
//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)
 | 
			
		||||
//}
 | 
			
		||||
 | 
			
		||||
@ -1,104 +1,104 @@
 | 
			
		||||
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 (
 | 
			
		||||
//	"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"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/json/client"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/models/param"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/models/protocol"
 | 
			
		||||
//	"log"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//	"time"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//func TestCheck(t *testing.T) {
 | 
			
		||||
//	b, _ := check("192.168.1.104", 9042, true)
 | 
			
		||||
//	assert.Equal(t, true, b)
 | 
			
		||||
//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(time.Second * 2)
 | 
			
		||||
//	time.Sleep(2 * time.Second)
 | 
			
		||||
//
 | 
			
		||||
//	p := protocol.HealthRequest{IsSSL: true}
 | 
			
		||||
//	b, _ := json.Marshal(p)
 | 
			
		||||
//	in := param.Input{
 | 
			
		||||
//		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)
 | 
			
		||||
//	var m protocol.HeahthResponse
 | 
			
		||||
//	json.Unmarshal(re.Data, &m)
 | 
			
		||||
//	if err != nil {
 | 
			
		||||
//		t.Fatal(err)
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	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
 | 
			
		||||
 | 
			
		||||
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 (
 | 
			
		||||
//	"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"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/json/client"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/models/param"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/models/protocol"
 | 
			
		||||
//	"log"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//	"time"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//func TestCheck(t *testing.T) {
 | 
			
		||||
//	b, _ := check("192.168.1.215", 53, false)
 | 
			
		||||
//	assert.Equal(t, true, b)
 | 
			
		||||
//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(time.Second * 2)
 | 
			
		||||
//	time.Sleep(2 * time.Second)
 | 
			
		||||
//
 | 
			
		||||
//	p := protocol.HealthRequest{IsSSL: false}
 | 
			
		||||
//	b, _ := json.Marshal(p)
 | 
			
		||||
//	in := param.Input{
 | 
			
		||||
//		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)
 | 
			
		||||
//	var m protocol.HealthResponse
 | 
			
		||||
//	json.Unmarshal(re.Data, &m)
 | 
			
		||||
//	if err != nil {
 | 
			
		||||
//		t.Fatal(err)
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	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
 | 
			
		||||
 | 
			
		||||
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) {
 | 
			
		||||
//	b, _ := check("192.168.1.215", 21, false)
 | 
			
		||||
//	assert.Equal(t, true, b)
 | 
			
		||||
//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(time.Second * 2)
 | 
			
		||||
//	time.Sleep(2 * time.Second)
 | 
			
		||||
//
 | 
			
		||||
//	p := protocol.HealthRequest{IsSSL: false}
 | 
			
		||||
//	b, _ := json.Marshal(p)
 | 
			
		||||
//	in := param.Input{
 | 
			
		||||
//		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)
 | 
			
		||||
//	var m protocol.HealthResponse
 | 
			
		||||
//	json.Unmarshal(re.Data, &m)
 | 
			
		||||
//	if err != nil {
 | 
			
		||||
//		t.Fatal(err)
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	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
 | 
			
		||||
 | 
			
		||||
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 := NewFTPSHealthCrawler()
 | 
			
		||||
	m := make(map[string]interface{}, 0)
 | 
			
		||||
 | 
			
		||||
	m["ip"] = "192.168.1.103"
 | 
			
		||||
	m["port"] = "2121"
 | 
			
		||||
	m["portType"] = "tcp"
 | 
			
		||||
	m["ssl"] = false
 | 
			
		||||
 | 
			
		||||
	r.PutConfig("ftps", m)
 | 
			
		||||
 | 
			
		||||
	return r
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestMatch(t *testing.T) {
 | 
			
		||||
	r := setConfig()
 | 
			
		||||
 | 
			
		||||
	out := param.Output{}
 | 
			
		||||
	r.Get("ftps", &out)
 | 
			
		||||
 | 
			
		||||
	var check bool
 | 
			
		||||
	json.Unmarshal(out.Data, &check)
 | 
			
		||||
 | 
			
		||||
	assert.Equal(t, true, check)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func start() {
 | 
			
		||||
	r := setConfig()
 | 
			
		||||
 | 
			
		||||
	of_rpc.AddDelegate("ftps", 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: "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)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
//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 := NewFTPSHealthCrawler()
 | 
			
		||||
//	m := make(map[string]interface{}, 0)
 | 
			
		||||
//
 | 
			
		||||
//	m["ip"] = "192.168.1.103"
 | 
			
		||||
//	m["port"] = "2121"
 | 
			
		||||
//	m["portType"] = "tcp"
 | 
			
		||||
//	m["ssl"] = false
 | 
			
		||||
//
 | 
			
		||||
//	r.PutConfig("ftps", m)
 | 
			
		||||
//
 | 
			
		||||
//	return r
 | 
			
		||||
//}
 | 
			
		||||
//
 | 
			
		||||
//func TestMatch(t *testing.T) {
 | 
			
		||||
//	r := setConfig()
 | 
			
		||||
//
 | 
			
		||||
//	out := param.Output{}
 | 
			
		||||
//	r.Get("ftps", &out)
 | 
			
		||||
//
 | 
			
		||||
//	var check bool
 | 
			
		||||
//	json.Unmarshal(out.Data, &check)
 | 
			
		||||
//
 | 
			
		||||
//	assert.Equal(t, true, check)
 | 
			
		||||
//}
 | 
			
		||||
//
 | 
			
		||||
//func start() {
 | 
			
		||||
//	r := setConfig()
 | 
			
		||||
//
 | 
			
		||||
//	of_rpc.AddDelegate("ftps", r)
 | 
			
		||||
//	err := of_rpc.StartJSONRPC()
 | 
			
		||||
//	if err != nil {
 | 
			
		||||
//		log.Fatal(err)
 | 
			
		||||
//	}
 | 
			
		||||
//}
 | 
			
		||||
//
 | 
			
		||||
//func TestRPC(t *testing.T) {
 | 
			
		||||
//
 | 
			
		||||
//	go start()
 | 
			
		||||
//	time.Sleep(time.Second * 2)
 | 
			
		||||
//	time.Sleep(2 * time.Second)
 | 
			
		||||
//
 | 
			
		||||
//	p := protocol.HealthRequest{IsSSL: false}
 | 
			
		||||
//	b, _ := json.Marshal(p)
 | 
			
		||||
//	in := param.Input{
 | 
			
		||||
//		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)
 | 
			
		||||
//	var m protocol.HealthResponse
 | 
			
		||||
//	json.Unmarshal(re.Data, &m)
 | 
			
		||||
//	if err != nil {
 | 
			
		||||
//		t.Fatal(err)
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	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
 | 
			
		||||
 | 
			
		||||
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 (
 | 
			
		||||
//	"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"
 | 
			
		||||
//	"log"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//	"time"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//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)
 | 
			
		||||
//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 (
 | 
			
		||||
////	"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
 | 
			
		||||
 | 
			
		||||
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 := NewIMAPHealthCrawler()
 | 
			
		||||
 | 
			
		||||
	m := make(map[string]interface{}, 0)
 | 
			
		||||
 | 
			
		||||
	m["ip"] = "192.168.1.215"
 | 
			
		||||
	m["port"] = "993"
 | 
			
		||||
	m["portType"] = "tcp"
 | 
			
		||||
	m["ssl"] = true
 | 
			
		||||
 | 
			
		||||
	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 (
 | 
			
		||||
//	"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 := NewIMAPHealthCrawler()
 | 
			
		||||
//
 | 
			
		||||
//	m := make(map[string]interface{}, 0)
 | 
			
		||||
//
 | 
			
		||||
//	m["ip"] = "192.168.1.215"
 | 
			
		||||
//	m["port"] = "993"
 | 
			
		||||
//	m["portType"] = "tcp"
 | 
			
		||||
//	m["ssl"] = true
 | 
			
		||||
//
 | 
			
		||||
//	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 (
 | 
			
		||||
 | 
			
		||||
@ -1,75 +1,75 @@
 | 
			
		||||
package ldap_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 := NewLDAPHealthCrawler()
 | 
			
		||||
 | 
			
		||||
	m := make(map[string]interface{}, 0)
 | 
			
		||||
 | 
			
		||||
	m["ip"] = "192.168.1.215"
 | 
			
		||||
	m["port"] = "389"
 | 
			
		||||
	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 (
 | 
			
		||||
//	"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 := NewLDAPHealthCrawler()
 | 
			
		||||
//
 | 
			
		||||
//	m := make(map[string]interface{}, 0)
 | 
			
		||||
//
 | 
			
		||||
//	m["ip"] = "192.168.1.215"
 | 
			
		||||
//	m["port"] = "389"
 | 
			
		||||
//	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 (
 | 
			
		||||
 | 
			
		||||
@ -1,105 +1,105 @@
 | 
			
		||||
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 (
 | 
			
		||||
//	"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"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/json/client"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/models/param"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/models/protocol"
 | 
			
		||||
//	"log"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//	"time"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//func TestCheck(t *testing.T) {
 | 
			
		||||
//	b, _ := check("192.168.1.104", 27017, true)
 | 
			
		||||
//	assert.Equal(t, true, b)
 | 
			
		||||
//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(time.Second * 2)
 | 
			
		||||
//	time.Sleep(2 * time.Second)
 | 
			
		||||
//
 | 
			
		||||
//	p := protocol.HealthRequest{IsSSL: true}
 | 
			
		||||
//	b, _ := json.Marshal(p)
 | 
			
		||||
//	in := param.Input{
 | 
			
		||||
//		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)
 | 
			
		||||
//	var m protocol.HealthResponse
 | 
			
		||||
//	json.Unmarshal(re.Data, &m)
 | 
			
		||||
//	if err != nil {
 | 
			
		||||
//		t.Fatal(err)
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	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
 | 
			
		||||
 | 
			
		||||
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 (
 | 
			
		||||
//	"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"
 | 
			
		||||
//	"log"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//	"time"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//func TestMatch(t *testing.T) {
 | 
			
		||||
//	b, err := check("192.168.1.106", 1433)
 | 
			
		||||
//	if err != nil {
 | 
			
		||||
//		t.Error(err)
 | 
			
		||||
//	}
 | 
			
		||||
//	assert.Equal(t, true, b)
 | 
			
		||||
//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 (
 | 
			
		||||
////	"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
 | 
			
		||||
 | 
			
		||||
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 (
 | 
			
		||||
//	"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 TestMatch(t *testing.T) {
 | 
			
		||||
//	b, err := check("192.168.1.103", 3306)
 | 
			
		||||
//	if err != nil {
 | 
			
		||||
//		t.Error(err)
 | 
			
		||||
//	}
 | 
			
		||||
//	assert.Equal(t, true, b)
 | 
			
		||||
//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 (
 | 
			
		||||
////	"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
 | 
			
		||||
 | 
			
		||||
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 (
 | 
			
		||||
//	"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"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/json/client"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/models/param"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/models/protocol"
 | 
			
		||||
//	"log"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//	"time"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//func TestCheck(t *testing.T) {
 | 
			
		||||
//	b, _ := check("192.168.1.106", 139, false)
 | 
			
		||||
//	assert.Equal(t, true, b)
 | 
			
		||||
//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(time.Second * 2)
 | 
			
		||||
//	time.Sleep(2 * time.Second)
 | 
			
		||||
//
 | 
			
		||||
//	p := protocol.HealthRequest{IsSSL: false}
 | 
			
		||||
//	b, _ := json.Marshal(p)
 | 
			
		||||
//	in := param.Input{
 | 
			
		||||
//		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)
 | 
			
		||||
//	var m protocol.HealthResponse
 | 
			
		||||
//	json.Unmarshal(re.Data, &m)
 | 
			
		||||
//	if err != nil {
 | 
			
		||||
//		t.Fatal(err)
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	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
 | 
			
		||||
 | 
			
		||||
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 (
 | 
			
		||||
//	"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"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/json/client"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/models/param"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/models/protocol"
 | 
			
		||||
//	"log"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//	"time"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//func TestCheck(t *testing.T) {
 | 
			
		||||
//	b, _ := check("192.168.1.30", 1521, false)
 | 
			
		||||
//	assert.Equal(t, true, b)
 | 
			
		||||
//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 TestCheckTls(t *testing.T) {
 | 
			
		||||
//	b, _ := check("192.168.1.215", 22, true)
 | 
			
		||||
//	assert.Equal(t, true, b)
 | 
			
		||||
//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(time.Second * 2)
 | 
			
		||||
//	time.Sleep(2 * time.Second)
 | 
			
		||||
//
 | 
			
		||||
//	p := protocol.HealthRequest{IsSSL: false}
 | 
			
		||||
//	b, _ := json.Marshal(p)
 | 
			
		||||
//	in := param.Input{
 | 
			
		||||
//		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)
 | 
			
		||||
//	var m protocol.HealthResponse
 | 
			
		||||
//	json.Unmarshal(re.Data, &m)
 | 
			
		||||
//	if err != nil {
 | 
			
		||||
//		t.Fatal(err)
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	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
 | 
			
		||||
 | 
			
		||||
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 (
 | 
			
		||||
//	"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"
 | 
			
		||||
//	"log"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//	"time"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//func TestMatch(t *testing.T) {
 | 
			
		||||
//	b, err := check("192.168.1.106", 1433)
 | 
			
		||||
//	if err != nil {
 | 
			
		||||
//		t.Error(err)
 | 
			
		||||
//	}
 | 
			
		||||
//	assert.Equal(t, true, b)
 | 
			
		||||
//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 (
 | 
			
		||||
////	"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
 | 
			
		||||
 | 
			
		||||
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 (
 | 
			
		||||
//	"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"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/json/client"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/models/param"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/models/protocol"
 | 
			
		||||
//	"log"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//	"time"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//func TestCheck(t *testing.T) {
 | 
			
		||||
//	b, _ := check("192.168.1.215", 110, false)
 | 
			
		||||
//	assert.Equal(t, true, b)
 | 
			
		||||
//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 TestCheckSSL(t *testing.T) {
 | 
			
		||||
//	b, _ := check("192.168.1.215", 995, true)
 | 
			
		||||
//	assert.Equal(t, true, b)
 | 
			
		||||
//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(time.Second * 2)
 | 
			
		||||
//	time.Sleep(2 * time.Second)
 | 
			
		||||
//
 | 
			
		||||
//	p := protocol.HealthRequest{IsSSL: false}
 | 
			
		||||
//	b, _ := json.Marshal(p)
 | 
			
		||||
//	in := param.Input{
 | 
			
		||||
//		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)
 | 
			
		||||
//	var m protocol.HealthResponse
 | 
			
		||||
//	json.Unmarshal(re.Data, &m)
 | 
			
		||||
//	if err != nil {
 | 
			
		||||
//		t.Fatal(err)
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	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
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"git.loafle.net/overflow/overflow_probe/crawler"
 | 
			
		||||
	"git.loafle.net/overflow/overflow_probe/crawler/config"
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
	"testing"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func setConfig() crawler.Crawler {
 | 
			
		||||
 | 
			
		||||
	r := NewRedisHeahthCrawler()
 | 
			
		||||
 | 
			
		||||
	m := config.Config{}
 | 
			
		||||
	m.Target = config.Target{}
 | 
			
		||||
	m.Target.Connection = config.Connection{}
 | 
			
		||||
	m.Target.Connection.Ip = "192.168.1.104"
 | 
			
		||||
	m.Target.Connection.Port = "6379"
 | 
			
		||||
	m.Target.Connection.PortType = "tcp"
 | 
			
		||||
	m.Target.Connection.SSL = false
 | 
			
		||||
 | 
			
		||||
	r.PutConfig("redis", m)
 | 
			
		||||
 | 
			
		||||
	return r
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestMatch(t *testing.T) {
 | 
			
		||||
	// test config
 | 
			
		||||
	r := setConfig()
 | 
			
		||||
 | 
			
		||||
	b, _ := r.Get("redis")
 | 
			
		||||
 | 
			
		||||
	var check bool
 | 
			
		||||
	json.Unmarshal(b, &check)
 | 
			
		||||
 | 
			
		||||
	assert.Equal(t, true, check)
 | 
			
		||||
}
 | 
			
		||||
//import (
 | 
			
		||||
//	"encoding/json"
 | 
			
		||||
//	"git.loafle.net/overflow/overflow_probe/crawler"
 | 
			
		||||
//	"git.loafle.net/overflow/overflow_probe/crawler/config"
 | 
			
		||||
//	"github.com/stretchr/testify/assert"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//func setConfig() crawler.Crawler {
 | 
			
		||||
//
 | 
			
		||||
//	r := NewRedisHeahthCrawler()
 | 
			
		||||
//
 | 
			
		||||
//	m := config.Config{}
 | 
			
		||||
//	m.Target = config.Target{}
 | 
			
		||||
//	m.Target.Connection = config.Connection{}
 | 
			
		||||
//	m.Target.Connection.Ip = "192.168.1.104"
 | 
			
		||||
//	m.Target.Connection.Port = "6379"
 | 
			
		||||
//	m.Target.Connection.PortType = "tcp"
 | 
			
		||||
//	m.Target.Connection.SSL = false
 | 
			
		||||
//
 | 
			
		||||
//	r.PutConfig("redis", m)
 | 
			
		||||
//
 | 
			
		||||
//	return r
 | 
			
		||||
//}
 | 
			
		||||
//
 | 
			
		||||
//func TestMatch(t *testing.T) {
 | 
			
		||||
//	// test config
 | 
			
		||||
//	r := setConfig()
 | 
			
		||||
//
 | 
			
		||||
//	b, _ := r.Get("redis")
 | 
			
		||||
//
 | 
			
		||||
//	var check bool
 | 
			
		||||
//	json.Unmarshal(b, &check)
 | 
			
		||||
//
 | 
			
		||||
//	assert.Equal(t, true, check)
 | 
			
		||||
//}
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
//func start() {
 | 
			
		||||
 | 
			
		||||
@ -1,75 +1,75 @@
 | 
			
		||||
package rmi_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 := NewRMIHeahthCrawler()
 | 
			
		||||
 | 
			
		||||
	m := make(map[string]interface{}, 0)
 | 
			
		||||
 | 
			
		||||
	m["ip"] = "192.168.1.103"
 | 
			
		||||
	m["port"] = "9840"
 | 
			
		||||
	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 (
 | 
			
		||||
//	"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 := NewRMIHeahthCrawler()
 | 
			
		||||
//
 | 
			
		||||
//	m := make(map[string]interface{}, 0)
 | 
			
		||||
//
 | 
			
		||||
//	m["ip"] = "192.168.1.103"
 | 
			
		||||
//	m["port"] = "9840"
 | 
			
		||||
//	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 imap
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
@ -1,75 +1,75 @@
 | 
			
		||||
package smb_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 := NewSMBHeahthCrawler()
 | 
			
		||||
 | 
			
		||||
	m := make(map[string]interface{}, 0)
 | 
			
		||||
 | 
			
		||||
	m["ip"] = "192.168.1.106"
 | 
			
		||||
	m["port"] = "445"
 | 
			
		||||
	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 (
 | 
			
		||||
//	"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 := NewSMBHeahthCrawler()
 | 
			
		||||
//
 | 
			
		||||
//	m := make(map[string]interface{}, 0)
 | 
			
		||||
//
 | 
			
		||||
//	m["ip"] = "192.168.1.106"
 | 
			
		||||
//	m["port"] = "445"
 | 
			
		||||
//	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 smb_protocol_crawler
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
@ -1,111 +1,111 @@
 | 
			
		||||
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 (
 | 
			
		||||
//	"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"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/json/client"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/models/param"
 | 
			
		||||
//	"git.loafle.net/overflow/of_rpc/models/protocol"
 | 
			
		||||
//	"log"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//	"time"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//func TestCheck(t *testing.T) {
 | 
			
		||||
//	b, _ := check("192.168.1.215", 25, false)
 | 
			
		||||
//	assert.Equal(t, true, b)
 | 
			
		||||
//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 TestCheckSSL(t *testing.T) {
 | 
			
		||||
//	b, _ := check("192.168.1.215", 465, true)
 | 
			
		||||
//	assert.Equal(t, true, b)
 | 
			
		||||
//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(time.Second * 2)
 | 
			
		||||
//	time.Sleep(2 * time.Second)
 | 
			
		||||
//
 | 
			
		||||
//	p := protocol.HealthRequest{IsSSL: false}
 | 
			
		||||
//	b, _ := json.Marshal(p)
 | 
			
		||||
//	in := param.Input{
 | 
			
		||||
//		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)
 | 
			
		||||
//	var m protocol.HealthResponse
 | 
			
		||||
//	json.Unmarshal(re.Data, &m)
 | 
			
		||||
//	if err != nil {
 | 
			
		||||
//		t.Fatal(err)
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	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
 | 
			
		||||
 | 
			
		||||
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 := NewSNMPV2CHeahthCrawler()
 | 
			
		||||
 | 
			
		||||
	m := make(map[string]interface{}, 0)
 | 
			
		||||
 | 
			
		||||
	m["ip"] = "192.168.1.215"
 | 
			
		||||
	m["port"] = "161"
 | 
			
		||||
	m["portType"] = "udp"
 | 
			
		||||
	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 (
 | 
			
		||||
//	"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 := NewSNMPV2CHeahthCrawler()
 | 
			
		||||
//
 | 
			
		||||
//	m := make(map[string]interface{}, 0)
 | 
			
		||||
//
 | 
			
		||||
//	m["ip"] = "192.168.1.215"
 | 
			
		||||
//	m["port"] = "161"
 | 
			
		||||
//	m["portType"] = "udp"
 | 
			
		||||
//	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 snmpv2c_protocol_crawler
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
@ -1,75 +1,75 @@
 | 
			
		||||
package snmpv3_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 := NewSNMPV3HeahthCrawler()
 | 
			
		||||
 | 
			
		||||
	m := make(map[string]interface{}, 0)
 | 
			
		||||
 | 
			
		||||
	m["ip"] = "192.168.1.254"
 | 
			
		||||
	m["port"] = "161"
 | 
			
		||||
	m["portType"] = "udp"
 | 
			
		||||
	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 (
 | 
			
		||||
//	"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 := NewSNMPV3HeahthCrawler()
 | 
			
		||||
//
 | 
			
		||||
//	m := make(map[string]interface{}, 0)
 | 
			
		||||
//
 | 
			
		||||
//	m["ip"] = "192.168.1.254"
 | 
			
		||||
//	m["port"] = "161"
 | 
			
		||||
//	m["portType"] = "udp"
 | 
			
		||||
//	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 snmpv3_protocol_crawler
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
@ -1,75 +1,75 @@
 | 
			
		||||
package ssh_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 := NewSSHHeahthCrawler()
 | 
			
		||||
 | 
			
		||||
	m := make(map[string]interface{}, 0)
 | 
			
		||||
 | 
			
		||||
	m["ip"] = "192.168.1.215"
 | 
			
		||||
	m["port"] = "22"
 | 
			
		||||
	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 (
 | 
			
		||||
//	"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 := NewSSHHeahthCrawler()
 | 
			
		||||
//
 | 
			
		||||
//	m := make(map[string]interface{}, 0)
 | 
			
		||||
//
 | 
			
		||||
//	m["ip"] = "192.168.1.215"
 | 
			
		||||
//	m["port"] = "22"
 | 
			
		||||
//	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 ssh_protocol_crawler
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
@ -1,75 +1,75 @@
 | 
			
		||||
package telnet_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 := NewTelnetHeahthCrawler()
 | 
			
		||||
 | 
			
		||||
	m := make(map[string]interface{}, 0)
 | 
			
		||||
 | 
			
		||||
	m["ip"] = "192.168.1.215"
 | 
			
		||||
	m["port"] = "23"
 | 
			
		||||
	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 (
 | 
			
		||||
//	"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 := NewTelnetHeahthCrawler()
 | 
			
		||||
//
 | 
			
		||||
//	m := make(map[string]interface{}, 0)
 | 
			
		||||
//
 | 
			
		||||
//	m["ip"] = "192.168.1.215"
 | 
			
		||||
//	m["port"] = "23"
 | 
			
		||||
//	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 main
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
@ -1,75 +1,75 @@
 | 
			
		||||
package wmi_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 := NewWMIHeahthCrawler()
 | 
			
		||||
 | 
			
		||||
	m := make(map[string]interface{}, 0)
 | 
			
		||||
 | 
			
		||||
	m["ip"] = "192.168.1.1"
 | 
			
		||||
	m["port"] = "135"
 | 
			
		||||
	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 (
 | 
			
		||||
//	"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 := NewWMIHeahthCrawler()
 | 
			
		||||
//
 | 
			
		||||
//	m := make(map[string]interface{}, 0)
 | 
			
		||||
//
 | 
			
		||||
//	m["ip"] = "192.168.1.1"
 | 
			
		||||
//	m["port"] = "135"
 | 
			
		||||
//	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 wmi_protocol_crawler
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
@ -3,11 +3,11 @@ package test
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"git.loafle.net/overflow/overflow_probe/crawler"
 | 
			
		||||
	"git.loafle.net/overflow/overflow_probe/crawler/health_crawler/redis_protocol_crawler"
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
	"git.loafle.net/overflow/overflow_probe/crawler/health_crawler/redis_protocol_crawler_go"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func initConfig() crawler.CrawlerImpl {
 | 
			
		||||
 | 
			
		||||
@ -1,83 +1,83 @@
 | 
			
		||||
package communicate
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
	"gopkg.in/gin-gonic/gin.v1"
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
 | 
			
		||||
	"git.loafle.net/overflow/overflow_probe/central/client/events"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/http/httptest"
 | 
			
		||||
	"testing"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestCommunicatorInit(t *testing.T) {
 | 
			
		||||
	assert.NotNil(t, _c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func makeGin() *gin.Engine {
 | 
			
		||||
	r := gin.New()
 | 
			
		||||
	api := r.Group("/_api")
 | 
			
		||||
	{
 | 
			
		||||
		collector := api.Group("/collector")
 | 
			
		||||
		{
 | 
			
		||||
			event := collector.Group("/event")
 | 
			
		||||
			{
 | 
			
		||||
				{
 | 
			
		||||
					types := event.Group("/status")
 | 
			
		||||
					{
 | 
			
		||||
						types.POST("/:type", func(c *gin.Context) {
 | 
			
		||||
							fmt.Println("called /_api/collector/event/status/:type")
 | 
			
		||||
							var j events.Event
 | 
			
		||||
							c.BindJSON(&j)
 | 
			
		||||
							fmt.Println(j)
 | 
			
		||||
							c.JSON(http.StatusOK, gin.H{"status": "ok"})
 | 
			
		||||
						})
 | 
			
		||||
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return r
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestSend(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
	}))
 | 
			
		||||
	defer ts.Close()
 | 
			
		||||
	for i := 0; i < 10; i++ {
 | 
			
		||||
		e := events.NewEvent(events.CENTRAL_EVENT, events.CollectorInstallEvent{Version: "Test"})
 | 
			
		||||
		Send(e)
 | 
			
		||||
		//		t.Log(e.GetResult())
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestRealSendByGin(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	SetRootURL("http://localhost:8080")
 | 
			
		||||
 | 
			
		||||
	e := events.NewEvent(events.CENTRAL_EVENT, events.NewInstallEvent("TestInstallEvent"))
 | 
			
		||||
	data, _ := json.Marshal(&e)
 | 
			
		||||
 | 
			
		||||
	var u events.URLMaker
 | 
			
		||||
	u = e.Data.(events.URLMaker)
 | 
			
		||||
	t.Log(GetRootURL() + u.GetUrl())
 | 
			
		||||
	req := httptest.NewRequest("POST", u.GetUrl(), bytes.NewReader(data))
 | 
			
		||||
	w := httptest.NewRecorder()
 | 
			
		||||
 | 
			
		||||
	g := makeGin()
 | 
			
		||||
	g.ServeHTTP(w, req)
 | 
			
		||||
 | 
			
		||||
	if w.Code != http.StatusOK {
 | 
			
		||||
		t.Errorf("Home page didn't return %v", http.StatusOK)
 | 
			
		||||
	} else {
 | 
			
		||||
		t.Log("OKOKOK")
 | 
			
		||||
		data, _ := ioutil.ReadAll(w.Body)
 | 
			
		||||
		t.Log(string(data))
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
//import (
 | 
			
		||||
//	"bytes"
 | 
			
		||||
//	"encoding/json"
 | 
			
		||||
//	"fmt"
 | 
			
		||||
//	"github.com/stretchr/testify/assert"
 | 
			
		||||
//	"gopkg.in/gin-gonic/gin.v1"
 | 
			
		||||
//	"io/ioutil"
 | 
			
		||||
//
 | 
			
		||||
//	"git.loafle.net/overflow/overflow_probe/central/client/events"
 | 
			
		||||
//	"net/http"
 | 
			
		||||
//	"net/http/httptest"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//func TestCommunicatorInit(t *testing.T) {
 | 
			
		||||
//	assert.NotNil(t, _c)
 | 
			
		||||
//}
 | 
			
		||||
//
 | 
			
		||||
//func makeGin() *gin.Engine {
 | 
			
		||||
//	r := gin.New()
 | 
			
		||||
//	api := r.Group("/_api")
 | 
			
		||||
//	{
 | 
			
		||||
//		collector := api.Group("/collector")
 | 
			
		||||
//		{
 | 
			
		||||
//			event := collector.Group("/event")
 | 
			
		||||
//			{
 | 
			
		||||
//				{
 | 
			
		||||
//					types := event.Group("/status")
 | 
			
		||||
//					{
 | 
			
		||||
//						types.POST("/:type", func(c *gin.Context) {
 | 
			
		||||
//							fmt.Println("called /_api/collector/event/status/:type")
 | 
			
		||||
//							var j events.Event
 | 
			
		||||
//							c.BindJSON(&j)
 | 
			
		||||
//							fmt.Println(j)
 | 
			
		||||
//							c.JSON(http.StatusOK, gin.H{"status": "ok"})
 | 
			
		||||
//						})
 | 
			
		||||
//
 | 
			
		||||
//					}
 | 
			
		||||
//				}
 | 
			
		||||
//			}
 | 
			
		||||
//		}
 | 
			
		||||
//	}
 | 
			
		||||
//	return r
 | 
			
		||||
//}
 | 
			
		||||
//
 | 
			
		||||
//func TestSend(t *testing.T) {
 | 
			
		||||
//
 | 
			
		||||
//	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
//	}))
 | 
			
		||||
//	defer ts.Close()
 | 
			
		||||
//	for i := 0; i < 10; i++ {
 | 
			
		||||
//		e := events.NewEvent(events.CENTRAL_EVENT, events.CollectorInstallEvent{Version: "Test"})
 | 
			
		||||
//		Send(e)
 | 
			
		||||
//		//		t.Log(e.GetResult())
 | 
			
		||||
//	}
 | 
			
		||||
//}
 | 
			
		||||
//
 | 
			
		||||
//func TestRealSendByGin(t *testing.T) {
 | 
			
		||||
//
 | 
			
		||||
//	SetRootURL("http://localhost:8080")
 | 
			
		||||
//
 | 
			
		||||
//	e := events.NewEvent(events.CENTRAL_EVENT, events.NewInstallEvent("TestInstallEvent"))
 | 
			
		||||
//	data, _ := json.Marshal(&e)
 | 
			
		||||
//
 | 
			
		||||
//	var u events.URLMaker
 | 
			
		||||
//	u = e.Data.(events.URLMaker)
 | 
			
		||||
//	t.Log(GetRootURL() + u.GetUrl())
 | 
			
		||||
//	req := httptest.NewRequest("POST", u.GetUrl(), bytes.NewReader(data))
 | 
			
		||||
//	w := httptest.NewRecorder()
 | 
			
		||||
//
 | 
			
		||||
//	g := makeGin()
 | 
			
		||||
//	g.ServeHTTP(w, req)
 | 
			
		||||
//
 | 
			
		||||
//	if w.Code != http.StatusOK {
 | 
			
		||||
//		t.Errorf("Home page didn't return %v", http.StatusOK)
 | 
			
		||||
//	} else {
 | 
			
		||||
//		t.Log("OKOKOK")
 | 
			
		||||
//		data, _ := ioutil.ReadAll(w.Body)
 | 
			
		||||
//		t.Log(string(data))
 | 
			
		||||
//	}
 | 
			
		||||
//}
 | 
			
		||||
 | 
			
		||||
@ -1,26 +1,26 @@
 | 
			
		||||
package communicate
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
 | 
			
		||||
	"git.loafle.net/overflow/overflow_probe/central/client/events"
 | 
			
		||||
	"git.loafle.net/overflow/overflow_probe/discovery/discovery/types/timestamp"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"testing"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestEventCollector(t *testing.T) {
 | 
			
		||||
	ev := events.Event{}
 | 
			
		||||
 | 
			
		||||
	ev.EventType = "install"
 | 
			
		||||
	ev.Time = timestamp.Now()
 | 
			
		||||
	ev.Collector_id = "1111111"
 | 
			
		||||
	ev.Data = events.CollectorInstallEvent{Version: "2.2"}
 | 
			
		||||
 | 
			
		||||
	bb, _ := json.Marshal(ev)
 | 
			
		||||
 | 
			
		||||
	//com := CompressTest(CompressDataGzip, UnCompressDataGzip, bb)
 | 
			
		||||
 | 
			
		||||
	http.Post("http://localhost:9090/_api/collector/event/status/install", "application/json", bytes.NewBuffer(bb))
 | 
			
		||||
}
 | 
			
		||||
//import (
 | 
			
		||||
//	"bytes"
 | 
			
		||||
//	"encoding/json"
 | 
			
		||||
//
 | 
			
		||||
//	"git.loafle.net/overflow/overflow_probe/central/client/events"
 | 
			
		||||
//	"git.loafle.net/overflow/overflow_probe/discovery/discovery/types/timestamp"
 | 
			
		||||
//	"net/http"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//func TestEventCollector(t *testing.T) {
 | 
			
		||||
//	ev := events.Event{}
 | 
			
		||||
//
 | 
			
		||||
//	ev.EventType = "install"
 | 
			
		||||
//	ev.Time = timestamp.Now()
 | 
			
		||||
//	ev.Collector_id = "1111111"
 | 
			
		||||
//	ev.Data = events.CollectorInstallEvent{Version: "2.2"}
 | 
			
		||||
//
 | 
			
		||||
//	bb, _ := json.Marshal(ev)
 | 
			
		||||
//
 | 
			
		||||
//	//com := CompressTest(CompressDataGzip, UnCompressDataGzip, bb)
 | 
			
		||||
//
 | 
			
		||||
//	http.Post("http://localhost:9090/_api/collector/event/status/install", "application/json", bytes.NewBuffer(bb))
 | 
			
		||||
//}
 | 
			
		||||
 | 
			
		||||
@ -1,235 +1,235 @@
 | 
			
		||||
package ftp
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"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
 | 
			
		||||
//import (
 | 
			
		||||
//	"fmt"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//
 | 
			
		||||
//    reader *bufio.Reader
 | 
			
		||||
//    writer *bufio.Writer
 | 
			
		||||
//	"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
 | 
			
		||||
////    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
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"crypto/tls"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
 | 
			
		||||
	"log"
 | 
			
		||||
	"net"
 | 
			
		||||
	"testing"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestHTTPSMatcher_Match(t *testing.T) {
 | 
			
		||||
	netinfo := "192.168.1.1:443"
 | 
			
		||||
	dialer := &net.Dialer{
 | 
			
		||||
		Timeout: 5 * time.Second,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	conn, err := tls.DialWithDialer(
 | 
			
		||||
		dialer,
 | 
			
		||||
		"tcp",
 | 
			
		||||
		netinfo,
 | 
			
		||||
		&tls.Config{
 | 
			
		||||
			InsecureSkipVerify: true,
 | 
			
		||||
			ServerName:         "192.168.1.103",
 | 
			
		||||
		},
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Println(err)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	defer conn.Close()
 | 
			
		||||
 | 
			
		||||
	//fmt.Println(conn)
 | 
			
		||||
	h := NewHTTPMatcher()
 | 
			
		||||
 | 
			
		||||
	pac := h.Packet(0)
 | 
			
		||||
 | 
			
		||||
	//fmt.Println(pac)
 | 
			
		||||
	//fmt.Println(pac.Buffer)
 | 
			
		||||
 | 
			
		||||
	//bytes := make([]byte, 1024)
 | 
			
		||||
 | 
			
		||||
	l, _ := conn.Write(pac.Buffer)
 | 
			
		||||
 | 
			
		||||
	buf := make([]byte, 1024)
 | 
			
		||||
	l, _ = conn.Read(buf)
 | 
			
		||||
 | 
			
		||||
	fmt.Println(string(buf))
 | 
			
		||||
	fmt.Println(l)
 | 
			
		||||
	is := h.Match(0, packet.NewPacket(buf, l), nil)
 | 
			
		||||
	fmt.Println(is)
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
//import (
 | 
			
		||||
//	"crypto/tls"
 | 
			
		||||
//	"fmt"
 | 
			
		||||
//	"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
 | 
			
		||||
//	"log"
 | 
			
		||||
//	"net"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//	"time"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//func TestHTTPSMatcher_Match(t *testing.T) {
 | 
			
		||||
//	netinfo := "192.168.1.1:443"
 | 
			
		||||
//	dialer := &net.Dialer{
 | 
			
		||||
//		Timeout: 5 * time.Second,
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	conn, err := tls.DialWithDialer(
 | 
			
		||||
//		dialer,
 | 
			
		||||
//		"tcp",
 | 
			
		||||
//		netinfo,
 | 
			
		||||
//		&tls.Config{
 | 
			
		||||
//			InsecureSkipVerify: true,
 | 
			
		||||
//			ServerName:         "192.168.1.103",
 | 
			
		||||
//		},
 | 
			
		||||
//	)
 | 
			
		||||
//
 | 
			
		||||
//	if err != nil {
 | 
			
		||||
//		log.Println(err)
 | 
			
		||||
//		return
 | 
			
		||||
//	}
 | 
			
		||||
//	defer conn.Close()
 | 
			
		||||
//
 | 
			
		||||
//	//fmt.Println(conn)
 | 
			
		||||
//	h := NewHTTPMatcher()
 | 
			
		||||
//
 | 
			
		||||
//	pac := h.Packet(0)
 | 
			
		||||
//
 | 
			
		||||
//	//fmt.Println(pac)
 | 
			
		||||
//	//fmt.Println(pac.Buffer)
 | 
			
		||||
//
 | 
			
		||||
//	//bytes := make([]byte, 1024)
 | 
			
		||||
//
 | 
			
		||||
//	l, _ := conn.Write(pac.Buffer)
 | 
			
		||||
//
 | 
			
		||||
//	buf := make([]byte, 1024)
 | 
			
		||||
//	l, _ = conn.Read(buf)
 | 
			
		||||
//
 | 
			
		||||
//	fmt.Println(string(buf))
 | 
			
		||||
//	fmt.Println(l)
 | 
			
		||||
//	is := h.Match(0, packet.NewPacket(buf, l), nil)
 | 
			
		||||
//	fmt.Println(is)
 | 
			
		||||
//
 | 
			
		||||
//}
 | 
			
		||||
 | 
			
		||||
@ -1,147 +1,147 @@
 | 
			
		||||
package imap
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"crypto/tls"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"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"
 | 
			
		||||
	"net"
 | 
			
		||||
	"testing"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func ImapRun(client net.Conn, t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	lm := NewIMAPMatcher()
 | 
			
		||||
 | 
			
		||||
	port := types.NewPort("143", 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()
 | 
			
		||||
 | 
			
		||||
	bytett := make([]byte, 1024)
 | 
			
		||||
 | 
			
		||||
	rr, _ := client.Read(bytett)
 | 
			
		||||
 | 
			
		||||
	bb := lm.Match(0, packet.NewPacket(bytett, rr), scanInfo)
 | 
			
		||||
 | 
			
		||||
	if bb {
 | 
			
		||||
		t.Log("good!")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	fmt.Println(lm.PacketCount())
 | 
			
		||||
 | 
			
		||||
	for ii := 0; ii < lm.PacketCount(); ii++ {
 | 
			
		||||
 | 
			
		||||
		pack := lm.Packet(ii)
 | 
			
		||||
 | 
			
		||||
		//fmt.Println(pack)
 | 
			
		||||
 | 
			
		||||
		client.Write(pack.Buffer)
 | 
			
		||||
 | 
			
		||||
		bytes := make([]byte, 1024)
 | 
			
		||||
 | 
			
		||||
		read, _ := client.Read(bytes)
 | 
			
		||||
 | 
			
		||||
		fmt.Println(cap(bytes))
 | 
			
		||||
 | 
			
		||||
		//fmt.Println(bytes)
 | 
			
		||||
 | 
			
		||||
		b := lm.Match(ii+1, packet.NewPacket(bytes, read), scanInfo)
 | 
			
		||||
 | 
			
		||||
		if b {
 | 
			
		||||
			t.Log("send Good!")
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	t.Log(scanInfo)
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestIMapTls(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	conn, _ := tls.Dial(
 | 
			
		||||
		"tcp",
 | 
			
		||||
		"192.168.1.215:993",
 | 
			
		||||
		&tls.Config{
 | 
			
		||||
			InsecureSkipVerify: true,
 | 
			
		||||
			ServerName:         "192.168.1.215",
 | 
			
		||||
		},
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	defer conn.Close()
 | 
			
		||||
 | 
			
		||||
	ImapRun(conn, t)
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestIMapNormal(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	client, _ := net.Dial("tcp", "192.168.1.215:143")
 | 
			
		||||
 | 
			
		||||
	defer client.Close()
 | 
			
		||||
 | 
			
		||||
	ImapRun(client, t)
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestImap(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	lm := NewIMAPMatcher()
 | 
			
		||||
 | 
			
		||||
	port := types.NewPort("143", 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()
 | 
			
		||||
 | 
			
		||||
	bytett := make([]byte, 1024)
 | 
			
		||||
 | 
			
		||||
	rr, _ := client.Read(bytett)
 | 
			
		||||
 | 
			
		||||
	bb := lm.Match(0, packet.NewPacket(bytett, rr), scanInfo)
 | 
			
		||||
 | 
			
		||||
	if bb {
 | 
			
		||||
		t.Log("good!")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	fmt.Println(lm.PacketCount())
 | 
			
		||||
 | 
			
		||||
	for ii := 0; ii < lm.PacketCount(); ii++ {
 | 
			
		||||
 | 
			
		||||
		pack := lm.Packet(ii)
 | 
			
		||||
 | 
			
		||||
		//fmt.Println(pack)
 | 
			
		||||
 | 
			
		||||
		client.Write(pack.Buffer)
 | 
			
		||||
 | 
			
		||||
		bytes := make([]byte, 1024)
 | 
			
		||||
 | 
			
		||||
		read, _ := client.Read(bytes)
 | 
			
		||||
 | 
			
		||||
		fmt.Println(cap(bytes))
 | 
			
		||||
 | 
			
		||||
		//fmt.Println(bytes)
 | 
			
		||||
 | 
			
		||||
		b := lm.Match(ii+1, packet.NewPacket(bytes, read), scanInfo)
 | 
			
		||||
 | 
			
		||||
		if b {
 | 
			
		||||
			t.Log("send Good!")
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	t.Log(scanInfo)
 | 
			
		||||
}
 | 
			
		||||
//import (
 | 
			
		||||
//	"crypto/tls"
 | 
			
		||||
//	"fmt"
 | 
			
		||||
//	"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"
 | 
			
		||||
//	"net"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//func ImapRun(client net.Conn, t *testing.T) {
 | 
			
		||||
//
 | 
			
		||||
//	lm := NewIMAPMatcher()
 | 
			
		||||
//
 | 
			
		||||
//	port := types.NewPort("143", 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()
 | 
			
		||||
//
 | 
			
		||||
//	bytett := make([]byte, 1024)
 | 
			
		||||
//
 | 
			
		||||
//	rr, _ := client.Read(bytett)
 | 
			
		||||
//
 | 
			
		||||
//	bb := lm.Match(0, packet.NewPacket(bytett, rr), scanInfo)
 | 
			
		||||
//
 | 
			
		||||
//	if bb {
 | 
			
		||||
//		t.Log("good!")
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	fmt.Println(lm.PacketCount())
 | 
			
		||||
//
 | 
			
		||||
//	for ii := 0; ii < lm.PacketCount(); ii++ {
 | 
			
		||||
//
 | 
			
		||||
//		pack := lm.Packet(ii)
 | 
			
		||||
//
 | 
			
		||||
//		//fmt.Println(pack)
 | 
			
		||||
//
 | 
			
		||||
//		client.Write(pack.Buffer)
 | 
			
		||||
//
 | 
			
		||||
//		bytes := make([]byte, 1024)
 | 
			
		||||
//
 | 
			
		||||
//		read, _ := client.Read(bytes)
 | 
			
		||||
//
 | 
			
		||||
//		fmt.Println(cap(bytes))
 | 
			
		||||
//
 | 
			
		||||
//		//fmt.Println(bytes)
 | 
			
		||||
//
 | 
			
		||||
//		b := lm.Match(ii+1, packet.NewPacket(bytes, read), scanInfo)
 | 
			
		||||
//
 | 
			
		||||
//		if b {
 | 
			
		||||
//			t.Log("send Good!")
 | 
			
		||||
//		}
 | 
			
		||||
//
 | 
			
		||||
//	}
 | 
			
		||||
//	t.Log(scanInfo)
 | 
			
		||||
//
 | 
			
		||||
//}
 | 
			
		||||
//
 | 
			
		||||
//func TestIMapTls(t *testing.T) {
 | 
			
		||||
//
 | 
			
		||||
//	conn, _ := tls.Dial(
 | 
			
		||||
//		"tcp",
 | 
			
		||||
//		"192.168.1.215:993",
 | 
			
		||||
//		&tls.Config{
 | 
			
		||||
//			InsecureSkipVerify: true,
 | 
			
		||||
//			ServerName:         "192.168.1.215",
 | 
			
		||||
//		},
 | 
			
		||||
//	)
 | 
			
		||||
//
 | 
			
		||||
//	defer conn.Close()
 | 
			
		||||
//
 | 
			
		||||
//	ImapRun(conn, t)
 | 
			
		||||
//
 | 
			
		||||
//}
 | 
			
		||||
//
 | 
			
		||||
//func TestIMapNormal(t *testing.T) {
 | 
			
		||||
//
 | 
			
		||||
//	client, _ := net.Dial("tcp", "192.168.1.215:143")
 | 
			
		||||
//
 | 
			
		||||
//	defer client.Close()
 | 
			
		||||
//
 | 
			
		||||
//	ImapRun(client, t)
 | 
			
		||||
//
 | 
			
		||||
//}
 | 
			
		||||
//
 | 
			
		||||
//func TestImap(t *testing.T) {
 | 
			
		||||
//
 | 
			
		||||
//	lm := NewIMAPMatcher()
 | 
			
		||||
//
 | 
			
		||||
//	port := types.NewPort("143", 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()
 | 
			
		||||
//
 | 
			
		||||
//	bytett := make([]byte, 1024)
 | 
			
		||||
//
 | 
			
		||||
//	rr, _ := client.Read(bytett)
 | 
			
		||||
//
 | 
			
		||||
//	bb := lm.Match(0, packet.NewPacket(bytett, rr), scanInfo)
 | 
			
		||||
//
 | 
			
		||||
//	if bb {
 | 
			
		||||
//		t.Log("good!")
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	fmt.Println(lm.PacketCount())
 | 
			
		||||
//
 | 
			
		||||
//	for ii := 0; ii < lm.PacketCount(); ii++ {
 | 
			
		||||
//
 | 
			
		||||
//		pack := lm.Packet(ii)
 | 
			
		||||
//
 | 
			
		||||
//		//fmt.Println(pack)
 | 
			
		||||
//
 | 
			
		||||
//		client.Write(pack.Buffer)
 | 
			
		||||
//
 | 
			
		||||
//		bytes := make([]byte, 1024)
 | 
			
		||||
//
 | 
			
		||||
//		read, _ := client.Read(bytes)
 | 
			
		||||
//
 | 
			
		||||
//		fmt.Println(cap(bytes))
 | 
			
		||||
//
 | 
			
		||||
//		//fmt.Println(bytes)
 | 
			
		||||
//
 | 
			
		||||
//		b := lm.Match(ii+1, packet.NewPacket(bytes, read), scanInfo)
 | 
			
		||||
//
 | 
			
		||||
//		if b {
 | 
			
		||||
//			t.Log("send Good!")
 | 
			
		||||
//		}
 | 
			
		||||
//
 | 
			
		||||
//	}
 | 
			
		||||
//	t.Log(scanInfo)
 | 
			
		||||
//}
 | 
			
		||||
 | 
			
		||||
@ -1,109 +1,109 @@
 | 
			
		||||
package ldap
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"crypto/tls"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"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"
 | 
			
		||||
	"net"
 | 
			
		||||
	"testing"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
//func SetUp() {
 | 
			
		||||
//    fmt.Println("SetUp")
 | 
			
		||||
//import (
 | 
			
		||||
//	"crypto/tls"
 | 
			
		||||
//	"fmt"
 | 
			
		||||
//	"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"
 | 
			
		||||
//	"net"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
////func 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() {
 | 
			
		||||
//    fmt.Println("TearDown")
 | 
			
		||||
//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 TestMain(m *testing.M) {
 | 
			
		||||
//    SetUp()
 | 
			
		||||
//    m.Run()
 | 
			
		||||
//    TearDown()
 | 
			
		||||
//
 | 
			
		||||
//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)
 | 
			
		||||
//}
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
 | 
			
		||||
	"net"
 | 
			
		||||
	"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",
 | 
			
		||||
//		},
 | 
			
		||||
//	)
 | 
			
		||||
//import (
 | 
			
		||||
//	"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
 | 
			
		||||
//	"net"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//    if err != nil {
 | 
			
		||||
//        t.Log(err)
 | 
			
		||||
//        return
 | 
			
		||||
//    }
 | 
			
		||||
///*
 | 
			
		||||
//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)
 | 
			
		||||
//	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
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
 | 
			
		||||
	"net"
 | 
			
		||||
	"testing"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestNBSS(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	m := NewNetBiosMatcher()
 | 
			
		||||
 | 
			
		||||
	conn, _ := net.Dial("tcp", "192.168.1.202:139")
 | 
			
		||||
 | 
			
		||||
	defer conn.Close()
 | 
			
		||||
 | 
			
		||||
	for i := 0; i < m.PacketCount(); i++ {
 | 
			
		||||
 | 
			
		||||
		pack := m.Packet(i)
 | 
			
		||||
		conn.Write(pack)
 | 
			
		||||
		bytes := make([]byte, 1024)
 | 
			
		||||
		n, _ := conn.Read(bytes)
 | 
			
		||||
		p := packet.NewPacket(bytes, n)
 | 
			
		||||
 | 
			
		||||
		if m.Match(i, p, nil) {
 | 
			
		||||
			t.Log("NBSS found")
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		t.Error("NBSS not found")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
//import (
 | 
			
		||||
//	"git.loafle.net/overflow/overflow_probe/discovery/discovery/scan/matcher/packet"
 | 
			
		||||
//	"net"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//func TestNBSS(t *testing.T) {
 | 
			
		||||
//
 | 
			
		||||
//	m := NewNetBiosMatcher()
 | 
			
		||||
//
 | 
			
		||||
//	conn, _ := net.Dial("tcp", "192.168.1.202:139")
 | 
			
		||||
//
 | 
			
		||||
//	defer conn.Close()
 | 
			
		||||
//
 | 
			
		||||
//	for i := 0; i < m.PacketCount(); i++ {
 | 
			
		||||
//
 | 
			
		||||
//		pack := m.Packet(i)
 | 
			
		||||
//		conn.Write(pack)
 | 
			
		||||
//		bytes := make([]byte, 1024)
 | 
			
		||||
//		n, _ := conn.Read(bytes)
 | 
			
		||||
//		p := packet.NewPacket(bytes, n)
 | 
			
		||||
//
 | 
			
		||||
//		if m.Match(i, p, nil) {
 | 
			
		||||
//			t.Log("NBSS found")
 | 
			
		||||
//			return
 | 
			
		||||
//		}
 | 
			
		||||
//
 | 
			
		||||
//		t.Error("NBSS not found")
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//}
 | 
			
		||||
 | 
			
		||||
@ -1,52 +1,52 @@
 | 
			
		||||
package oracle
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"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"
 | 
			
		||||
	"net"
 | 
			
		||||
	"testing"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestOracle(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	lm := NewOracleMatcher()
 | 
			
		||||
 | 
			
		||||
	port := types.NewPort("1521", types.NewHost("192.168.1.30"), 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)
 | 
			
		||||
 | 
			
		||||
		fmt.Println(pack)
 | 
			
		||||
 | 
			
		||||
		client.Write(pack.Buffer)
 | 
			
		||||
 | 
			
		||||
		bytes := make([]byte, 1024)
 | 
			
		||||
 | 
			
		||||
		read, _ := client.Read(bytes)
 | 
			
		||||
 | 
			
		||||
		fmt.Println(bytes)
 | 
			
		||||
 | 
			
		||||
		b := lm.Match(ii, packet.NewPacket(bytes, read), scanInfo)
 | 
			
		||||
 | 
			
		||||
		if b {
 | 
			
		||||
			t.Log("Good")
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	t.Log(scanInfo)
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
//import (
 | 
			
		||||
//	"fmt"
 | 
			
		||||
//	"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"
 | 
			
		||||
//	"net"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//func TestOracle(t *testing.T) {
 | 
			
		||||
//
 | 
			
		||||
//	lm := NewOracleMatcher()
 | 
			
		||||
//
 | 
			
		||||
//	port := types.NewPort("1521", types.NewHost("192.168.1.30"), 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)
 | 
			
		||||
//
 | 
			
		||||
//		fmt.Println(pack)
 | 
			
		||||
//
 | 
			
		||||
//		client.Write(pack.Buffer)
 | 
			
		||||
//
 | 
			
		||||
//		bytes := make([]byte, 1024)
 | 
			
		||||
//
 | 
			
		||||
//		read, _ := client.Read(bytes)
 | 
			
		||||
//
 | 
			
		||||
//		fmt.Println(bytes)
 | 
			
		||||
//
 | 
			
		||||
//		b := lm.Match(ii, packet.NewPacket(bytes, read), scanInfo)
 | 
			
		||||
//
 | 
			
		||||
//		if b {
 | 
			
		||||
//			t.Log("Good")
 | 
			
		||||
//		}
 | 
			
		||||
//
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	t.Log(scanInfo)
 | 
			
		||||
//
 | 
			
		||||
//}
 | 
			
		||||
 | 
			
		||||
@ -1,85 +1,86 @@
 | 
			
		||||
package pop
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"crypto/tls"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"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"
 | 
			
		||||
	"net"
 | 
			
		||||
	"testing"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestPopTLS(t *testing.T) {
 | 
			
		||||
	conn, _ := tls.Dial(
 | 
			
		||||
		"tcp",
 | 
			
		||||
		"192.168.1.215:995",
 | 
			
		||||
		&tls.Config{
 | 
			
		||||
			InsecureSkipVerify: true,
 | 
			
		||||
			ServerName:         "192.168.1.215",
 | 
			
		||||
		},
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	defer conn.Close()
 | 
			
		||||
 | 
			
		||||
	pop3Run(conn, t)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestPopNor(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	client, _ := net.Dial("tcp", "192.168.1.215:110")
 | 
			
		||||
 | 
			
		||||
	defer client.Close()
 | 
			
		||||
 | 
			
		||||
	pop3Run(client, t)
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func pop3Run(client net.Conn, t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	lm := NewPOPMatcher()
 | 
			
		||||
 | 
			
		||||
	port := types.NewPort("110", 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)
 | 
			
		||||
 | 
			
		||||
	bytett := make([]byte, 1024)
 | 
			
		||||
 | 
			
		||||
	read, _ := client.Read(bytett)
 | 
			
		||||
 | 
			
		||||
	bb := lm.Match(0, packet.NewPacket(bytett, read), scanInfo)
 | 
			
		||||
 | 
			
		||||
	if bb {
 | 
			
		||||
		t.Log("good!")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	fmt.Println(lm.PacketCount())
 | 
			
		||||
 | 
			
		||||
	for ii := 0; ii < lm.PacketCount(); ii++ {
 | 
			
		||||
 | 
			
		||||
		pack := lm.Packet(ii)
 | 
			
		||||
 | 
			
		||||
		//fmt.Println(pack)
 | 
			
		||||
 | 
			
		||||
		client.Write(pack.Buffer)
 | 
			
		||||
 | 
			
		||||
		bytes := make([]byte, 1024)
 | 
			
		||||
 | 
			
		||||
		rr, _ := client.Read(bytes)
 | 
			
		||||
 | 
			
		||||
		//fmt.Println(bytes)
 | 
			
		||||
 | 
			
		||||
		b := lm.Match(ii+1, packet.NewPacket(bytes, rr), scanInfo)
 | 
			
		||||
 | 
			
		||||
		if b {
 | 
			
		||||
			t.Log("send Good!")
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	t.Log(scanInfo)
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
//import (
 | 
			
		||||
//	"crypto/tls"
 | 
			
		||||
//	"fmt"
 | 
			
		||||
//
 | 
			
		||||
//	"net"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//	"git.loafle.net/overflow/overflow_probe/model/scaninfo"
 | 
			
		||||
//	"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(
 | 
			
		||||
//		"tcp",
 | 
			
		||||
//		"192.168.1.215:995",
 | 
			
		||||
//		&tls.Config{
 | 
			
		||||
//			InsecureSkipVerify: true,
 | 
			
		||||
//			ServerName:         "192.168.1.215",
 | 
			
		||||
//		},
 | 
			
		||||
//	)
 | 
			
		||||
//
 | 
			
		||||
//	defer conn.Close()
 | 
			
		||||
//
 | 
			
		||||
//	pop3Run(conn, t)
 | 
			
		||||
//}
 | 
			
		||||
//
 | 
			
		||||
//func TestPopNor(t *testing.T) {
 | 
			
		||||
//
 | 
			
		||||
//	client, _ := net.Dial("tcp", "192.168.1.215:110")
 | 
			
		||||
//
 | 
			
		||||
//	defer client.Close()
 | 
			
		||||
//
 | 
			
		||||
//	pop3Run(client, t)
 | 
			
		||||
//
 | 
			
		||||
//}
 | 
			
		||||
//
 | 
			
		||||
//func pop3Run(client net.Conn, t *testing.T) {
 | 
			
		||||
//
 | 
			
		||||
//	lm := NewPOPMatcher()
 | 
			
		||||
//
 | 
			
		||||
//	port := types.NewPort("110", 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)
 | 
			
		||||
//
 | 
			
		||||
//	bytett := make([]byte, 1024)
 | 
			
		||||
//
 | 
			
		||||
//	read, _ := client.Read(bytett)
 | 
			
		||||
//
 | 
			
		||||
//	bb := lm.Match(0, packet.NewPacket(bytett, read), scanInfo)
 | 
			
		||||
//
 | 
			
		||||
//	if bb {
 | 
			
		||||
//		t.Log("good!")
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	fmt.Println(lm.PacketCount())
 | 
			
		||||
//
 | 
			
		||||
//	for ii := 0; ii < lm.PacketCount(); ii++ {
 | 
			
		||||
//
 | 
			
		||||
//		pack := lm.Packet(ii)
 | 
			
		||||
//
 | 
			
		||||
//		//fmt.Println(pack)
 | 
			
		||||
//
 | 
			
		||||
//		client.Write(pack.Buffer)
 | 
			
		||||
//
 | 
			
		||||
//		bytes := make([]byte, 1024)
 | 
			
		||||
//
 | 
			
		||||
//		rr, _ := client.Read(bytes)
 | 
			
		||||
//
 | 
			
		||||
//		//fmt.Println(bytes)
 | 
			
		||||
//
 | 
			
		||||
//		b := lm.Match(ii+1, packet.NewPacket(bytes, rr), scanInfo)
 | 
			
		||||
//
 | 
			
		||||
//		if b {
 | 
			
		||||
//			t.Log("send Good!")
 | 
			
		||||
//		}
 | 
			
		||||
//
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	t.Log(scanInfo)
 | 
			
		||||
//
 | 
			
		||||
//}
 | 
			
		||||
 | 
			
		||||
@ -1,51 +1,51 @@
 | 
			
		||||
package wmi
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"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"
 | 
			
		||||
	"net"
 | 
			
		||||
	"testing"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestWMI(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	lm := NewWMIMatcher()
 | 
			
		||||
 | 
			
		||||
	port := types.NewPort("135", types.NewHost("192.168.1.1"), 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)
 | 
			
		||||
 | 
			
		||||
		fmt.Println(pack)
 | 
			
		||||
 | 
			
		||||
		client.Write(pack.Buffer)
 | 
			
		||||
 | 
			
		||||
		bytes := make([]byte, 1024)
 | 
			
		||||
 | 
			
		||||
		read, _ := client.Read(bytes)
 | 
			
		||||
 | 
			
		||||
		//fmt.Println(bytes)
 | 
			
		||||
 | 
			
		||||
		b := lm.Match(ii, packet.NewPacket(bytes, read), scanInfo)
 | 
			
		||||
 | 
			
		||||
		if b {
 | 
			
		||||
			fmt.Println("Good")
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	t.Log(scanInfo)
 | 
			
		||||
}
 | 
			
		||||
//import (
 | 
			
		||||
//	"fmt"
 | 
			
		||||
//	"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"
 | 
			
		||||
//	"net"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//)
 | 
			
		||||
//
 | 
			
		||||
//func TestWMI(t *testing.T) {
 | 
			
		||||
//
 | 
			
		||||
//	lm := NewWMIMatcher()
 | 
			
		||||
//
 | 
			
		||||
//	port := types.NewPort("135", types.NewHost("192.168.1.1"), 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)
 | 
			
		||||
//
 | 
			
		||||
//		fmt.Println(pack)
 | 
			
		||||
//
 | 
			
		||||
//		client.Write(pack.Buffer)
 | 
			
		||||
//
 | 
			
		||||
//		bytes := make([]byte, 1024)
 | 
			
		||||
//
 | 
			
		||||
//		read, _ := client.Read(bytes)
 | 
			
		||||
//
 | 
			
		||||
//		//fmt.Println(bytes)
 | 
			
		||||
//
 | 
			
		||||
//		b := lm.Match(ii, packet.NewPacket(bytes, read), scanInfo)
 | 
			
		||||
//
 | 
			
		||||
//		if b {
 | 
			
		||||
//			fmt.Println("Good")
 | 
			
		||||
//		}
 | 
			
		||||
//
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	t.Log(scanInfo)
 | 
			
		||||
//}
 | 
			
		||||
 | 
			
		||||
@ -1,235 +1,235 @@
 | 
			
		||||
package ftp
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"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
 | 
			
		||||
//import (
 | 
			
		||||
//	"fmt"
 | 
			
		||||
//	"testing"
 | 
			
		||||
//
 | 
			
		||||
//    reader *bufio.Reader
 | 
			
		||||
//    writer *bufio.Writer
 | 
			
		||||
//	"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
 | 
			
		||||
////    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