ing
This commit is contained in:
parent
3c2c480f83
commit
136aaf373a
|
@ -71,11 +71,13 @@ func scanV4(discoverySession session.DiscoverySession, targetHost *omd.Host) (er
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
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)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sendComplete.Store(true)
|
sendComplete.Store(true)
|
||||||
|
}()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-timerStopped:
|
case <-timerStopped:
|
||||||
|
@ -97,8 +99,6 @@ func sendTCP4(discoverySession session.DiscoverySession, ps pcap.PCapScanner, ho
|
||||||
|
|
||||||
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 {
|
||||||
|
@ -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)
|
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))
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue
Block a user