mirror of
https://github.com/bettercap/bettercap
synced 2025-07-15 01:23:42 -07:00
refact: refactored syn.scan open port log as proper event
This commit is contained in:
parent
ce76c7258d
commit
42b08db0b0
3 changed files with 38 additions and 4 deletions
|
@ -164,11 +164,9 @@ func (s *SynScanner) onPacket(pkt gopacket.Packet) {
|
|||
|
||||
if s.inRange(ip.SrcIP) && tcp.DstPort == synSourcePort && tcp.SYN && tcp.ACK {
|
||||
from := ip.SrcIP.String()
|
||||
|
||||
log.Info("Found open port %d for %s", tcp.SrcPort, core.Bold(from))
|
||||
port := int(tcp.SrcPort)
|
||||
|
||||
var host *network.Endpoint
|
||||
|
||||
if ip.SrcIP.Equal(s.Session.Interface.IP) {
|
||||
host = s.Session.Interface
|
||||
} else if ip.SrcIP.Equal(s.Session.Gateway.IP) {
|
||||
|
@ -179,7 +177,7 @@ func (s *SynScanner) onPacket(pkt gopacket.Packet) {
|
|||
|
||||
if host != nil {
|
||||
sports := strings.Split(host.Meta.Get("tcp-ports").(string), ",")
|
||||
ports := []int{int(tcp.SrcPort)}
|
||||
ports := []int{port}
|
||||
|
||||
for _, s := range sports {
|
||||
n, err := strconv.Atoi(s)
|
||||
|
@ -195,6 +193,8 @@ func (s *SynScanner) onPacket(pkt gopacket.Packet) {
|
|||
}
|
||||
|
||||
host.Meta.Set("tcp-ports", strings.Join(list, ","))
|
||||
|
||||
NewSynScanEvent(host, port).Push()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue