This commit is contained in:
crusader 2018-09-28 18:46:46 +09:00
parent a8d61c6657
commit 3c2c480f83

View File

@ -94,10 +94,11 @@ func sendTCP4(discoverySession session.DiscoverySession, ps pcap.PCapScanner, ho
} }
buf := gopacket.NewSerializeBuffer() buf := gopacket.NewSerializeBuffer()
startTime := time.Now()
Loop: Loop:
for portNumber := dp.FirstScanRange; portNumber < dp.LastScanRange; portNumber++ { for portNumber := dp.FirstScanRange; portNumber < dp.LastScanRange; portNumber++ {
startTime := time.Now()
if nil != dp.ExcludePorts { if nil != dp.ExcludePorts {
for _, exPortNumber := range dp.ExcludePorts { for _, exPortNumber := range dp.ExcludePorts {
if portNumber == exPortNumber { if portNumber == exPortNumber {
@ -105,27 +106,43 @@ Loop:
} }
} }
} }
if 80 == portNumber || 111 == portNumber {
log.Print("1 IP:", host.Address, " Port:", portNumber, " t:", time.Since(startTime))
}
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 || 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 { if err := gopacket.SerializeLayers(buf, tcpPacket.Opts, tcpPacket.Eth, tcpPacket.IP, tcpPacket.TCP); err != nil {
return err 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 { if err := ps.WritePacketData(buf.Bytes()); err != nil {
return err return err
} }
if 80 == portNumber || 111 == portNumber {
log.Print("4 IP:", host.Address, " Port:", portNumber, " t:", time.Since(startTime))
}
select { select {
case <-time.After(time.Microsecond * 100): case <-time.After(time.Microsecond * 100):
case <-stopChan: case <-stopChan:
return nil return nil
} }
} if 80 == portNumber || 111 == portNumber {
log.Print("5 IP:", host.Address, " Port:", portNumber, " t:", time.Since(startTime))
}
log.Print("IP:", host.Address, " t:", time.Since(startTime)) }
return nil return nil
} }