Skip to content
KitploitKITPLOIT
工具漏洞利用博客
Log in
提交
工具漏洞利用博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

订阅源联系隐私© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
decode-spam-headers — 一个脚本,帮助你理解为什么你的电子邮件最终进入了垃圾邮件文件夹。 | Kitploit
工具/GitHubGitHub/mgeeky/decode-spam-headers
钓鱼工具信息收集红队电子邮件安全日志分析
GitHubmgeeky/decode-spam-headers

decode-spam-headers

一个脚本,帮助你理解为什么你的电子邮件最终进入了垃圾邮件文件夹。

查看仓库
69898428个月前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

decode-spam-headers.py

无论你是想在日常管理工作中弄清楚某封特定电子邮件为何会进入垃圾邮件/垃圾邮件文件夹,还是为了红队钓鱼模拟的目的,这个脚本都能帮到你!

这个想法产生于一次针对配备 MS Defender for Office365 的 MS Office365 E5 环境开展商业钓鱼模拟演练的过程中。可以想象,从钓鱼模拟的角度来看,这是一个相当棘手的安全技术栈。

在手动翻阅所有这些 Office365 SMTP 邮件头并试图从中挑选出 SCL 值之后,是时候编写一个像样的 SMTP 邮件头解析器了。

时光荏苒,我不断为越来越多的 SMTP 邮件头添加支持——于是就有了它。这个工具现在已能理解几十种不同的邮件头。

Info

该工具接受一个包含所有 SMTP 邮件头的 *.EML 或 *.txt 文件作为输入。然后,它会提取一组值得关注的邮件头,并使用 105+ 项测试尽可能地对它们进行解码。

该脚本还会提取所有 IPv4 地址和域名,并对它们执行完整的 DNS 解析。

输出结果将包含关于这封电子邮件为何可能被阻止的有用信息。

为了在将钓鱼 HTML 代码发送给客户之前对其进行润色,你可能还想把它输入到我的 phishing-HTML-linter.py 中。它能相当出色地发现 HTML 中会让你的电子邮件获得更高垃圾邮件评分的_坏味道_。

Example Screenshots

  • MTA 服务器链(已出色解析的 Received 邮件头):

1.png

  • 根据公开文档尽可能多地解码各种邮件头(此处为 Office365 ForeFront 垃圾邮件报告):

2.png

  • 实现了不同的自定义启发式方法,以主动验证并寻找垃圾邮件分类线索,这里是检测_域仿冒_的逻辑:

3.png

  • 该脚本尝试对部分 Office365 反垃圾邮件规则进行逆向工程并加以记录,同时还收集关于其他不透明反垃圾邮件邮件头的公开知识:

4.png

  • 报告可以生成美观的 HTML(用法:py decode-spam-headers.py headers.txt -f html -o report.html ):

5.png

Processed headers

已处理的邮件头(解析了超过 85+ 个邮件头):

  • X-forefront-antispam-report
  • X-exchange-antispam
  • X-exchange-antispam-mailbox-delivery
  • X-exchange-antispam-message-info
  • X-microsoft-antispam-report-cfa-test
  • Received
  • From
  • To
  • Subject
  • Thread-topic
  • Received-spf
  • X-mailer
  • X-originating-ip
  • User-agent
  • X-forefront-antispam-report
  • X-microsoft-antispam-mailbox-delivery
  • X-microsoft-antispam
  • X-exchange-antispam-report-cfa-test
  • X-spam-status
  • X-spam-level
  • X-spam-flag
  • X-spam-report
  • X-vr-spamcause
  • X-ovh-spam-reason
  • X-vr-spamscore
  • X-virus-scanned
  • X-spam-checker-version
  • X-ironport-av
  • X-ironport-anti-spam-filtered
  • X-ironport-anti-spam-result
  • X-mimecast-spam-score
  • Spamdiagnosticmetadata
  • X-ms-exchange-atpmessageproperties
  • X-msfbl
  • X-ms-exchange-transport-endtoendlatency
  • X-ms-oob-tlc-oobclassifiers
  • X-ip-spam-verdict
  • X-amp-result
  • X-ironport-remoteip
  • X-ironport-reputation
  • X-sbrs
  • X-ironport-sendergroup
  • X-policy
  • X-ironport-mailflowpolicy
  • X-remote-ip
  • X-sea-spam
  • X-fireeye
  • X-antiabuse
  • X-tmase-version
  • X-tm-as-product-ver
  • X-tm-as-result
  • X-imss-scan-details
  • X-tm-as-user-approved-sender
  • X-tm-as-user-blocked-sender
  • X-tmase-result
  • X-tmase-snap-result
  • X-imss-dkim-white-list
  • X-tm-as-result-xfilter
  • X-tm-as-smtp
  • X-scanned-by
  • X-mimecast-spam-signature
  • X-mimecast-bulk-signature
  • X-sender-ip
  • X-forefront-antispam-report-untrusted
  • X-microsoft-antispam-untrusted
  • X-sophos-senderhistory
  • X-sophos-rescan
  • X-MS-Exchange-CrossTenant-Id
  • X-OriginatorOrg
  • IronPort-Data
  • IronPort-HdrOrdr
  • X-DKIM
  • DKIM-Filter
  • X-SpamExperts-Class
  • X-SpamExperts-Evidence
  • X-Recommended-Action
  • X-AppInfo
  • X-Spam
  • X-TM-AS-MatchedID
  • X-MS-Exchange-EnableFirstContactSafetyTip
  • X-MS-Exchange-Organization-BypassFocusedInbox
  • X-MS-Exchange-SkipListedInternetSender
  • X-MS-Exchange-ExternalOriginalInternetSender
  • X-CNFS-Analysis
  • X-Authenticated-Sender
  • X-Apparently-From
  • X-Env-Sender
  • Sender

这些邮件头大多没有完整的文档,因此该脚本无法确切指出所有细节,但至少它收集了所有我能找到的相关信息。

Reverse-Engineering efforts

我正在投入大量精力去发现并理解各种 Office365 ForeFront 反垃圾邮件规则(SFS、ENG),尽管这些规则并未公开记录。```

(5) Test: X-Forefront-Antispam-Report

HEADER: X-Forefront-Antispam-Report

VALUE: CIP:209.85.167.100;CTRY:US;LANG:de;SCL:5;SRV:;IPV:NLI;SFV:SPM;H:mail-lf1-f100.google.com;PTR:mail-l f1-f100.google.com;CAT:DIMP;SFTY:9.19;SFS:(4636009)(956004)(166002)(6916009)(356005)(336012)(19 625305002)(22186003)(5660300002)(4744005)(6666004)(35100500006)(82960400001)(26005)(7596003)(7636003)(554460 02)(224303003)(1096003)(58800400005)(86362001)(9686003)(43540500002);DIR:INB;SFTY:9.19;

[...]

    - Message matched 24 Anti-Spam rules (SFS):           <============ opaque anti-spam rules
            - (1096003)
            - (166002)
            - (19625305002)
            - (22186003)
            - (224303003)
            - (26005)
            - (336012)
            - (356005)
            - (35100500006)         - (SPAM) Message contained embedded image.
该过程完全手动,通过向 Office365 邮件服务器发送特制邮件,然后手动审查并关联收集到的规则。

目前已发送了 60 多封邮件,以下是我目前对 Microsoft 规则的了解:```py

    #
    # Below rules were collected solely in a trial-and-error manner or by scraping any 
    # pieces of information from all around the Internet.
    #
    # They do not represent the actual Anti-Spam rule name or context and surely represent 
    # something close to what is understood (or they may have totally different meaning).
    # 
    # Until we'll be able to review anti-spam rules documention, there is no viable mean to map
    # rule ID to its meaning.
    #

    Anti_Spam_Rules_ReverseEngineered = \
    {
        '35100500006' : logger.colored('(SPAM) Message contained embedded image.', 'red'),

        # https://docs.microsoft.com/en-us/answers/questions/416100/what-is-meanings-of-39x-microsoft-antispam-mailbox.html
        '520007050' : logger.colored('(SPAM) Moved message to Spam and created Email Rule to move messages from this particular sender to Junk.', 'red'),

        # triggered on an empty mail with subject being: "test123 - viagra"
        '162623004' : 'Subject line contained suspicious words (like Viagra).',

        # triggered on mail with subject "test123" and body being single word "viagra"
        '19618925003' : 'Mail body contained suspicious words (like Viagra).',

        # triggered on mail with empty body and subject "Click here"
        '28233001' : 'Subject line contained suspicious words luring action (ex. "Click here"). ',

        # triggered on a mail with test subject and 1500 words of http://nietzsche-ipsum.com/
        '30864003' : 'Mail body contained a lot of text (more than 10.000 characters).',

        # mails that had simple message such as "Hello world" triggered this rule, whereas mails with
        # more than 150 words did not.
        '564344004' : 'HTML mail body with less than 150 words of text (not sure how much less though)',

        # message was sent with a basic html and only one <u> tag in body.
        '67856001' : 'HTML mail body contained underline <u> tag.',

        # message with html,head,body and body containing simple text with no b/i/u formatting.
        '579124003' : 'HTML mail body contained text, but no text formatting (<b>, <i>, <u>) was present',

        # This is a strong signal. Mails without <a> doesnt have this rule.
        '166002' : 'HTML mail body contained URL <a> link.',

        # Message contained <a href="https://something.com/file.html?parameter=value" - GET parameter with value.
        '21615005' : 'Mail body contained <a> tag with URL containing GET parameter: ex. href="https://foo.bar/file?aaa=bbb"',
下载工具