service_matcher-go/oracle/oracle_test.go

50 lines
870 B
Go
Raw Normal View History

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