Exemple #1
0
 public static void PrintCubeResolver(string[] args)
 {
     try
     {
         if (args.Length == 2) // name
         {
             DnsResolvers.CubeResolver(args[1], IPAddress.Parse("1.1.1.1"));
         }
         else if (args.Length == 3) // name + dns
         {
             DnsResolvers.CubeResolver(args[1], IPAddress.Parse(args[2]));
         }
         else if (args.Length == 4) // name + dns + QTYPE
         {
             DnsResolvers.CubeResolver(args[1], IPAddress.Parse(args[2]), (DnsResolvers.QTYPE)Enum.Parse(typeof(DnsResolvers.QTYPE), args[3]));
         }
         else if (args.Length == 5 && args[4] == "DoH") // name + dns + QTYPE + QueryTransport
         {
             DnsResolvers.CubeResolver(args[1], null, (DnsResolvers.QTYPE)Enum.Parse(typeof(DnsResolvers.QTYPE), args[3]), (DnsResolvers.QueryTransport)Enum.Parse(typeof(DnsResolvers.QueryTransport), args[4]), args[2]);
         }
         else if (args.Length == 5)
         {
             DnsResolvers.CubeResolver(args[1], IPAddress.Parse(args[2]), (DnsResolvers.QTYPE)Enum.Parse(typeof(DnsResolvers.QTYPE), args[3]), (DnsResolvers.QueryTransport)Enum.Parse(typeof(DnsResolvers.QueryTransport), args[4]));
         }
         else
         {
             return;
         }
     }
     catch (FormatException e)
     {
         Console.WriteLine($"Invalid DNS server: {args[2]}\nException thrown: {e}");
     }
 }
Exemple #2
0
        public static void PrintOSResolver(string[] args)
        {
            var result = DnsResolvers.OSResolver(args[1]);

            // PTR query
            if (result.qTYPE == DnsResolvers.QTYPE.PTR)
            {
                Console.WriteLine($"IP: {args[1]}\nHostname: {result.hostname}");
            }
            else
            {
                Console.WriteLine($"Hostname: {args[1]}\nAddresses:");
                foreach (IPAddress address in result.ips)
                {
                    Console.WriteLine($"\t{address}");
                }
            }
        }
Exemple #3
0
        public static void PrintDoHJson(string[] args)
        {
            (string responseBody, DoHResponse doHResponse)result;

            try
            {
                if (args.Length == 2) // name
                {
                    result = DnsResolvers.DoHJson(args[1]);
                }
                else if (args.Length == 3) // name + dns
                {
                    result = DnsResolvers.DoHJson(args[1], args[2]);
                }
                else if (args.Length == 4) // name + dns + QTYPE
                {
                    result = DnsResolvers.DoHJson(args[1], args[2], (DnsResolvers.QTYPE)Enum.Parse(typeof(DnsResolvers.QTYPE), args[3]));
                }
                else if (args.Length == 5) // name + dns + QTYPE + DNSSEC (do)
                {
                    result = DnsResolvers.DoHJson(args[1], args[2], (DnsResolvers.QTYPE)Enum.Parse(typeof(DnsResolvers.QTYPE), args[3]), Boolean.Parse(args[4]));
                }
                else
                {
                    Console.WriteLine("Invalid arguments.");
                    return;
                }

                Console.WriteLine($"####### Response JSON #######\n{result.responseBody}\n");
                foreach (DoHAnswer doHAnswer in result.doHResponse.Answer)
                {
                    Console.WriteLine($"####### Parsed Response #######\n{doHAnswer.data}\n");
                }
            }
            catch (HttpRequestException e)
            {
                Console.WriteLine($"{e}");
            }
        }