fix: syn.scanner now uses a dedicated pcap handle to prevent deadlocks and improve performances

This commit is contained in:
evilsocket 2019-04-21 20:37:41 +02:00
commit cd249687da
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
4 changed files with 87 additions and 80 deletions

View file

@ -1,7 +1,6 @@
package syn_scan
import (
"net"
"sync/atomic"
"github.com/bettercap/bettercap/network"
@ -19,15 +18,6 @@ type OpenPort struct {
Port int `json:"port"`
}
func (mod *SynScanner) isAddressInRange(ip net.IP) bool {
for _, a := range mod.addresses {
if a.Equal(ip) {
return true
}
}
return false
}
func (mod *SynScanner) onPacket(pkt gopacket.Packet) {
var eth layers.Ethernet
var ip layers.IPv4
@ -46,7 +36,7 @@ func (mod *SynScanner) onPacket(pkt gopacket.Packet) {
return
}
if mod.isAddressInRange(ip.SrcIP) && tcp.DstPort == synSourcePort && tcp.SYN && tcp.ACK {
if tcp.DstPort == synSourcePort && tcp.SYN && tcp.ACK {
atomic.AddUint64(&mod.stats.openPorts, 1)
from := ip.SrcIP.String()