65 lines
977 B
Go
65 lines
977 B
Go
|
package mssql
|
||
|
|
||
|
import (
|
||
|
"net"
|
||
|
"testing"
|
||
|
|
||
|
cnsm "git.loafle.net/commons_go/network_service_matcher"
|
||
|
)
|
||
|
|
||
|
/*
|
||
|
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 := NewMatcher()
|
||
|
|
||
|
for i := 0; i < m.PacketCount(); i++ {
|
||
|
|
||
|
pack := m.Packet(i)
|
||
|
conn.Write(pack.Buffer)
|
||
|
bytes := make([]byte, 1024)
|
||
|
n, _ := conn.Read(bytes)
|
||
|
p := cnsm.NewPacket(bytes, n)
|
||
|
|
||
|
if m.Match(nil, i, p) {
|
||
|
t.Log(m.ServiceName())
|
||
|
return
|
||
|
}
|
||
|
|
||
|
t.Error("MSSQL not found")
|
||
|
}
|
||
|
|
||
|
}
|