service_matcher-go/oracle/oracle_test.go
2018-09-03 22:36:57 +09:00

50 lines
870 B
Go

package oracle
import (
osm "git.loafle.net/overflow/service_matcher-go"
"net"
"testing"
)
func TestOracle(t *testing.T) {
lm := NewMatcher()
//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)
conn, err := net.Dial("tcp", "192.168.1.15:1521")
if err != nil {
t.Errorf("ERR %s", err)
}
defer conn.Close()
matchCtx := osm.NewMatchCtx("192.168.1.15", 1521)
t.Log(lm.PacketCount(matchCtx))
for ii := 0; ii < lm.PacketCount(matchCtx); ii++ {
pack := lm.Packet(matchCtx, ii)
t.Log(pack)
conn.Write(pack.Buffer)
bytes := make([]byte, 1024)
read, _ := conn.Read(bytes)
t.Log(bytes)
if err := lm.Match(matchCtx, ii, osm.NewPacket(bytes, read)); nil == err {
t.Log("Good")
}
}
}