mirror of
https://github.com/bettercap/bettercap
synced 2025-07-05 20:42:09 -07:00
fix: fixed a nbns parsing bug who sometimes returned binary hostnames
This commit is contained in:
parent
90bb05cd5b
commit
e93fe8ec4c
1 changed files with 7 additions and 2 deletions
|
@ -1,6 +1,8 @@
|
||||||
package packets
|
package packets
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/evilsocket/islazy/str"
|
"github.com/evilsocket/islazy/str"
|
||||||
|
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
|
@ -27,8 +29,11 @@ var (
|
||||||
func NBNSGetMeta(pkt gopacket.Packet) map[string]string {
|
func NBNSGetMeta(pkt gopacket.Packet) map[string]string {
|
||||||
if ludp := pkt.Layer(layers.LayerTypeUDP); ludp != nil {
|
if ludp := pkt.Layer(layers.LayerTypeUDP); ludp != nil {
|
||||||
if udp := ludp.(*layers.UDP); udp != nil && udp.SrcPort == NBNSPort && len(udp.Payload) >= NBNSMinRespSize {
|
if udp := ludp.(*layers.UDP); udp != nil && udp.SrcPort == NBNSPort && len(udp.Payload) >= NBNSMinRespSize {
|
||||||
return map[string]string{
|
hostname := str.Trim(string(udp.Payload[57:72]))
|
||||||
"nbns:hostname": str.Trim(string(udp.Payload[57:72])),
|
if strconv.IsPrint(rune(hostname[0])) {
|
||||||
|
return map[string]string{
|
||||||
|
"nbns:hostname": hostname,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue