network_service_matcher/netbios/netbios_test.go

34 lines
504 B
Go
Raw Permalink Normal View History

2017-12-04 07:27:08 +00:00
package netbios
import (
"net"
"testing"
cnsm "git.loafle.net/commons_go/network_service_matcher"
)
func TestNBSS(t *testing.T) {
m := NewMatcher()
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 := cnsm.NewPacket(bytes, n)
if m.Match(nil, i, p) {
t.Log("NBSS found")
return
}
t.Error("NBSS not found")
}
}