1

我正在 VS 中构建一个 C# 控制台应用程序,它要求用户输入域,例如 example.net并返回所有邮件记录(A、MX、SPF、DMARC、DKIM、CNAME)

我使用了下面的示例,它将返回 SPF TXT 记录的字符串,但不返回 DMARC 和 DKIM TXT 记录。奇怪?- 或不?

我在_domainkey.example.netk1._domainkey.example.net(DKIM)之后。

我在_dmarc.example.net(DMARC)之后。

private static IList<string> GetTxtRecords(string hostname)
        {
            IList<string> txtRecords = new List<string>();
            string output;
            string pattern = string.Format(@"{0}\s*text =\s*""([\w\-\=]*)""", hostname);

            var startInfo = new ProcessStartInfo("nslookup");
            startInfo.Arguments = string.Format("-type=TXT {0}", hostname);
            startInfo.RedirectStandardOutput = true;
            startInfo.UseShellExecute = false;
            startInfo.WindowStyle = ProcessWindowStyle.Hidden;

            using (var cmd = Process.Start(startInfo))
            {
                output = cmd.StandardOutput.ReadToEnd();
            }

            MatchCollection matches = Regex.Matches(output, pattern, RegexOptions.IgnoreCase);
            foreach (Match match in matches)
            {
                if (match.Success)
                    txtRecords.Add(match.Groups[1].Value);
            }

            return txtRecords;
        }

如何获取 DMARC 和 DOMAIN KEY (DKIM) 邮件记录?

4

1 回答 1

1

我会使用 ARSoft Tools for DNS 之类的实用程序来指定文本记录。

其次,包含 DKIM 签名标头的消息还包括子域的“选择器”:mail._domainkey.msn.com。其中“邮件”子域是选择器。

DKIM 签名标头中包含危害签名的标头。您将需要这些来验证消息的真实性。

于 2018-09-12T12:26:43.087 回答