overflow_discovery/service/matcher/smb/smb_test.go
crusader 46be2aa395 ing
2017-11-21 21:52:45 +09:00

44 lines
583 B
Go

package smb
import (
"net"
"testing"
"git.loafle.net/overflow/overflow_discovery/service/matcher"
)
const (
ADDR string = "192.168.1.106:445"
)
func TestSMBMatcher(t *testing.T) {
m := NewMatcher()
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(nil, i, p) {
t.Log("SMB found.")
return
}
t.Error("SMB not found")
}
}