Configuration

我的 Postfix 安裝正在發送垃圾郵件;如何阻止它?

  • February 12, 2016

幾天以來,我的網路/郵件伺服器(centos 6.4)正在大量發送垃圾郵件,只有停止後綴服務才能結束它。

SMPT 設置為僅接受通過 ssl 和使用使用者名/密碼的連接。而且我已經更改了(疑似)受感染電子郵件帳戶的密碼。

電子郵件是通過 iRedMail 設置的。

任何有關辨識和阻止這種情況的幫助都非常受歡迎!

添加:一些日誌摘錄:

Mar 23 05:01:52 MyServer postfix/smtp[9494]: 4E81026038: to=<bet@magiccablepc.com>, relay=mail.suddenlinkmail.com[208.180.40.132]:25, delay=3, delays=0.07/0/2.4/0.5, dsn=2.0.0, status=sent (250 Message received: 20140323040153.YPML21660.txedge-vm03.suddenlink.net@MyServer.org)
Mar 23 05:02:01 MyServer postfix/smtp[9577]: 209BA26067: to=<gino.c@bigpond.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=14, delays=12/0/0/2, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as B654226078)
Mar 23 05:02:01 MyServer postfix/smtp[9495]: 8278726077: to=<harry@gunship.org>, relay=mx-biz.mail.am0.yahoodns.net[98.139.171.245]:25, delay=0.88, delays=0.25/0/0.47/0.14, dsn=4.7.1, status=deferred (host mx-biz.mail.am0.yahoodns.net[98.139.171.245] said: 421 4.7.1 [TS03] All messages from [IPADDRESS] will be permanently deferred; Retrying will NOT succeed. See http://postmaster.yahoo.com/421-ts03.html (in reply to MAIL FROM command))

無法送達報告的郵件頭:

Return-Path: <MAILER-DAEMON>
Delivered-To: info@fotografieluna.be
Received: from localhost (icantinternet.org [127.0.0.1]) 
       by icantinternet.org (Postfix) with ESMTP id 4669E25D9D 
       for <info@fotografieluna.be>; Mon, 24 Mar 2014 14:20:15 +0100 (CET)
X-Virus-Scanned: amavisd-new at icantinternet.org
X-Spam-Flag: YES
X-Spam-Score: 9.501
X-Spam-Level: *********
X-Spam-Status: Yes, score=9.501 tagged_above=2 required=6.2 
       tests=[BAYES_99=3.5, BAYES_999=0.2, RAZOR2_CF_RANGE_51_100=0.5, 
       RAZOR2_CF_RANGE_E8_51_100=1.886, RAZOR2_CHECK=0.922, RDNS_NONE=0.793,  
       URIBL_BLACK=1.7] autolearn=no
Received: from icantinternet.org ([127.0.0.1]) 
       by localhost (icantinternet.org [127.0.0.1]) (amavisd-new, port 10024) 
       with ESMTP id FOrkYnmugXGk for <info@fotografieluna.be>; 
       Mon, 24 Mar 2014 14:20:13 +0100 (CET)
Received: from spamfilter2.webreus.nl (unknown [46.235.46.231]) 
       by icantinternet.org (Postfix) with ESMTP id D15BA25D14 
       for <info@fotografieluna.be>; Mon, 24 Mar 2014 14:20:12 +0100 (CET)
Received: from spamfilter2.webreus.nl (localhost [127.0.0.1])  
       by spamfilter2.webreus.nl (Postfix) with ESMTP id 7FB2EE78EFF 
       for <info@fotografieluna.be>; Mon, 24 Mar 2014 14:20:13 +0100 (CET)
X-Virus-Scanned: by SpamTitan at webreus.nl
Received: from mx-in-2.webreus.nl (mx-in-2.webreus.nl [46.235.44.240]) 
       by spamfilter2.webreus.nl (Postfix) with ESMTP id 3D793E78E5A 
       for <info@fotografieluna.be>; Mon, 24 Mar 2014 14:20:09 +0100 (CET)
Received-SPF: None (mx-in-2.webreus.nl: no sender authenticity 
 information available from domain of 
 MAILER-DAEMON@athosian.udag.de) identity=pra; 
 client-ip=62.146.106.25; receiver=mx-in-2.webreus.nl; 
 envelope-from=""; x-sender="MAILER-DAEMON@athosian.udag.de"; 
 x-conformance=sidf_compatible
Received-SPF: None (mx-in-2.webreus.nl: no sender authenticity 
 information available from domain of 
 postmaster@athosian.udag.de) identity=mailfrom; 
 client-ip=62.146.106.25; receiver=mx-in-2.webreus.nl; 
 envelope-from=""; x-sender="postmaster@athosian.udag.de"; 
 x-conformance=sidf_compatible
Received-SPF: None (mx-in-2.webreus.nl: no sender authenticity 
 information available from domain of 
 postmaster@athosian.udag.de) identity=helo; 
 client-ip=62.146.106.25; receiver=mx-in-2.webreus.nl; 
 envelope-from=""; x-sender="postmaster@athosian.udag.de"; 
 x-conformance=sidf_compatible
Received: from athosian.udag.de ([62.146.106.25]) 
 by mx-in-2.webreus.nl with ESMTP; 24 Mar 2014 14:20:03 +0100
Received: by athosian.udag.de (Postfix) 
       id 3B16E54807C; Mon, 24 Mar 2014 14:19:59 +0100 (CET)
Date: Mon, 24 Mar 2014 14:19:59 +0100 (CET)
From: MAILER-DAEMON@athosian.udag.de (Mail Delivery System)
Subject: ***Spam*** Undelivered Mail Returned to Sender
To: info@fotografieluna.be
Auto-Submitted: auto-replied
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;  
       boundary="36D9C5488E5.1395667199/athosian.udag.de"
Content-Transfer-Encoding: 7bit
Message-Id: <20140324131959.3B16E54807C@athosian.udag.de>

Pravin 提供了一些很好的一般性觀點,但沒有真正詳細說明其中任何一個,也沒有解決您可能遇到的實際問題。

首先,您需要了解 postfix 是如何接收這些消息的,以及為什麼選擇中繼它們(這兩個問題很可能相關)。

最好的方法是查看任何一條消息的消息 ID,然後在mail.log文件中查找有關它的所有日誌條目。這至少會告訴你消息從哪裡來以及 postfix 對它做了什麼,直到它離開它的關心並進入這個世界。這是一個(編輯的)範例摘錄:

Mar 26 00:51:13 vigil postfix/smtpd[9120]: 3B7085E038D: client=foo.bar.com[1.2.3.4]
Mar 26 00:51:13 vigil postfix/cleanup[9159]: 3B7085E038D: message-id=<------------@someserver>
Mar 26 00:51:13 vigil postfix/qmgr[5366]: 3B7085E038D: from=<foo@bar.com>, size=456346, nrcpt=2 (queue active)
Mar 26 00:51:13 vigil postfix/lmtp[9160]: 3B7085E038D: to=<fred@someplace.else>, relay=127.0.0.1[127.0.0.1]:10024, delay=0.3, delays=0.11/0/0/0.19, dsn=2.0.0, status=sent (250 2.0.0 Ok, id=04611-19, from MTA([127.0.0.1]:10025): 250 2.0.0 Ok: queued as 6EA115E038F)
Mar 26 00:51:13 vigil postfix/qmgr[5366]: 3B7085E038D: removed

這告訴我以下事情:

  1. 消息來自 foo.bar.com,一個 IP 地址為 1.2.3.4 的伺服器自稱為 foo.bar.com
  2. (由缺少警告暗示)根據正向和反向 DNS,該地址確實與該名稱匹配。
  3. 該消息是針對名為 的使用者fred@someplace.else,伺服器認為該使用者是可接受的目標地址。
  4. 根據其配置,郵件伺服器通過127.0.0.1:10024(我們的垃圾郵件/病毒過濾器)轉發郵件以進行進一步處理。
  5. 過濾器說“好的,我將把它作為 ID 為 6EA115E038F 的消息排隊並從這里處理。”
  6. 收到此確認後,主伺服器宣布它已完成並從隊列中刪除原始消息。

現在,一旦您知道消息是如何進入系統的,您就可以開始找出問題所在。

  • 如果它來自其他地方並完全中繼到其他地方,則 postfix 目前正在充當開放中繼。這是非常非常糟糕的,你應該收緊你的smtpd_recipient_restrictionssmtpd_client_restrictions設置/etc/postfix/main.cf
  • 如果它來自localhost,則很可能一個虛擬主機使用者或另一個使用者已被按需發送垃圾郵件的 php 腳本所破壞。使用該find命令查找最近添加或更改的 .php 文件,然後仔細查看任何可疑名稱。

任何更具體的事情都將過多地取決於上述調查的結果,因此嘗試詳細說明是沒有意義的。我會給你一個更一般的警告,至少要儘早安裝和配置postgrey 。

引用自:https://unix.stackexchange.com/questions/121517