mirror of
https://github.com/bettercap/bettercap
synced 2025-07-30 11:40:33 -07:00
36 lines
912 B
Go
36 lines
912 B
Go
package packets
|
|
|
|
import (
|
|
"github.com/bettercap/bettercap/core"
|
|
|
|
"github.com/google/gopacket"
|
|
"github.com/google/gopacket/layers"
|
|
)
|
|
|
|
const (
|
|
NBNSPort = 137
|
|
NBNSMinRespSize = 73
|
|
)
|
|
|
|
var (
|
|
// NBNS hostname resolution request buffer.
|
|
NBNSRequest = []byte{
|
|
0x82, 0x28, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0,
|
|
0x0, 0x0, 0x20, 0x43, 0x4B, 0x41, 0x41, 0x41, 0x41,
|
|
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
|
|
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
|
|
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x0,
|
|
0x0, 0x21, 0x0, 0x1,
|
|
}
|
|
)
|
|
|
|
func NBNSGetMeta(pkt gopacket.Packet) map[string]string {
|
|
if ludp := pkt.Layer(layers.LayerTypeUDP); ludp != nil {
|
|
if udp := ludp.(*layers.UDP); udp != nil && udp.SrcPort == NBNSPort && len(udp.Payload) >= NBNSMinRespSize {
|
|
return map[string]string{
|
|
"nbns:hostname": core.Trim(string(udp.Payload[57:72])),
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|