mirror of
https://github.com/bettercap/bettercap
synced 2025-07-06 04:52:10 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
fabf3bb8e9
commit
d2f13a3293
2 changed files with 35 additions and 23 deletions
|
@ -31,32 +31,26 @@ func (mod *EventsStream) viewZeroConfEvent(output io.Writer, e session.Event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
services := make([]string, 0)
|
services := make([]string, 0)
|
||||||
for _, q := range event.Query.Questions {
|
for _, q := range event.Services {
|
||||||
services = append(services, tui.Yellow(string(q.Name)))
|
services = append(services, tui.Yellow(q))
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
|
instPart := ""
|
||||||
|
if len(event.Instances) > 0 {
|
||||||
instances := make([]string, 0)
|
instances := make([]string, 0)
|
||||||
answers := append(event.Query.Answers, event.Query.Additionals...)
|
for _, q := range event.Instances {
|
||||||
for _, answer := range answers {
|
instances = append(instances, tui.Green(q))
|
||||||
if answer.Class == layers.DNSClassIN && answer.Type == layers.DNSTypePTR {
|
|
||||||
instances = append(instances, tui.Green(string(answer.PTR)))
|
|
||||||
} else {
|
|
||||||
instances = append(instances, tui.Green(answer.String()))
|
|
||||||
}
|
}
|
||||||
|
instPart = fmt.Sprintf(" and instances %s", strings.Join(instances, ", "))
|
||||||
}
|
}
|
||||||
|
|
||||||
advPart := ""
|
fmt.Fprintf(output, "[%s] [%s] %s is browsing (%s) for services %s%s\n",
|
||||||
if len(instances) > 0 {
|
|
||||||
advPart = fmt.Sprintf(" and advertising %s", strings.Join(instances, ", "))
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
fmt.Fprintf(output, "[%s] [%s] %s is browsing (%s) for services %s\n",
|
|
||||||
e.Time.Format(mod.timeFormat),
|
e.Time.Format(mod.timeFormat),
|
||||||
tui.Green(e.Tag),
|
tui.Green(e.Tag),
|
||||||
source,
|
source,
|
||||||
ops.Ternary(event.Query.QR, "RESPONSE", "QUERY"),
|
ops.Ternary(event.Query.QR, "RESPONSE", "QUERY"),
|
||||||
strings.Join(services, ", "),
|
strings.Join(services, ", "),
|
||||||
|
instPart,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(output, "[%s] [%s] %v\n", e.Time.Format(mod.timeFormat), tui.Green(e.Tag), e)
|
fmt.Fprintf(output, "[%s] [%s] %v\n", e.Time.Format(mod.timeFormat), tui.Green(e.Tag), e)
|
||||||
|
|
|
@ -24,8 +24,10 @@ type ServiceDiscoveryEvent struct {
|
||||||
// an endpoint is browsing for specific services
|
// an endpoint is browsing for specific services
|
||||||
type BrowsingEvent struct {
|
type BrowsingEvent struct {
|
||||||
Source string `json:"source"`
|
Source string `json:"source"`
|
||||||
Query layers.DNS `json:"service"`
|
|
||||||
Endpoint *network.Endpoint `json:"endpoint"`
|
Endpoint *network.Endpoint `json:"endpoint"`
|
||||||
|
Services []string `json:"services"`
|
||||||
|
Instances []string `json:"instances"`
|
||||||
|
Query layers.DNS `json:"query"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mod *ZeroGod) onServiceDiscovered(svc *zeroconf.ServiceEntry) {
|
func (mod *ZeroGod) onServiceDiscovered(svc *zeroconf.ServiceEntry) {
|
||||||
|
@ -250,9 +252,25 @@ func (mod *ZeroGod) onPacket(pkt gopacket.Packet) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
services := make([]string, 0)
|
||||||
|
for _, q := range dns.Questions {
|
||||||
|
services = append(services, tui.Yellow(string(q.Name)))
|
||||||
|
}
|
||||||
|
|
||||||
|
instances := make([]string, 0)
|
||||||
|
for _, answer := range append(append(dns.Answers, dns.Additionals...), dns.Authorities...) {
|
||||||
|
if answer.Class == layers.DNSClassIN && answer.Type == layers.DNSTypePTR {
|
||||||
|
instances = append(instances, string(answer.PTR))
|
||||||
|
} else {
|
||||||
|
instances = append(instances, answer.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
event := BrowsingEvent{
|
event := BrowsingEvent{
|
||||||
Source: srcIP.String(),
|
Source: srcIP.String(),
|
||||||
Query: dns,
|
Query: dns,
|
||||||
|
Services: services,
|
||||||
|
Instances: instances,
|
||||||
Endpoint: mod.Session.Lan.GetByIp(srcIP.String()),
|
Endpoint: mod.Session.Lan.GetByIp(srcIP.String()),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue