This commit is contained in:
crusader 2018-10-23 12:09:40 +09:00
parent df9121603d
commit 212d3feb38
2 changed files with 20 additions and 16 deletions

View File

@ -71,8 +71,6 @@ func scanV4(discoverySession session.DiscoverySession, targetHost *omd.Host) (er
} }
}() }()
log.Print("SYN start ", targetHost.Address)
go func() { go func() {
if err = sendTCP4(discoverySession, ps, targetHost, stopChan); nil != err { if err = sendTCP4(discoverySession, ps, targetHost, stopChan); nil != err {
log.Printf("sendTCP %v", err) log.Printf("sendTCP %v", err)
@ -108,37 +106,37 @@ Loop:
} }
} }
} }
startTime := time.Now() // startTime := time.Now()
tcpPacket.TCP.DstPort = layers.TCPPort(portNumber) tcpPacket.TCP.DstPort = layers.TCPPort(portNumber)
if err := tcpPacket.TCP.SetNetworkLayerForChecksum(tcpPacket.IP); err != nil { if err := tcpPacket.TCP.SetNetworkLayerForChecksum(tcpPacket.IP); err != nil {
return err return err
} }
if 80 == portNumber || 41111 == portNumber { // if 80 == portNumber || 41111 == portNumber {
log.Print("1 SYN IP:", host.Address, " Port:", portNumber, " t:", time.Since(startTime)) // log.Print("1 SYN IP:", host.Address, " Port:", portNumber, " t:", time.Since(startTime))
} // }
if err := gopacket.SerializeLayers(buf, tcpPacket.Opts, tcpPacket.Eth, tcpPacket.IP, tcpPacket.TCP); err != nil { if err := gopacket.SerializeLayers(buf, tcpPacket.Opts, tcpPacket.Eth, tcpPacket.IP, tcpPacket.TCP); err != nil {
return err return err
} }
if 80 == portNumber || 41111 == portNumber { // if 80 == portNumber || 41111 == portNumber {
log.Print("2 SYN IP:", host.Address, " Port:", portNumber, " t:", time.Since(startTime)) // log.Print("2 SYN IP:", host.Address, " Port:", portNumber, " t:", time.Since(startTime))
} // }
if err := ps.WritePacketData(buf.Bytes()); err != nil { if err := ps.WritePacketData(buf.Bytes()); err != nil {
return err return err
} }
if 80 == portNumber || 41111 == portNumber { // if 80 == portNumber || 41111 == portNumber {
log.Print("3 SYN IP:", host.Address, " Port:", portNumber, " t:", time.Since(startTime)) // log.Print("3 SYN IP:", host.Address, " Port:", portNumber, " t:", time.Since(startTime))
} // }
select { select {
case <-time.After(time.Microsecond * 10): case <-time.After(time.Microsecond * 10):
case <-stopChan: case <-stopChan:
return nil return nil
} }
if 80 == portNumber || 41111 == portNumber { // if 80 == portNumber || 41111 == portNumber {
log.Print("4 SYN IP:", host.Address, " Port:", portNumber, " t:", time.Since(startTime)) // log.Print("4 SYN IP:", host.Address, " Port:", portNumber, " t:", time.Since(startTime))
} // }
} }
return nil return nil

View File

@ -2,6 +2,7 @@ package service
import ( import (
"fmt" "fmt"
"log"
"net" "net"
"time" "time"
@ -15,7 +16,7 @@ import (
) )
const ( const (
deadline = time.Millisecond * 500 deadline = time.Millisecond * 1000
) )
func scanTCP(discoverySession session.DiscoverySession, targetPort *omd.Port) error { func scanTCP(discoverySession session.DiscoverySession, targetPort *omd.Port) error {
@ -54,6 +55,10 @@ func scanTCP(discoverySession session.DiscoverySession, targetPort *omd.Port) er
var discoveredMatcher osm.Matcher var discoveredMatcher osm.Matcher
var discoveredConnector connector var discoveredConnector connector
if targetPort.PortNumber == "7" {
log.Print("")
}
LOOP: LOOP:
for _, _connector := range connectors { for _, _connector := range connectors {
conn, err := _connector.dial(targetPort) conn, err := _connector.dial(targetPort)
@ -221,6 +226,7 @@ LOOP:
} }
_, err := conn.Write(_packet.Buffer) _, err := conn.Write(_packet.Buffer)
if nil != err { if nil != err {
log.Print(err)
break INNER_LOOP break INNER_LOOP
} }