misc: small fix or general refactoring i did not bother commenting

This commit is contained in:
evilsocket 2019-04-22 11:47:36 +02:00
commit 30d9415d8c
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
5 changed files with 25 additions and 24 deletions

View file

@ -46,6 +46,12 @@ func (mod *SynScanner) onPacket(pkt gopacket.Packet) {
from := ip.SrcIP.String()
port := int(tcp.SrcPort)
openPort := &OpenPort{
Proto: "tcp",
Port: port,
Service: network.GetServiceByPort(port, "tcp"),
}
var host *network.Endpoint
if ip.SrcIP.Equal(mod.Session.Interface.IP) {
host = mod.Session.Interface
@ -58,20 +64,13 @@ func (mod *SynScanner) onPacket(pkt gopacket.Packet) {
if host != nil {
ports := host.Meta.GetOr("ports", map[int]*OpenPort{}).(map[int]*OpenPort)
if _, found := ports[port]; !found {
openPort := &OpenPort{
Proto: "tcp",
Port: port,
Service: network.GetServiceByPort(port, "tcp"),
}
ports[port] = openPort
mod.bannerQueue.Add(async.Job(grabberJob{host, openPort}))
}
host.Meta.Set("ports", ports)
}
mod.bannerQueue.Add(async.Job(grabberJob{from, openPort}))
NewSynScanEvent(from, host, port).Push()
}
}