mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 05:23:19 -07:00
fix: syn.scanner now uses a dedicated pcap handle to prevent deadlocks and improve performances
This commit is contained in:
parent
8257d25ff3
commit
cd249687da
4 changed files with 87 additions and 80 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue