implementing-dmarc-dkim-spf-email-security
SPF、DKIM 和 DMARC 是邮件认证的三大支柱,共同防止域名伪造、验证消息完整性并定义处理未认证邮件的策略。正确实施可显著减少冒充组织域名的钓鱼攻击。
Best use case
implementing-dmarc-dkim-spf-email-security is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
SPF、DKIM 和 DMARC 是邮件认证的三大支柱,共同防止域名伪造、验证消息完整性并定义处理未认证邮件的策略。正确实施可显著减少冒充组织域名的钓鱼攻击。
Teams using implementing-dmarc-dkim-spf-email-security should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/implementing-dmarc-dkim-spf-email-security/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How implementing-dmarc-dkim-spf-email-security Compares
| Feature / Agent | implementing-dmarc-dkim-spf-email-security | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
SPF、DKIM 和 DMARC 是邮件认证的三大支柱,共同防止域名伪造、验证消息完整性并定义处理未认证邮件的策略。正确实施可显著减少冒充组织域名的钓鱼攻击。
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 实施 DMARC、DKIM 和 SPF 邮件安全 ## 概述 SPF、DKIM 和 DMARC 是邮件认证的三大支柱。三者共同防止域名伪造、验证消息完整性并定义处理未认证邮件的策略。正确实施可显著减少冒充组织域名的钓鱼攻击。 ## 前置条件 - 域名的 DNS 管理访问权限 - 邮件服务器/MTA 配置访问权限(Postfix、Exchange、Google Workspace、Microsoft 365) - 对 DNS TXT 记录的基本了解 - Python 3.8+ 用于验证脚本 ## 核心概念 ### SPF(发件人策略框架) 发布 DNS TXT 记录,列出被授权代表您的域名发送邮件的 IP 地址和邮件服务器。接收服务器根据此列表检查信封发件人的 IP。 ### DKIM(域名密钥识别邮件) 使用私钥向外发邮件添加加密签名。相应的公钥在 DNS 中发布。接收方验证签名以确保消息在传输过程中未被篡改。 ### DMARC(基于域名的消息认证、报告和一致性) 基于 SPF 和 DKIM 构建,为认证失败的消息指定策略(none/quarantine/reject),并提供监控伪造尝试的报告机制。 ## 实施步骤 ### 步骤一:审计当前状态 ```bash # 检查现有 SPF 记录 dig TXT example.com | grep spf # 检查现有 DKIM 选择器 dig TXT selector1._domainkey.example.com # 检查现有 DMARC 记录 dig TXT _dmarc.example.com ``` ### 步骤二:实施 SPF ``` # example.com 的 DNS TXT 记录 v=spf1 ip4:203.0.113.0/24 include:_spf.google.com include:spf.protection.outlook.com -all ``` 关键 SPF 机制: - `ip4:` / `ip6:` — 授权特定 IP 范围 - `include:` — 包含另一个域的 SPF 记录 - `a` — 授权域名的 A 记录 IP - `mx` — 授权域名的 MX 记录 IP - `-all` — 硬拒绝其他所有(推荐) - `~all` — 软拒绝(监控阶段) ### 步骤三:实施 DKIM ```bash # 生成 DKIM 密钥对(2048 位 RSA) openssl genrsa -out dkim_private.pem 2048 openssl rsa -in dkim_private.pem -pubout -out dkim_public.pem # 格式化公钥用于 DNS(删除头部,合并行) grep -v "PUBLIC KEY" dkim_public.pem | tr -d '\n' ``` `selector1._domainkey.example.com` 的 DNS TXT 记录: ``` v=DKIM1; k=rsa; p=MIIBIjANBgkqhki... ``` ### 步骤四:实施 DMARC ``` # _dmarc.example.com 的 DNS TXT 记录 # 阶段 1(监控): v=DMARC1; p=none; rua=mailto:dmarc-aggregate@example.com; ruf=mailto:dmarc-forensic@example.com; pct=100 # 阶段 2(隔离): v=DMARC1; p=quarantine; rua=mailto:dmarc-aggregate@example.com; pct=25 # 阶段 3(拒绝): v=DMARC1; p=reject; rua=mailto:dmarc-aggregate@example.com; pct=100 ``` ### 步骤五:监控和分析 DMARC 报告 使用 `scripts/process.py` 解析 DMARC 聚合 XML 报告,识别认证失败、未授权发件人和伪造尝试。 ## 工具与资源 - **MXToolbox**: https://mxtoolbox.com/SuperTool.aspx - **DMARC Analyzer(dmarcian)**: https://dmarcian.com/ - **Google Postmaster Tools**: https://postmaster.google.com/ - **Valimail DMARC Monitor**: https://www.valimail.com/ - **DMARC Report Analyzer**: https://dmarc.postmarkapp.com/ ## 验证 - SPF 记录在 mxtoolbox.com 上通过验证 - DKIM 签名在测试邮件上得到验证 - DMARC 记录格式正确且已启用报告 - 测试邮件在收件人的 Authentication-Results 标头中通过所有三项检查
Related Skills
triaging-security-incident
使用 NIST SP 800-61r3 和 SANS PICERL 框架对安全事件进行初始分类,确定严重性、范围和所需响应行动。 按类型对事件分类,根据业务影响分配优先级,并路由到相应的响应团队。适用于事件分类、 安全告警分类、严重性评估、事件优先级排序或初始事件分析等请求场景。
triaging-security-incident-with-ir-playbook
使用结构化 IR Playbook 对安全事件进行分类和优先排序,确定严重性、分配响应团队并启动适当的响应程序。
triaging-security-alerts-in-splunk
在 Splunk Enterprise Security 中对安全告警进行分类,通过 SPL 查询和事件审查(Incident Review) 仪表板对重要事件进行严重性分类、调查、关联相关遥测并做出升级或关闭决策。 适用于 SOC 分析师需要处理关联搜索产生的告警队列、确定调查优先级, 或需要为交接给二/三级分析师记录分类决策时。
testing-websocket-api-security
测试 WebSocket API 实现中的安全漏洞,包括 WebSocket 升级时缺少身份认证、跨站 WebSocket 劫持(Cross-Site WebSocket Hijacking,CSWSH)、通过 WebSocket 消息进行的注入攻击、输入校验不足、通过消息泛洪实施拒绝服务,以及通过 WebSocket 帧造成的信息泄露。测试人员使用 Burp Suite 拦截 WebSocket 握手和消息,构造恶意 payload,并测试 WebSocket 通道上的授权绕过。适用于 WebSocket 安全测试、WS 渗透测试、CSWSH 攻击或实时 API 安全评估相关请求。
testing-jwt-token-security
在安全测试活动中,评估 JSON Web Token(JWT)实现中的密码学弱点、算法混淆攻击和授权绕过漏洞。
testing-for-email-header-injection
测试 Web 应用程序邮件功能中的 SMTP 头部注入漏洞,这些漏洞允许攻击者注入额外的邮件头部、修改收件人,并通过联系表单实施垃圾邮件中继。
testing-api-security-with-owasp-top-10
使用自动化和手工测试技术,针对 OWASP API 安全 Top 10 风险对 REST 和 GraphQL API 端点进行系统性评估。
performing-wireless-security-assessment-with-kismet
使用 Kismet 通过被动射频监控进行无线网络安全评估,检测流氓接入点(Rogue AP)、隐藏 SSID、弱加密和未授权客户端。
performing-ssl-tls-security-assessment
使用 sslyze Python 库评估 SSL/TLS 服务器配置,评估加密套件、证书链、协议版本、HSTS 头部,以及 Heartbleed 和 ROBOT 等已知漏洞。
performing-soap-web-service-security-testing
通过分析 WSDL 定义,测试 XML 注入(XML Injection)、XXE、WS-Security 绕过和 SOAPAction 欺骗,对 SOAP Web 服务执行安全测试。
performing-serverless-function-security-review
对 AWS Lambda、Azure Functions 和 GCP Cloud Functions 中的无服务器函数(Serverless Function)执行安全审查,识别过度宽松的执行角色(Execution Role)、不安全的环境变量、注入漏洞和缺失的运行时保护措施。
performing-scada-hmi-security-assessment
对 SCADA 人机界面(HMI, Human-Machine Interface)系统进行安全评估,识别基于 Web 的 HMI、瘦客户端配置、认证机制以及 HMI 与 PLC 之间通信信道中的漏洞,符合 IEC 62443 和 NIST SP 800-82 指南要求。