mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 21:43:18 -07:00
new: syn.scan can now resolve port services too
This commit is contained in:
parent
9c381a449d
commit
0b430dd488
2 changed files with 563 additions and 2 deletions
|
@ -10,6 +10,13 @@ import (
|
|||
"github.com/google/gopacket/layers"
|
||||
)
|
||||
|
||||
type OpenPort struct {
|
||||
Proto string `json:"proto"`
|
||||
Banner string `json:"banner"`
|
||||
Service string `json:"service"`
|
||||
Port int `json:"port"`
|
||||
}
|
||||
|
||||
func (mod *SynScanner) isAddressInRange(ip net.IP) bool {
|
||||
for _, a := range mod.addresses {
|
||||
if a.Equal(ip) {
|
||||
|
@ -53,8 +60,16 @@ func (mod *SynScanner) onPacket(pkt gopacket.Packet) {
|
|||
}
|
||||
|
||||
if host != nil {
|
||||
ports := host.Meta.GetIntsWith("tcp-ports", port, true)
|
||||
host.Meta.SetInts("tcp-ports", ports)
|
||||
ports := host.Meta.GetOr("ports", map[int]OpenPort{}).(map[int]OpenPort)
|
||||
if _, found := ports[port]; !found {
|
||||
ports[port] = OpenPort{
|
||||
Proto: "tcp",
|
||||
Port: port,
|
||||
Service: network.GetServiceByPort(port, "tcp"),
|
||||
}
|
||||
}
|
||||
|
||||
host.Meta.Set("ports", ports)
|
||||
}
|
||||
|
||||
NewSynScanEvent(from, host, port).Push()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue