Postfix: header_checks

Posted In: , . By taladnam

งานเข้า

Postfix mail server โดน spam เข้ามาเป็นระยะๆ จากหลากหลาย ip address ทั่วโลก โดยพฤติกรรมคือ ใช้ sender (From:) กับ recipient (To:) เป็น email address เดียวกัน ซึ่งตรวจสอบแล้วว่า ในการใช้งานตามปกติจะไม่มีพฤติกรรมแบบนี้เลย ... ดังนั้นในฐานะผู้ดูแลระบบ เป็นหน้าที่และความรับผิดชอบที่จำเป็นต้องจัดการ

...


ร่องรอย

source ip address ส่วนใหญ่เป็น dynamic (pool) ip address จากแทบทุกประเทศ"

...


ทำ #1

เพิ่ม reject_rbl_client ใน smtpd_recipient_restrictions

smtpd_recipient_restrictions = permit_mynetworks,
reject_unauth_destination,
reject_unknown_recipient_domain,
reject_non_fqdn_hostname,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_rbl_client b.barracudacentral.org,
reject_rbl_client bl.spamcop.net,
reject_rbl_client dnsbl.sorbs.net,
reject_rbl_client dsn.rfc-ignorant.org,
reject_rbl_client dul.dnsbl.sorbs.net,
reject_rbl_client list.dsbl.org,
reject_rbl_client sbl-xbl.spamhaus.org,
permit

...


ทำ #2

หลังจากทำ #1 ปรากฏว่า ปริมาณ spam ลดลงไปได้เยอะทีเดียว แต่ไม่หมดครับ เนื่องจาก source ip address เยอะมากๆ มีบางส่วน ไม่ได้ติดอยู่ใน RBL ยังคงส่ง spam มาได้อย่างต่อเนื่อง

เลือกใช้ header_checks เข้ามาช่วย โดยทำตามขั้นตอนดังนี้

1. กำหนด pattern ในไฟล์ /etc/postfix/header_checks

/From.*\@victim\.co\.th.*To.*\@victim\.co\.th.*/i DISCARD [***Spoofed-SPAM ***]


2. เพิ่ม configuration ใน /etc/postfix/main.cf

header_checks = pcre:/etc/postfix/header_checks


3. สั่ง postfix reload แล้วลองตรวจสอบดูจาก /var/log/mail.log โดย grep "discard:" หรือ text ที่กำหนด


mail:~# tail -f /var/log/mail.log |grep Spoofed-SPAM

Jul 16 08:02:02 mail postfix/cleanup[7694]: 86A5442537: discard: header
From: "Aubrey Uwuxohax" <b3a6aa47@victim.co.th> from
unknown[186.104.14.199]; from=<b3a6aa47@victim.co.th>
to=<b3a6aa47@victim.co.th> proto=ESMTP
helo=<196-207-22-190.adsl.terra.cl>: [*** Spoofed-SPAM ***]

Jul 16 08:03:56 mail postfix/cleanup[7694]: F18C6422FD: discard: header
From: "Viki Qljdisjz" <cailand@victim.co.th> from
pc-151-174-214-201.cm.vtr.net[201.214.174.151];
from=<cailand@victim.co.th> to=<cailand@victim.co.th>
proto=ESMTP helo=<pc-151-174-214-201.cm.vtr.net>: [*** Spoofed-SPAM ***]



คาดว่าน่าจะช่วยลด spam จากพฤติกรรมดังกล่าวได้เกือบทั้งหมด

สิ่งที่สำคัญเลย คือ การเขียน pattern ให้ match กับพฤติการการ spam นั่นแหละครับ

ป.ล. แต่ pattern ตามตัวอย่างในขั้นตอนที่ 1 นั้น ตรวจจับแค่ว่า sender และ recipient อยู่ภายใต้ domain เดียวกันเท่านั้น ยังไม่ได้ตรวจสอบถึงขนาดที่เป็น username เดียวกันด้วย (ใครมี pattern ดังกล่าว แนะนำด้วยนะครับ)

...


อ้างอิง

 

ถ้าธุรกิจของคุณมีการส่งอีเมลให้กับ Subscriber List จำนวนมากๆ โดยเฉพาะส่งไปหา Microsoft Services เช่น hotmail.com, msn.com, live.com

ขอแนะนำให้คุณสมัครเป็น Partner กับ Junk E-Mail Reporting Program ซึ่งเป็นบริการฟรี ที่จะคอยแจ้งเตือนคุณว่า มี user ของ Microsoft ใครบ้าง ซึ่งไม่ต้องการรับอีเมลจากคุณ เพื่อว่าคุณจะได้ทำการ update Subscriber List ให้สะอาดสอ้านอยู่เสมอ เลือกส่งอีเมลถึงเฉพาะคนที่ต้องการเท่านั้น


The Junk E-Mail Reporting Program (JMRP) is a free program intended to help large senders remove unwanted recipients from their e-mail lists. The goal of this program is to clean-up distribution lists so that users receive wanted e-mail and senders aren’t negatively affected by complaints.

Senders that sign up for this program will receive any e-mail that is reported as junk e-mail. Our hope is that senders will use this service to change their e-mailing practices to reduce junk e-mail reports and remove recipients who do not welcome such contact from their e-mailing list. Failure to reduce junk e-mail reporting incidents will result in a sender's removal from the program and could also impact a sender’s deliverability.

Below is a questionnaire for companies/clients interested in this program.

1. Your company name, the primary contact and a contact e-mail
2. Does your company follow standard CAN-SPAM Act practices?
3. The opt-out link for each list. Please include a functional link that we can use for a one time test. If you require users to have an account, please provide an account that we can access and close for the purpose of testing.
4. The home page where people sign up for each list
5. Sender IPs for verification
6. Is the IP address registered under your company's name/domain name? Or do you have exclusive sending rights from the IP via your hosting company (not shared with any other senders)? Please provide supporting documentation.
7. Can you remove recipients that complain from these lists?
If the answers to items 6 & 7 are "no", Microsoft will be unable to enroll your company at this time.

If you are interested in participating, please complete the questionnaire and send your responses to: http://support.msn.com/ . While we do try to accommodate requests, we cannot guarantee enrollment into the program.