跳到正文
Skillpedia
安全35k · #8031

implementing-dmarc-dkim-spf-email-security

它能做什么

这个工具通过设置 SPF、DKIM 和 DMARC 三种安全机制来保护你的邮箱域名。这样可以防止别人冒用你的名义发送假邮件,同时确保你的邮件能顺利送达收件人。

适用场景

  • ✓当你第一次为域名设置邮件安全时。
  • ✓当你需要防范钓鱼和邮件伪造攻击时。
  • ✓当你需要检查邮件安全规则是否合规时。

技能链接

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-dmarc-dkim-spf-email-security/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-dmarc-dkim-spf-email-security/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“帮我的域名设置邮件安全。”

每周 5 个新技能,1 分钟读完。

工作原理

工具会先检查你当前的设置,然后在你的 DNS(管理互联网域名的系统)中为 SPF、DKIM 和 DMARC 创建相应的记录。这些记录会告诉其他邮件服务器,哪些服务器有权代表你发送邮件,以及如何验证邮件是否合法。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Implementing DMARC, DKIM, and SPF Email Security

Overview

SPF, DKIM, and DMARC form the three pillars of email authentication. Together they prevent domain spoofing, validate message integrity, and define policies for handling unauthenticated mail. Proper implementation drastically reduces phishing attacks that impersonate your organization's domain.

When to Use

  • When deploying or configuring implementing dmarc dkim spf email security capabilities in your environment
  • When establishing security controls aligned to compliance requirements
  • When building or improving security architecture for this domain
  • When conducting security assessments that require this implementation

Prerequisites

  • DNS management access for your domain
  • Access to email server/MTA configuration (Postfix, Exchange, Google Workspace, Microsoft 365)
  • Basic understanding of DNS TXT records
  • Python 3.8+ for validation scripts

Key Concepts

SPF (Sender Policy Framework)

Publishes a DNS TXT record listing authorized IP addresses and mail servers that can send email on behalf of your domain. Receiving servers check the envelope sender's IP against this list.

DKIM (DomainKeys Identified Mail)

Adds a cryptographic signature to outgoing emails using a private key. The corresponding public key is published in DNS. Receivers verify the signature to ensure the message was not altered in transit.

DMARC (Domain-based Message Authentication, Reporting and Conformance)

Builds on SPF and DKIM by specifying a policy (none/quarantine/reject) for messages that fail authentication, and provides a reporting mechanism to monitor spoofing attempts.

Workflow

Step 1: Audit Current State

# Check existing SPF record
dig TXT example.com | grep spf

# Check existing DKIM selector
dig TXT selector1._domainkey.example.com

# Check existing DMARC record
dig TXT _dmarc.example.com

Step 2: Implement SPF

# DNS TXT record for example.com
v=spf1 ip4:203.0.113.0/24 include:_spf.google.com include:spf.protection.outlook.com -all

Key SPF mechanisms:

  • ip4: / ip6: - Authorize specific IP ranges
  • include: - Include another domain's SPF record
  • a - Authorize domain's A record IPs
  • mx - Authorize domain's MX record IPs
  • -all - Hard fail all others (recommended)
  • ~all - Soft fail (monitoring phase)

Step 3: Implement DKIM

# Generate DKIM key pair (2048-bit RSA)
openssl genrsa -out dkim_private.pem 2048
openssl rsa -in dkim_private.pem -pubout -out dkim_public.pem

# Format public key for DNS (remove headers, join lines)
grep -v "PUBLIC KEY" dkim_public.pem | tr -d '\n'

DNS TXT record at selector1._domainkey.example.com:

v=DKIM1; k=rsa; p=MIIBIjANBgkqhki...

Step 4: Implement DMARC

# DNS TXT record at _dmarc.example.com
# Phase 1 (Monitor):
v=DMARC1; p=none; rua=mailto:dmarc-aggregate@example.com; ruf=mailto:dmarc-forensic@example.com; pct=100

# Phase 2 (Quarantine):
v=DMARC1; p=quarantine; rua=mailto:dmarc-aggregate@example.com; pct=25

# Phase 3 (Reject):
v=DMARC1; p=reject; rua=mailto:dmarc-aggregate@example.com; pct=100

Step 5: Monitor and Analyze DMARC Reports

Use the scripts/process.py to parse DMARC aggregate XML reports and identify authentication failures, unauthorized senders, and spoofing attempts.

Tools & Resources

Validation

  • SPF record passes validation at mxtoolbox.com
  • DKIM signature verified on test emails
  • DMARC record properly formatted and reporting enabled
  • Test emails pass all three checks in recipient's Authentication-Results header
常见问题

SPF、DKIM 和 DMARC 是什么?

它们都是用来证明一封邮件确实来自它声称的发件人的方法。SPF 检查发送服务器,DKIM 添加数字签名,DMARC 则规定当检测到异常时应该如何处理。

我需要有 DNS 的访问权限吗?

需要。要使用这个工具,你必须有权限为你的域名添加或修改 DNS 记录。

这能阻止所有垃圾邮件吗?

不能直接做到,但它能大大增加攻击者使用你的域名发送假邮件的难度,而这正是钓鱼和垃圾邮件攻击中的常见手段。

详情

作者的原始描述

Configures SPF, DKIM, and DMARC DNS TXT records to authenticate outbound email, prevent domain spoofing, and enforce a rejection/quarantine policy on unauthenticated mail, including auditing a domain's current DNS state. Use when hardening a domain's email security posture or defending against phishing and spoofing attacks.

repo: mukul975/Anthropic-Cybersecurity-Skills

热度

GitHub 星标
35k
排名
#8031
许可证
Apache-2.0
更新时间
2026/8/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能