web-dev-qa-db-ja.com

X-PHP-Originating-ScriptヘッダーのないPostfixでの送信スパム

いつものように奇妙だと思う本物のメールアドレスを使用して、サーバーから多くのスパムが送信されます。偽のアドレスがランダムに使用されています。また、私は通常、これらの電子メールにX-PHP-Originating-Scriptヘッダーを見つけますが、この場合はありません。 X-Mailerの値は常に同じであるとは限りません。これが私が今日しようとしたことです:

  • Linux Malware Detect、ClamScan、ISPP Scan、Rkhunterをシステム全体で複数回実行しましたが、ネガティブでした。
  • メールのパスワード、データベースのrootパスワード、ISPConfigの管理者パスワードを変更せずに変更しました
  • Fail2banも実行されており、これらの電子メール送信に関連付けられたIPを検出して禁止しているようですが、ログを見ると、「すでに禁止されている」IPについての言及がたくさんあるため、100%確信が持てません。正常に動作しています。ポート25で「netstat」ウォッチングを実行しているときに同じIPが表示されることがあるので、これと関係があると思いますが、どうすればよいかわかりません。

私のシステムに関する情報:Debian 6、ISPConfig 3、PHP/MySQLホスティングサーバー。 Postfix + ClamAV + Amavis

スパム電子メールヘッダーのサンプル:

        regular_text: Received: from MYHOST (localhost.localdomain [127.0.0.1])
        regular_text:   by MYHOST (Postfix) with ESMTP id 68BBA2016422;
        regular_text:   Thu, 23 Nov 2017 14:59:41 -0500 (EST)
        regular_text: Received: from 62.112.5.169 (unknown [175.223.31.212])
        regular_text:   by MYHOST (Postfix) with ESMTP id 9F04D2016473;
        regular_text:   Thu, 23 Nov 2017 14:59:00 -0500 (EST)
        regular_text: From: Paypal Update Center <[email protected]>
        regular_text: Subject: Regarding your information
        regular_text: MIME-Version: 1.0
        regular_text: X-Priority: 3
        regular_text: X-MSMail-Priority: Normal
        regular_text: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.6429
        regular_text: X-Mailer: Microsoft Outlook Express 6.00.2600.6429
        regular_text: Message-ID: <[email protected]>
        regular_text: Content-Type: multipart/mixed; boundary="_NextPart_000_0077_87BE7816.3B325A4E"
        regular_text: Date: Thu, 23 Nov 2017 14:59:00 -0500 (EST)

postconf -n:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
always_add_missing_headers = yes
always_bcc = mailarchive@localhost
append_dot_mydomain = no
biff = no
body_checks = regexp:/etc/postfix/body_checks
broken_sasl_auth_clients = yes
config_directory = /etc/postfix
content_filter = scan:[127.0.0.1]:10025
disable_vrfy_command = yes
dovecot_destination_recipient_limit = 1
header_checks = regexp:/etc/postfix/header_checks
html_directory = /usr/share/doc/postfix/html
inet_interfaces = all
mailbox_size_limit = 0
maildrop_destination_concurrency_limit = 1
maildrop_destination_recipient_limit = 1
message_size_limit = 0
mime_header_checks = regexp:/etc/postfix/mime_header_checks
mydestination = ks4000003.ip-198-245-60.net, localhost, localhost.localdomain
myhostname = ks4000003.ip-198-245-60.net
mynetworks = 127.0.0.0/8 [::1]/128
myorigin = /etc/mailname
nested_header_checks = regexp:/etc/postfix/nested_header_checks
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps
readme_directory = /usr/share/doc/postfix
receive_override_options = no_address_mappings
recipient_delimiter = +
relay_domains = mysql:/etc/postfix/mysql-virtual_relaydomains.cf
relay_recipient_maps = mysql:/etc/postfix/mysql-virtual_relayrecipientmaps.cf
relayhost =
smtp_destination_concurrency_limit = 5
smtp_destination_rate_delay = 1s
smtp_extra_recipient_limit = 20
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_client_restrictions = permit_mynetworks, permit_sasl_authenticated, check_client_access mysql:/etc/postfix/mysql-virtual_client.cf
smtpd_data_restrictions = reject_unauth_pipelining
smtpd_delay_reject = no
smtpd_error_sleep_time = 0
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_client_access hash:/etc/postfix/rbl_whitelist, check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf, check_sender_access regexp:/etc/postfix/sender_access.regexp hash:/etc/postfix/sender_access mysql:/etc/postfix/mysql-virtual_sender.cf, reject_unknown_recipient_domain, reject_unauth_destination, reject_unauth_destination, reject_unlisted_recipient, reject_invalid_hostname, reject_non_fqdn_sender, reject_rbl_client cbl.abuseat.org, reject_rbl_client bl.spamcop.net, reject_rbl_client sbl.spamhaus.org, reject_rbl_client truncate.gbudb.net, permit
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sender_restrictions = check_client_access cidr:/etc/postfix/internal_clients_filter, permit_sasl_authenticated, permit_mynetworks, reject_non_fqdn_sender, reject_unknown_sender_domain, reject_unauth_destination
smtpd_tls_cert_file = /etc/postfix/smtpd.cert
smtpd_tls_key_file = /etc/postfix/smtpd.key
smtpd_tls_loglevel = 1
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
transport_maps = proxy:mysql:/etc/postfix/mysql-virtual_transports.cf, hash:/etc/postfix/transport
unknown_local_recipient_reject_code = 550
virtual_alias_domains =
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, mysql:/etc/postfix/mysql-virtual_email2email.cf
virtual_gid_maps = static:5000
virtual_mailbox_base = /var/vmail
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
virtual_transport = dovecot
virtual_uid_maps = static:5000

PostfixをシャットダウンしてApacheログを見ると、次のようなことがわかります。

[Tue Nov 28 08:06:23 2017] [error] [client 168.1.128.35] Directory index forbidden by Options directive: /var/www/apps/
[Tue Nov 28 08:56:30 2017] [error] [client 66.249.64.210] File does not exist: /var/www/robots.txt
[Tue Nov 28 09:06:10 2017] [error] [client 169.53.184.5] Directory index forbidden by Options directive: /var/www/apps/
[Tue Nov 28 09:11:25 2017] [error] [client 66.249.64.31] File does not exist: /var/www/robots.txt
[Tue Nov 28 09:11:25 2017] [error] [client 66.249.64.4] File does not exist: /var/www/.well-known
[Tue Nov 28 09:44:14 2017] [error] [client 66.249.64.26] File does not exist: /var/www/robots.txt
[Tue Nov 28 09:44:14 2017] [error] [client 66.249.64.26] File does not exist: /var/www/.well-known
[Tue Nov 28 09:45:13 2017] [error] [client 66.249.64.26] File does not exist: /var/www/.well-known
[Tue Nov 28 09:52:50 2017] [error] [client 172.104.115.143] File does not exist: /var/www/favicon.ico
[Tue Nov 28 10:00:13 2017] [error] [client 212.83.150.38] File does not exist: /var/www/a2billing
[Tue Nov 28 10:01:25 2017] [error] [client 212.83.150.38] File does not exist: /var/www/a2billing
[Tue Nov 28 10:07:28 2017] [error] [client 139.162.87.250] Directory index forbidden by Options directive: /var/www/apps/

ランダムなIPが/ var/www/appsなどにアクセスしようとしているのは奇妙だと思います。これらは、通常は到達可能なディレクトリではないためです。

そして、これは疑わしいスクリプトがスパムを送信するために使用する経路の例です:

Nov 30 09:44:10 ks4000003 postfix/smtpd[5035]: warning: hostname 201-46-61-66.wireless.dynamic.sbr1.ce.faster.net.br does not resolve to address 201.46.61.66: Name or service not known
Nov 30 09:44:10 ks4000003 postfix/smtpd[5035]: connect from unknown[201.46.61.66]
Nov 30 09:44:14 ks4000003 postfix/smtpd[5035]: Anonymous TLS connection established from unknown[201.46.61.66]: TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)
Nov 30 09:44:18 ks4000003 postfix/smtpd[5035]: warning: unknown[201.46.61.66]: SASL LOGIN authentication failed: UGFzc3dvcmQ6
Nov 30 09:44:20 ks4000003 postfix/smtpd[5035]: warning: unknown[201.46.61.66]: SASL PLAIN authentication failed: 
Nov 30 09:44:21 ks4000003 postfix/smtpd[5035]: NOQUEUE: reject: RCPT from unknown[201.46.61.66]: 554 5.7.1 <[email protected]>: Recipient address rejected: Access denied; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<[201.46.61.66]>
Nov 30 09:44:21 ks4000003 postfix/smtpd[5035]: disconnect from unknown[201.46.61.66]

私はこれについてかなり必死になっているので、どんな助けでもありがたいです。これについて私ができる簡単なことがあるに違いありません。

2
guylabbe.ca

私は通常、これらの電子メールにX-PHP-Originating-Scriptヘッダーを見つけます

これは、メールが脆弱なPHPスクリプトから送信された場合、以前のように発生します。ただし、このメールはサーバーから発信されたものではなく、サーバーをリレー。

Received: from 62.112.5.169 (unknown [175.223.31.212])
 by MYHOST (Postfix) with ESMTP id 9F04D2016473;
 Thu, 23 Nov 2017 14:59:00 -0500 (EST)

ここで、62.112.5.169は難読化されたHELOホスト名であり、メールは実際にはKoreaTelecomに属する175.223.28.0/22から送信されます。

たとえば、check_client_accessはいくつかのソースと形式(正規表現、BerkeleyDB、さらにはMySQL)からデータを収集するため、構成から実際にどのような制限があるかを判断するのは非常に困難です。あなたは例えばこれらのクライアントからのメールを実際に許可する緩い正規表現があります事実上メールサーバーをオープンリレーにします

まず、構成から最も複雑なソースを削除します。次に、postmap -qを使用してそれらをすべて個別にテストし、実際に実行していると思われることを実行していることを確認します。

2
Esa Jokinen

Smtpd_client_restrictionsのデフォルトはpermitです。

http://www.postfix.org/postconf.5.html#smtpd_client_restrictions

smtpd_client_restrictions行の最後にrejectを追加して、ポリシーを明示的にします。

smtpd_client_restrictions = permit_mynetworks, permit_sasl_authenticated, check_client_access mysql:/etc/postfix/mysql-virtual_client.cf, reject

@Esa Jokinenは、MySQL構成がアクセスを許可している可能性があることを正しく指摘しています。SASL認証されておらず、mynetworksにないクライアントをホワイトリストに登録していない場合は、そのcheck_client_accessパラメーターを削除するだけです。

1
quadruplebucky