Class: BetterCap::Discovery::Agents::Wsd
- Inherits:
-
Object
- Object
- BetterCap::Discovery::Agents::Wsd
- Defined in:
- lib/bettercap/discovery/agents/wsd.rb
Overview
Class responsible for sending WS-Discovery broadcast queries to the network.
Instance Method Summary collapse
-
#initialize(ctx, address = nil) ⇒ Wsd
constructor
References: - https://msdn.microsoft.com/en-us/library/windows/desktop/bb513684(v=vs.85).aspx - http://specs.xmlsoap.org/ws/2005/04/discovery/ws-discovery.pdf - https://en.wikipedia.org/wiki/Web_Services_for_Devices - https://en.wikipedia.org/wiki/WS-Discovery - https://en.wikipedia.org/wiki/Zero-configuration_networking#WS-Discovery.
Constructor Details
#initialize(ctx, address = nil) ⇒ Wsd
References:
- https://msdn.microsoft.com/en-us/library/windows/desktop/bb513684(v=vs.85).aspx
- http://specs.xmlsoap.org/ws/2005/04/discovery/ws-discovery.pdf
- https://en.wikipedia.org/wiki/Web_Services_for_Devices
- https://en.wikipedia.org/wiki/WS-Discovery
- https://en.wikipedia.org/wiki/Zero-configuration_networking#WS-Discovery
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/bettercap/discovery/agents/wsd.rb', line 34 def initialize( ctx, address = nil ) pkt = PacketFu::UDPPacket.new pkt.eth_saddr = ctx.iface.mac pkt.eth_daddr = '01:00:5e:7f:ff:fa' pkt.ip_saddr = ctx.iface.ip pkt.ip_daddr = '239.255.255.250' pkt.udp_src = (rand((2 ** 16) - 1024) + 1024).to_i pkt.udp_dst = 3702 uuid = SecureRandom.uuid payload = '<?xml version="1.0" encoding="utf-8" ?>' payload << '<soap:Envelope' payload << ' xmlns:soap="http://www.w3.org/2003/05/soap-envelope"' payload << ' xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"' payload << ' xmlns:wsd="http://schemas.xmlsoap.org/ws/2005/04/discovery"' payload << ' xmlns:wsdp="http://schemas.xmlsoap.org/ws/2006/02/devprof">' payload << '<soap:Header>' # WS-Discovery payload << '<wsa:To>urn:schemas-xmlsoap-org:ws:2005:04:discovery</wsa:To>' # Action (Probe) payload << "<wsa:Action>http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</wsa:Action>" # Message identifier (unique GUID) payload << "<wsa:MessageID>urn:uuid:#{uuid}</wsa:MessageID>" payload << '</soap:Header>' payload << '<soap:Body>' payload << '<wsd:Probe/>' # WS-Discovery type (blank) payload << '</soap:Body>' payload << '</env:Envelope>' pkt.payload = payload pkt.recalc ctx.packets.push(pkt) end |