Class: BetterCap::Discovery::Agents::Mdns
- Inherits:
-
Object
- Object
- BetterCap::Discovery::Agents::Mdns
- Defined in:
- lib/bettercap/discovery/agents/mdns.rb
Overview
Class responsible for sending mDNS broadcast queries to the network.
Instance Method Summary collapse
-
#initialize(ctx, address = nil) ⇒ Mdns
constructor
Create a thread which will send an mDNS broadcast query in order to populate the ARP cache with active targets.
Constructor Details
#initialize(ctx, address = nil) ⇒ Mdns
Create a thread which will send an mDNS broadcast query in order to populate the ARP cache with active targets. http://www.multicastdns.org/ http://www.ietf.org/rfc/rfc6762.txt https://en.wikipedia.org/wiki/Multicast_DNS https://en.wikipedia.org/wiki/Zero-configuration_networking#DNS-SD_with_multicast
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/bettercap/discovery/agents/mdns.rb', line 30 def initialize( ctx, address = nil ) pkt = PacketFu::UDPPacket.new pkt.eth_saddr = ctx.iface.mac pkt.eth_daddr = '01:00:5e:00:00:fb' pkt.ip_saddr = ctx.iface.ip pkt.ip_daddr = '224.0.0.251' pkt.udp_src = (rand((2 ** 16) - 1024) + 1024).to_i pkt.udp_dst = 5353 query = "\x09_services\x07_dns-sd\x04_udp\x05local" payload = "\x00\x01" # Transaction ID payload << "\x00\x00" # Flags payload << "\x00\x01" # Number of questions payload << "\x00\x00" # Number of answers payload << "\x00\x00" # Number of authority resource records payload << "\x00\x00" # Number of additional resource records payload << query # Query payload << "\x00" # Terminator payload << "\x00\x0c" # Type (PTR) payload << "\x00\x01" # Class pkt.payload = payload pkt.recalc ctx.packets.push(pkt) end |