This commit is contained in:
crusader 2018-09-03 16:59:17 +09:00
parent 60e5f1c7c3
commit bf7500671e
4 changed files with 50 additions and 50 deletions

View File

@ -109,7 +109,7 @@ func sendUDP4(discoverySession session.DiscoverySession, ps pcap.PCapScanner, ho
addr := &net.UDPAddr{IP: ip.To4(), Port: portNumber}
for i := 0; i < _matcher.PacketCount(); i++ {
p := _matcher.Packet(i)
if _, err := conn.WriteToUDP(p.Bytes(), addr); err != nil {
if _, err := conn.WriteToUDP(p.Buffer, addr); err != nil {
log.Print("UDP write error", err)
}
}

View File

@ -107,7 +107,7 @@ LOOP:
if err := conn.SetWriteDeadline(time.Now().Add(1 * time.Second)); nil != err {
return nil
}
_, err := conn.Write(_packet.Bytes())
_, err := conn.Write(_packet.Buffer)
if nil != err {
return nil
}
@ -164,7 +164,7 @@ LOOP:
if err := conn.SetWriteDeadline(time.Now().Add(1 * time.Second)); nil != err {
break INNER_LOOP
}
_, err := conn.Write(_packet.Bytes())
_, err := conn.Write(_packet.Buffer)
if nil != err {
break INNER_LOOP
}
@ -181,7 +181,7 @@ LOOP:
break INNER_LOOP
}
// log.Printf("res: %s", string(buf[:n]))
log.Printf("res: %s", string(buf[:n]))
if err := matcher.Match(info, j+1, osm.NewPacket(buf, n)); err == nil {
if packetCount-1 == j {

View File

@ -49,17 +49,17 @@ func Test_scanTCP(t *testing.T) {
args args
wantErr bool
}{
{
name: "80",
args: args{
discoverySession: s,
targetPort: __test.Port(
targetHost,
"80",
),
},
wantErr: false,
},
// {
// name: "80",
// args: args{
// discoverySession: s,
// targetPort: __test.Port(
// targetHost,
// "80",
// ),
// },
// wantErr: false,
// },
{
name: "139",
args: args{
@ -71,39 +71,39 @@ func Test_scanTCP(t *testing.T) {
},
wantErr: false,
},
{
name: "443",
args: args{
discoverySession: s,
targetPort: __test.Port(
targetHost,
"443",
),
},
wantErr: false,
},
{
name: "445",
args: args{
discoverySession: s,
targetPort: __test.Port(
targetHost,
"445",
),
},
wantErr: false,
},
{
name: "548",
args: args{
discoverySession: s,
targetPort: __test.Port(
targetHost,
"548",
),
},
wantErr: false,
},
// {
// name: "443",
// args: args{
// discoverySession: s,
// targetPort: __test.Port(
// targetHost,
// "443",
// ),
// },
// wantErr: false,
// },
// {
// name: "445",
// args: args{
// discoverySession: s,
// targetPort: __test.Port(
// targetHost,
// "445",
// ),
// },
// wantErr: false,
// },
// {
// name: "548",
// args: args{
// discoverySession: s,
// targetPort: __test.Port(
// targetHost,
// "548",
// ),
// },
// wantErr: false,
// },
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

View File

@ -39,7 +39,7 @@ func processPrepacket(ch chan *Res, conn net.Conn, m csm.Matcher) {
n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n)
_, err := conn.Write(m.Packet(i).Bytes())
_, err := conn.Write(m.Packet(i).Buffer)
if err != nil {
ch <- &Res{nil, err}
close(ch)
@ -57,7 +57,7 @@ func processPrepacket(ch chan *Res, conn net.Conn, m csm.Matcher) {
func processPostpacket(ch chan *Res, conn net.Conn, m csm.Matcher) {
for i := 0; i < m.PacketCount(); i++ {
_, err := conn.Write(m.Packet(i).Bytes())
_, err := conn.Write(m.Packet(i).Buffer)
if err != nil {
ch <- &Res{nil, err}
close(ch)