overflow_discovery/service/matcher/smb/smb_test.go
crusader 3dd6cb79ca ing
2017-11-21 21:47:55 +09:00

43 lines
581 B
Go

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