This commit is contained in:
crusader 2018-09-28 18:49:02 +09:00
parent 3c2c480f83
commit 136aaf373a

View File

@ -71,11 +71,13 @@ func scanV4(discoverySession session.DiscoverySession, targetHost *omd.Host) (er
}
}()
if err = sendTCP4(discoverySession, ps, targetHost, stopChan); nil != err {
log.Printf("sendTCP %v", err)
return
}
sendComplete.Store(true)
go func() {
if err = sendTCP4(discoverySession, ps, targetHost, stopChan); nil != err {
log.Printf("sendTCP %v", err)
return
}
sendComplete.Store(true)
}()
select {
case <-timerStopped:
@ -97,8 +99,6 @@ func sendTCP4(discoverySession session.DiscoverySession, ps pcap.PCapScanner, ho
Loop:
for portNumber := dp.FirstScanRange; portNumber < dp.LastScanRange; portNumber++ {
startTime := time.Now()
if nil != dp.ExcludePorts {
for _, exPortNumber := range dp.ExcludePorts {
if portNumber == exPortNumber {
@ -106,42 +106,24 @@ Loop:
}
}
}
if 80 == portNumber || 111 == portNumber {
log.Print("1 IP:", host.Address, " Port:", portNumber, " t:", time.Since(startTime))
}
tcpPacket.TCP.DstPort = layers.TCPPort(portNumber)
if err := tcpPacket.TCP.SetNetworkLayerForChecksum(tcpPacket.IP); err != nil {
return err
}
if 80 == portNumber || 111 == portNumber {
log.Print("2 IP:", host.Address, " Port:", portNumber, " t:", time.Since(startTime))
}
if err := gopacket.SerializeLayers(buf, tcpPacket.Opts, tcpPacket.Eth, tcpPacket.IP, tcpPacket.TCP); err != nil {
return err
}
if 80 == portNumber || 111 == portNumber {
log.Print("3 IP:", host.Address, " Port:", portNumber, " t:", time.Since(startTime))
}
if err := ps.WritePacketData(buf.Bytes()); err != nil {
return err
}
if 80 == portNumber || 111 == portNumber {
log.Print("4 IP:", host.Address, " Port:", portNumber, " t:", time.Since(startTime))
}
select {
case <-time.After(time.Microsecond * 100):
case <-stopChan:
return nil
}
if 80 == portNumber || 111 == portNumber {
log.Print("5 IP:", host.Address, " Port:", portNumber, " t:", time.Since(startTime))
}
}
return nil