1

C# と PCAP を使用して DNS 要求を作成しました。Wireshark を使用してリクエストを確認しました。しかし、応答がありません。

応答のあるDNSリクエストを比較しました。フラグと DNS クエリの値は同じです。

DNS リゾルバーが応答を送信しない理由がわかりません。私を助けてください。

ありがとうございました。

私のパケット生成方法:

    private Packet getPacket(string s, string d,string domain)
    {
        Random r = new Random();
        EthernetLayer ethernetLayer =
  new EthernetLayer
  {
      Source = new MacAddress("00:0C:29:E5:FA:36"),
      Destination = new MacAddress("00:0c:29:e5:fa:36"),
      EtherType = EthernetType.None, // Will be filled automatically.

  };


        IpV4Layer ipV4Layer =
            new IpV4Layer
            {
                Source = new IpV4Address(s),
                CurrentDestination = new IpV4Address(d),
                Fragmentation = IpV4Fragmentation.None,
                HeaderChecksum = null, // Will be filled automatically.
                Identification = 123,
                Options = IpV4Options.None,
                Protocol = null, // Will be filled automatically.
                Ttl = 100,
                TypeOfService = 0,

            };

        UdpLayer udpLayer =
            new UdpLayer
            {
               SourcePort =ushort.MaxValue,
                DestinationPort = 53,
                Checksum = null, // Will be filled automatically.
                CalculateChecksumValue = true,

            };

        DnsLayer dnsLayer =
            new DnsLayer
            {
                Id = ushort.Parse(r.Next(0,99999).ToString()),
                IsResponse = false,
                OpCode = DnsOpCode.Query,
                IsAuthoritativeAnswer = false,
                IsTruncated = false,
                IsRecursionDesired = true,
                IsRecursionAvailable = false,
                FutureUse = false,
                IsAuthenticData = false,
                IsCheckingDisabled = false,
                ResponseCode = DnsResponseCode.NoError,
                Queries = new[]
                                  {
                                      new DnsQueryResourceRecord(new DnsDomainName("col.stc.s-msn.com"),
                                                                 DnsType.A,
                                                                 DnsClass.Internet),
                                  },
                Answers = null,
                Authorities = null,
                Additionals = null,
                DomainNameCompressionMode = DnsDomainNameCompressionMode.All,
            };

        PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, udpLayer, dnsLayer);

        return builder.Build(DateTime.Now);
    }
}

これは私のパケット送信機能です:

    private static void performRequest(LivePacketDevice device)
    {
        using (PacketCommunicator communicator = device.Open(100,PacketDeviceOpenAttributes.Promiscuous,1000))
        {
            for (int i = 0; i < threadCount; i++)
            {
                Thread requester= new Thread(() =>
                {
                    try
                    {
                        Program p = new Program();
                        Random r = new Random();
                        string resolve = resolvers[r.Next(0, resolvers.Count-1)].ToString();

                        communicator.SendPacket(p.getPacket(destinationIP.ToString(), resolve, domainName));

                        p = null;
                        r = null;
                    }
                    catch (Exception ex) { Console.WriteLine(ex.Message); }
                });
                requester.Start();

                Thread.Sleep(1000);
            }

        }
    }
4

1 に答える 1