From 75999ef2faa8ebc1a7be5788072ea288cae06e33 Mon Sep 17 00:00:00 2001 From: crusader Date: Wed, 22 Nov 2017 01:42:45 +0900 Subject: [PATCH] =?UTF-8?q?=E3=85=91=E3=85=9C=E3=85=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activedirectory/activedirectory_test.go | 79 ------ service/match/cassandra/cassandra_test.go | 73 ------ service/match/dns/dns_test.go | 33 --- service/match/ftp/ftp_test.go | 234 ------------------ service/match/http/http_test.go | 49 ---- service/match/http/https_test.go | 55 ---- service/match/imap/imap_test.go | 153 ------------ service/match/mongodb/mongodb_test.go | 54 ---- service/match/mssql/mssql_test.go | 63 ----- service/match/mysql/mysql_test.go | 71 ------ service/match/netbios/netbios_test.go | 34 --- service/match/oracle/oracle_test.go | 53 ---- service/match/pgsql/pgsql_test.go | 70 ------ service/match/pop/pop_test.go | 86 ------- service/match/redis/redisProtected_test.go | 33 --- service/match/redis/redis_test.go | 37 --- service/match/rmi/rmi_test.go | 52 ---- service/match/smb/smb_test.go | 42 ---- service/match/snmp/snmpv2_test.go | 37 --- service/match/snmp/snmpv3_test.go | 37 --- service/match/ssh/ssh_test.go | 35 --- service/match/telnet/telnet_test.go | 33 --- service/match/wmi/wmi_test.go | 51 ---- 23 files changed, 1464 deletions(-) delete mode 100644 service/match/activedirectory/activedirectory_test.go delete mode 100644 service/match/cassandra/cassandra_test.go delete mode 100644 service/match/dns/dns_test.go delete mode 100644 service/match/ftp/ftp_test.go delete mode 100644 service/match/http/http_test.go delete mode 100644 service/match/http/https_test.go delete mode 100644 service/match/imap/imap_test.go delete mode 100644 service/match/mongodb/mongodb_test.go delete mode 100644 service/match/mssql/mssql_test.go delete mode 100644 service/match/mysql/mysql_test.go delete mode 100644 service/match/netbios/netbios_test.go delete mode 100644 service/match/oracle/oracle_test.go delete mode 100644 service/match/pgsql/pgsql_test.go delete mode 100644 service/match/pop/pop_test.go delete mode 100644 service/match/redis/redisProtected_test.go delete mode 100644 service/match/redis/redis_test.go delete mode 100644 service/match/rmi/rmi_test.go delete mode 100644 service/match/smb/smb_test.go delete mode 100644 service/match/snmp/snmpv2_test.go delete mode 100644 service/match/snmp/snmpv3_test.go delete mode 100644 service/match/ssh/ssh_test.go delete mode 100644 service/match/telnet/telnet_test.go delete mode 100644 service/match/wmi/wmi_test.go diff --git a/service/match/activedirectory/activedirectory_test.go b/service/match/activedirectory/activedirectory_test.go deleted file mode 100644 index 083b546..0000000 --- a/service/match/activedirectory/activedirectory_test.go +++ /dev/null @@ -1,79 +0,0 @@ -package activedirectory - -import ( - "crypto/tls" - "net" - "testing" - "fmt" - "git.loafle.net/overflow/overflow_discovery/service/matcher" -) - -func TestADNor(t *testing.T) { - client, err := net.Dial("tcp", "192.168.1.15:389") - - if err != nil { - t.Log(err) - } - - defer client.Close() - - dDRun(client, t) -} - -func TestADTLS(t *testing.T) { - conn, err := tls.Dial( - "tcp", - "192.168.1.1:636", - &tls.Config{ - InsecureSkipVerify: true, - ServerName: "192.168.1.1", - }, - ) - - if err != nil { - t.Log(err) - return - } - - defer conn.Close() - - dDRun(conn, t) -} - -func dDRun(client net.Conn, t *testing.T) { - - lm := NewActiveDirectoryMatcher() - - //port := types.NewPort("389", types.NewHost("192.168.1.1"), types.TYPE_TCP) - // - //var ipport string - //ipport = port.Host.Ip + ":" + string(port.Port) - // - //fmt.Println(ipport) - // - //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, matcher.NewPacket(bytes, read), nil) - - if b { - fmt.Println("Good") - } - - } - - -} diff --git a/service/match/cassandra/cassandra_test.go b/service/match/cassandra/cassandra_test.go deleted file mode 100644 index 7f71306..0000000 --- a/service/match/cassandra/cassandra_test.go +++ /dev/null @@ -1,73 +0,0 @@ -package cassandra - -import ( - "crypto/tls" - "git.loafle.net/overflow/overflow_discovery/service/matcher" - "net" - "testing" -) - -func TestCassandra(t *testing.T) { - - m := NewCassandraMatcher() - - conn, err := net.Dial("tcp", "192.168.1.16:19042") - if err != nil { - t.Error(err) - return - } - defer conn.Close() - - for i := 0; i < m.PacketCount(); i++ { - - pack := m.Packet(i) - conn.Write(pack.Buffer) - bytes := make([]byte, 1024) - n, _ := conn.Read(bytes) - p := matcher.NewPacket(bytes, n) - - if m.Match(i, p, nil) { - t.Log("Cassandra found") - return - } - - t.Error("Cassandra not found") - } - -} - -func TestCassandraTLS(t *testing.T) { - - m := NewCassandraMatcher() - - conn, err := tls.Dial( - "tcp", - "192.168.1.16:19042", - &tls.Config{ - InsecureSkipVerify: true, - ServerName: "192.168.1.16", - }, - ) - if err != nil { - t.Fatal(err) - } - - defer conn.Close() - - for i := 0; i < m.PacketCount(); i++ { - - pack := m.Packet(i) - conn.Write(pack.Buffer) - bytes := make([]byte, 1024) - n, _ := conn.Read(bytes) - p := matcher.NewPacket(bytes, n) - - if m.Match(i, p, nil) { - t.Log("Cassandra found") - return - } - - t.Error("Cassandra not found") - } - -} diff --git a/service/match/dns/dns_test.go b/service/match/dns/dns_test.go deleted file mode 100644 index 0e869b0..0000000 --- a/service/match/dns/dns_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package dns - -import ( - "git.loafle.net/overflow/overflow_discovery/service/matcher" - "net" - "testing" -) - -func TestDns(t *testing.T) { - m := NewDnsMatcher() - - conn, _ := net.Dial("udp", "168.126.63.1:53") - - defer conn.Close() - - for i := 0; i < m.PacketCount(); i++ { - if m.IsSend(53) != true { - t.Error("not port") - } - pack := m.Packet(i) - conn.Write(pack.Buffer) - bytes := make([]byte, 1024) - n, _ := conn.Read(bytes) - p := matcher.NewPacket(bytes, n) - - if m.Match(i, p, nil) { - t.Log("dns found") - return - } - - t.Error("dns not found") - } -} diff --git a/service/match/ftp/ftp_test.go b/service/match/ftp/ftp_test.go deleted file mode 100644 index 9a28a00..0000000 --- a/service/match/ftp/ftp_test.go +++ /dev/null @@ -1,234 +0,0 @@ -package ftp - -import ( - "fmt" - "testing" - "git.loafle.net/overflow/overflow_discovery/model/scaninfo" - "git.loafle.net/overflow/overflow_discovery/service/matcher" - - "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.NewScanInfoImpl("192.168.1.15","21") - // - //var ipport string - //ipport = port.Host.Ip + ":" + string(port.Port) - // - //log.Debug(ipport) - - client, _ := net.Dial("tcp", "192.168.1.15:21") - - 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, matcher.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, matcher.NewPacket(bytes, l), info) - - fmt.Println(b) - - } - - fmt.Println("Service Name : ", ftm.ServiceName()) -} diff --git a/service/match/http/http_test.go b/service/match/http/http_test.go deleted file mode 100644 index dc3ddd0..0000000 --- a/service/match/http/http_test.go +++ /dev/null @@ -1,49 +0,0 @@ -package http - -import ( - "fmt" - "git.loafle.net/overflow/overflow_discovery/service/matcher" - //"git.loafle.net/overflow/overflow_discovery/discovery/discovery/types" - "net" - "testing" -) - -func TestHTTPMatcher_Packet(t *testing.T) { - hm := NewHTTPMatcher() - fmt.Println(hm) - fmt.Println(hm.sendPackets[0]) - -} - -func TestHTTPMatcher_Match(t *testing.T) { - fmt.Println("Match") - - hm := NewHTTPMatcher() - - //port := types.NewPort("80", types.NewHost("192.168.1.103"), types.TYPE_TCP) - // - //var ipport string - //ipport = port.Host.Ip + ":" + string(port.Port) - - //fmt.Println(ipport) - - client, _ := net.Dial("tcp", "192.168.1.15:38980") - - defer client.Close() - - pack := hm.Packet(0) - - //fmt.Println(pack) - - //writer.WriteString(pack) - client.Write(pack.Buffer) - - bytes := make([]byte, 512) - - l, _ := client.Read(bytes) - - //fmt.Println(bytes) - - hm.Match(0, matcher.NewPacket(bytes, l), nil) - -} diff --git a/service/match/http/https_test.go b/service/match/http/https_test.go deleted file mode 100644 index 2b07dd0..0000000 --- a/service/match/http/https_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package http - -import ( - "crypto/tls" - "fmt" - "git.loafle.net/overflow/overflow_discovery/service/matcher" - "log" - "net" - "testing" - "time" -) - -func TestHTTPSMatcher_Match(t *testing.T) { - netinfo := "192.168.1.10:10443" - 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, matcher.NewPacket(buf, l), nil) - fmt.Println(is) - -} diff --git a/service/match/imap/imap_test.go b/service/match/imap/imap_test.go deleted file mode 100644 index d47953b..0000000 --- a/service/match/imap/imap_test.go +++ /dev/null @@ -1,153 +0,0 @@ -package imap - - -import ( - "crypto/tls" - "fmt" - //"git.loafle.net/overflow/overflow_discovery/collector/core/scan/port" - "git.loafle.net/overflow/overflow_discovery/service/matcher" - //"git.loafle.net/overflow/overflow_discovery/collector/core/scan/service/matcher/scaninfo" - //"git.loafle.net/overflow/overflow_discovery/collector/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 := types.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, matcher.NewPacket(bytett, rr), nil) - - 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, matcher.NewPacket(bytes, read), nil) - - if b { - t.Log("send Good!") - } - - } - - -} - -func TestIMapTls(t *testing.T) { - - conn, _ := tls.Dial( - "tcp", - "192.168.1.15:993", - &tls.Config{ - InsecureSkipVerify: true, - ServerName: "192.168.1.15", - }, - ) - - defer conn.Close() - - ImapRun(conn, t) - -} - -func TestIMapNormal(t *testing.T) { - - client, err := net.Dial("tcp", "192.168.1.15:143") - if err != nil { - t.Fatal(err) - } - - 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 + ":" + 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, matcher.NewPacket(bytett, rr), scanInfo) - bb := lm.Match(0, matcher.NewPacket(bytett, rr), nil) - - 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, matcher.NewPacket(bytes, read), nil) - - if b { - t.Log("send Good!") - } - - } - //t.Log(scanInfo) -} diff --git a/service/match/mongodb/mongodb_test.go b/service/match/mongodb/mongodb_test.go deleted file mode 100644 index 8958765..0000000 --- a/service/match/mongodb/mongodb_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package mongodb - -import ( - "crypto/tls" - "git.loafle.net/overflow/overflow_discovery/service/matcher" - "net" - "testing" -) - -func TestMongoNor(t *testing.T) { - - conn, _ := net.Dial("tcp", "192.168.1.16:37017") - - defer conn.Close() - - MongoRun(conn, t) - -} -func TestMongoTLS(t *testing.T) { - conn, _ := tls.Dial( - "tcp", - "192.168.1.16:47017", - &tls.Config{ - InsecureSkipVerify: true, - ServerName: "192.168.1.16", - }, - ) - - defer conn.Close() - - MongoRun(conn, t) -} - -func MongoRun(conn net.Conn, t *testing.T) { - - m := NewMongoDBMatcher() - - for i := 0; i < m.PacketCount(); i++ { - - pack := m.Packet(i) - conn.Write(pack.Buffer) - bytes := make([]byte, 1024) - n, _ := conn.Read(bytes) - p := matcher.NewPacket(bytes, n) - - if m.Match(i, p, nil) { - t.Log("MongoDB found") - return - } - - t.Error("MongoDB not found") - } - -} diff --git a/service/match/mssql/mssql_test.go b/service/match/mssql/mssql_test.go deleted file mode 100644 index 214ca7a..0000000 --- a/service/match/mssql/mssql_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package mssql - -import ( - "git.loafle.net/overflow/overflow_discovery/service/matcher" - "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.16:11433") - - defer conn.Close() - - sqlServerRun(conn, t) - -} - -//func TestSqlTLS(t *testing.T) { -// conn, err := tls.Dial( -// "tcp", -// "192.168.1.103:7680", -// &tls.Config{ -// InsecureSkipVerify: true, -// ServerName: "192.168.1.103", -// }, -// ) -// -// if err != nil { -// t.Log(err) -// 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 := matcher.NewPacket(bytes, n) - - if m.Match(i, p, nil) { - t.Log(m.ServiceName()) - return - } - - t.Error("MSSQL not found") - } - -} diff --git a/service/match/mysql/mysql_test.go b/service/match/mysql/mysql_test.go deleted file mode 100644 index 2f325d3..0000000 --- a/service/match/mysql/mysql_test.go +++ /dev/null @@ -1,71 +0,0 @@ -package mysql - - -import ( - "crypto/tls" - "git.loafle.net/overflow/overflow_discovery/service/matcher" - "net" - "testing" -) - -func TestMySql(t *testing.T) { - - m := NewMySqlMatcher() - - /* - 192.168.1.103:3306 - normal - 192.168.1.105:8306 - ssl - 192.168.1.203:3306 - mysql with error code - */ - conn, _ := net.Dial("tcp", "192.168.1.15:33068") - - defer conn.Close() - - bytes := make([]byte, 1024) - n, _ := conn.Read(bytes) - p := matcher.NewPacket(bytes, n) - - if m.Match(0, p, nil) { - t.Log(m.ServiceName()) - return - } - - t.Error("MySQL not found") - -} - -func TestCassandraTLS(t *testing.T) { - - m := NewMySqlMatcher() - - conn, err := tls.Dial( - "tcp", - "192.168.1.105:8306", - &tls.Config{ - InsecureSkipVerify: true, - ServerName: "192.168.1.105", - }, - ) - if err != nil { - t.Fatal(err) - } - - defer conn.Close() - - for i := 0; i < m.PacketCount(); i++ { - - pack := m.Packet(i) - conn.Write(pack.Buffer) - bytes := make([]byte, 1024) - n, _ := conn.Read(bytes) - p := matcher.NewPacket(bytes, n) - - if m.Match(i, p, nil) { - t.Log(m.ServiceName()) - return - } - - t.Error("MySQL not found") - } - -} diff --git a/service/match/netbios/netbios_test.go b/service/match/netbios/netbios_test.go deleted file mode 100644 index 44be41d..0000000 --- a/service/match/netbios/netbios_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package netbios - - -import ( - "git.loafle.net/overflow/overflow_discovery/service/matcher" - "net" - "testing" -) - -func TestNBSS(t *testing.T) { - - m := NewNetBiosMatcher() - - conn, _ := net.Dial("tcp", "192.168.1.106:139") - - defer conn.Close() - - for i := 0; i < m.PacketCount(); i++ { - - pack := m.Packet(i) - conn.Write(pack.Buffer) - bytes := make([]byte, 1024) - n, _ := conn.Read(bytes) - p := matcher.NewPacket(bytes, n) - - if m.Match(i, p, nil) { - t.Log("NBSS found") - return - } - - t.Error("NBSS not found") - } - -} diff --git a/service/match/oracle/oracle_test.go b/service/match/oracle/oracle_test.go deleted file mode 100644 index 7556782..0000000 --- a/service/match/oracle/oracle_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package oracle - - -import ( - - "git.loafle.net/overflow/overflow_discovery/service/matcher" - - - "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) - - - client, _ := net.Dial("tcp", "192.168.1.15:1521") - - defer client.Close() - - t.Log(lm.PacketCount()) - - for ii := 0; ii < lm.PacketCount(); ii++ { - - pack := lm.Packet(ii) - - t.Log(pack) - - client.Write(pack.Buffer) - - bytes := make([]byte, 1024) - - read, _ := client.Read(bytes) - - t.Log(bytes) - - b := lm.Match(ii, matcher.NewPacket(bytes, read), nil) - - if b { - t.Log("Good") - } - - } - - - -} diff --git a/service/match/pgsql/pgsql_test.go b/service/match/pgsql/pgsql_test.go deleted file mode 100644 index 70e30cd..0000000 --- a/service/match/pgsql/pgsql_test.go +++ /dev/null @@ -1,70 +0,0 @@ -package pgsql - -import ( - "crypto/tls" - "git.loafle.net/overflow/overflow_discovery/service/matcher" - "net" - "testing" -) - -func TestPG(t *testing.T) { - m := NewPostgreSQLMatcher() - - conn, err := net.Dial("tcp", "192.168.1.106:5432") //107 - if err != nil { - t.Error(err) - return - } - defer conn.Close() - - for i := 0; i < m.PacketCount(); i++ { - - pack := m.Packet(i) - conn.Write(pack.Buffer) - bytes := make([]byte, 1024) - n, _ := conn.Read(bytes) - p := matcher.NewPacket(bytes, n) - - if m.Match(i, p, nil) { - t.Log("PostgreSQL found") - return - } - - t.Error("PostgreSQL not found") - } -} - -func TestSqlTLS(t *testing.T) { - conn, err := tls.Dial( - "tcp", - "192.168.1.107:5432", - &tls.Config{ - InsecureSkipVerify: true, - ServerName: "192.168.1.107", - }, - ) - - if err != nil { - t.Error(err) - return - } - - defer conn.Close() - - m := NewPostgreSQLMatcher() - for i := 0; i < m.PacketCount(); i++ { - - pack := m.Packet(i) - conn.Write(pack.Buffer) - bytes := make([]byte, 1024) - n, _ := conn.Read(bytes) - p := matcher.NewPacket(bytes, n) - - if m.Match(i, p, nil) { - t.Log("PostgreSQL found") - return - } - - t.Error("PostgreSQL not found") - } -} diff --git a/service/match/pop/pop_test.go b/service/match/pop/pop_test.go deleted file mode 100644 index fbc9850..0000000 --- a/service/match/pop/pop_test.go +++ /dev/null @@ -1,86 +0,0 @@ -package pop - - -import ( - "crypto/tls" - "fmt" - "git.loafle.net/overflow/overflow_discovery/service/matcher" - - - "net" - "testing" -) - -func TestPopTLS(t *testing.T) { - conn, _ := tls.Dial( - "tcp", - "192.168.1.15:995", - &tls.Config{ - InsecureSkipVerify: true, - ServerName: "192.168.1.15", - }, - ) - - defer conn.Close() - - pop3Run(conn, t) -} - -func TestPopNor(t *testing.T) { - - client, _ := net.Dial("tcp", "192.168.1.15: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, matcher.NewPacket(bytett, read), nil) - - 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, matcher.NewPacket(bytes, rr), nil) - - if b { - t.Log("send Good!") - } - - } - - - -} diff --git a/service/match/redis/redisProtected_test.go b/service/match/redis/redisProtected_test.go deleted file mode 100644 index 8f4e78e..0000000 --- a/service/match/redis/redisProtected_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package redis - -//import ( -// "git.loafle.net/overflow/overflow_discovery/collector/core/scan/service/matcher/packet" -// "net" -// "testing" -//) -// -//func TestRedisProtected(t *testing.T) { -// -// m := NewRedisProtectedMatcher() -// -// conn, err := net.Dial("tcp", "192.168.1.215:8379") -// -// if err != nil { -// t.Log(err) -// return -// } -// -// defer conn.Close() -// -// bytes := make([]byte, 1024) -// n, _ := conn.Read(bytes) -// -// //fmt.Println(string(bytes[:n])) -// -// b := m.Match(0, matcher.NewPacket(bytes, n), nil) -// -// if b { -// t.Log("good!") -// } -// -//} diff --git a/service/match/redis/redis_test.go b/service/match/redis/redis_test.go deleted file mode 100644 index f0d2e9d..0000000 --- a/service/match/redis/redis_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package redis - -import ( - "git.loafle.net/overflow/overflow_discovery/service/matcher" - "net" - "testing" -) - -const ( - ADDR string = "192.168.1.16:26379" -) - -func TestRedisMatcher(t *testing.T) { - - m := NewRedisMatcher() - - conn, _ := net.Dial("tcp", ADDR) - defer conn.Close() - - for i := 0; i < m.PacketCount(); i++ { - - pack := m.Packet(i) - conn.Write(pack.Buffer) - bytes := make([]byte, 1024) - n, _ := conn.Read(bytes) - - p := matcher.NewPacket(bytes, n) - - if m.Match(i, p, nil) { - t.Log("Redis found.") - return - } - - t.Error("Redis not found") - } - -} diff --git a/service/match/rmi/rmi_test.go b/service/match/rmi/rmi_test.go deleted file mode 100644 index f579c8c..0000000 --- a/service/match/rmi/rmi_test.go +++ /dev/null @@ -1,52 +0,0 @@ -package rmi - -import ( - "fmt" - "git.loafle.net/overflow/overflow_discovery/service/matcher" - //"git.loafle.net/overflow/overflow_discovery/discovery/discovery/types" - "net" - "testing" -) - -func TestNew(t *testing.T) { - r := NewRMIMatcher() - fmt.Println("TestNew: ", r) -} -func TestRMIMatcher_Match(t *testing.T) { - - fmt.Println("Match") - - hm := NewRMIMatcher() - - //port := types.NewPort("9840", types.NewHost("192.168.1.101"), types.TYPE_TCP) - // - //var ipport string - //ipport = port.Host.Ip + ":" + string(port.Port) - - //fmt.Println(ipport) - - client, err := net.Dial("tcp", "192.168.1.101:9840") - - if err != nil { - t.Fatal(err) - } - - defer client.Close() - - pack := hm.Packet(0) - - fmt.Println(pack.Buffer) - - //writer.WriteString(pack) - client.Write(pack.Buffer) - - bytes := make([]byte, 512) - - l, _ := client.Read(bytes) - - //fmt.Println(bytes) - - t1 := hm.Match(0, matcher.NewPacket(bytes, l), nil) - - fmt.Println(t1) -} diff --git a/service/match/smb/smb_test.go b/service/match/smb/smb_test.go deleted file mode 100644 index 58ff870..0000000 --- a/service/match/smb/smb_test.go +++ /dev/null @@ -1,42 +0,0 @@ -package smb - -import ( - "git.loafle.net/overflow/overflow_discovery/service/matcher" - "net" - "testing" -) - -const ( - ADDR string = "192.168.1.106:445" -) - -func TestSMBMatcher(t *testing.T) { - - m := NewSMBMatcher() - - conn, err := net.Dial("tcp", ADDR) - - if err != nil { - t.Fatal(err) - } - - defer conn.Close() - - for i := 0; i < m.PacketCount(); i++ { - - pack := m.Packet(i) - conn.Write(pack.Buffer) - bytes := make([]byte, 1024) - n, _ := conn.Read(bytes) - - p := matcher.NewPacket(bytes, n) - - if m.Match(i, p, nil) { - t.Log("SMB found.") - return - } - - t.Error("SMB not found") - } - -} diff --git a/service/match/snmp/snmpv2_test.go b/service/match/snmp/snmpv2_test.go deleted file mode 100644 index 00742a7..0000000 --- a/service/match/snmp/snmpv2_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package snmp - - -import ( - "git.loafle.net/overflow/overflow_discovery/service/matcher" - "net" - "testing" -) - -func TestSNMP2(t *testing.T) { - - m := NewSNMPv2Matcher() - - conn, err := net.Dial("udp", "192.168.1.15:161") - if err != nil { - t.Error(err) - return - } - defer conn.Close() - - for i := 0; i < m.PacketCount(); i++ { - - pack := m.Packet(i) - conn.Write(pack.Buffer) - bytes := make([]byte, 1024) - n, _ := conn.Read(bytes) - p := matcher.NewPacket(bytes, n) - - if m.Match(i, p, nil) { - t.Log("SNMP found") - return - } - - t.Error("SNMP not found") - } - -} diff --git a/service/match/snmp/snmpv3_test.go b/service/match/snmp/snmpv3_test.go deleted file mode 100644 index 0f7f545..0000000 --- a/service/match/snmp/snmpv3_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package snmp - - -import ( - "git.loafle.net/overflow/overflow_discovery/service/matcher" - "net" - "testing" -) - -func TestSNMP3(t *testing.T) { - - m := NewSNMPv3Matcher() - - conn, err := net.Dial("udp", "192.168.1.15:161") - if err != nil { - t.Error(err) - return - } - defer conn.Close() - - for i := 0; i < m.PacketCount(); i++ { - - pack := m.Packet(i) - conn.Write(pack.Buffer) - bytes := make([]byte, 1024) - n, _ := conn.Read(bytes) - p := matcher.NewPacket(bytes, n) - - if m.Match(i, p, nil) { - t.Log("SNMP found") - return - } - - t.Error("SNMP not found") - } - -} diff --git a/service/match/ssh/ssh_test.go b/service/match/ssh/ssh_test.go deleted file mode 100644 index 5fd72fc..0000000 --- a/service/match/ssh/ssh_test.go +++ /dev/null @@ -1,35 +0,0 @@ -package ssh - -import ( - "fmt" - //"git.loafle.net/overflow/overflow_discovery/match/ssh" - "git.loafle.net/overflow/overflow_discovery/service/matcher" - //"git.loafle.net/overflow/overflow_discovery/collector/discovery/types" - "net" - "testing" - -) - -func TestSSHMatcher_Match(t *testing.T) { - - //port := types.NewPort("22", types.NewHost("192.168.1.103"), types.TYPE_TCP) - //ssh := NewSSHMatcher() - // - //var ipport string - //ipport = port.Host.Ip + ":" + string(port.Port) - - client, _ := net.Dial("tcp", "192.168.1.10:22") - - defer client.Close() - - bytes := make([]byte, 512) - - l, _ := client.Read(bytes) - - fmt.Println(bytes) - - b := NewSSHMatcher().Match(0, matcher.NewPacket(bytes, l), nil) - - fmt.Println(b) - -} diff --git a/service/match/telnet/telnet_test.go b/service/match/telnet/telnet_test.go deleted file mode 100644 index d7ca223..0000000 --- a/service/match/telnet/telnet_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package telnet - -import ( - "fmt" - "git.loafle.net/overflow/overflow_discovery/service/matcher" - - "net" - "testing" -) - -func TestTelnetMatcher_Match(t *testing.T) { - - //port := types.NewPort("23", types.NewHost("192.168.1.210"), types.TYPE_TCP) - //telnet := NewTelnetMatcher() - // - //var ipport string - //ipport = port.Host.Ip + ":" + string(port.Port) - - client, _ := net.Dial("tcp", "192.168.1.105:23") - - defer client.Close() - - bytes := make([]byte, 512) - - l, _ := client.Read(bytes) - - fmt.Println("length :", l) - fmt.Println(bytes) - - b := NewTelnetMatcher().Match(0, matcher.NewPacket(bytes, l), nil) - - fmt.Println(b) -} diff --git a/service/match/wmi/wmi_test.go b/service/match/wmi/wmi_test.go deleted file mode 100644 index ecadd53..0000000 --- a/service/match/wmi/wmi_test.go +++ /dev/null @@ -1,51 +0,0 @@ -package wmi - -import ( - "fmt" - "git.loafle.net/overflow/overflow_discovery/service/matcher" - //"git.loafle.net/overflow/overflow_discovery/collector/discovery/scan/matcher/scaninfo" - //"git.loafle.net/overflow/overflow_discovery/collector/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", "192.168.1.106:135") - - 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, matcher.NewPacket(bytes, read), nil) - - if b { - fmt.Println("Good") - } - - } - - -}