-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc7023c
commit c948688
Showing
8 changed files
with
1,695 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,288 @@ | ||
smtp_wrapper-0.1 -- SMTP filtering support daemon | ||
Copyright (C) 2006 Masahiko Ito | ||
|
||
These programs is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
|
||
These programs is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with these programs; if not, write to the Free Software | ||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
|
||
Mail suggestions and bug reports for these programs to | ||
"Masahiko Ito" <[email protected]> | ||
|
||
History | ||
======= | ||
|
||
2005/11/25 Develop started | ||
2006/01/23 First release(0.1) | ||
|
||
What's this ? | ||
============= | ||
|
||
���spam�к��Ȥ���smtp server�ȼ����spam�����å�������ץȤ�Ϣ���� | ||
���뤿��Υǡ����ץ������Ǥ��� | ||
|
||
spam�к��Ȥ��Ƥϴ��ˤ����Ĥ�������Ū��ˡ����Ω���Ƥ��ޤ������饤���� | ||
��¦����Υ��ץ������Ȥ��Ƥϥ٥������������Ѥ����ե��륿�ץ������ + | ||
procmail���ȹ礻�Ǥ��ä��ꡢ������¦����Υ��ץ������Ȥ��Ƥ�MILTER�� | ||
������Ʊ�ͤΥե��륿 + sendmail���ȹ礻�Ǥ��ä��ꤹ��褦�Ǥ��� | ||
|
||
�٥������������Ѥ����ե��륿�ϼºݡ����˸��̤�����ޤ������������� | ||
�����̤��Ѥ߽ŤͤƹԤ������˥ǡ����١��������粽���Ƥ�����������ư�� | ||
���Ť��ʤä����褦�ʵ������ޤ�������ʤ��ꡢ�����־�ǰʲ��ξ���� | ||
���Ĥ��ޤ����� | ||
|
||
o �˻�Ψ99%�Υ��ѥ��к������θ������ | ||
(Selective SMTP Rejection (S25R)����) | ||
- http://www.gabacho-net.jp/anti-spam/ | ||
|
||
o spam | ||
- http://moin.qmail.jp/spam | ||
|
||
�嵭�Υڡ������Ƥ�ʬ�ʤ��������̡� | ||
|
||
o ��³��IP��DNS�εհ�����ʤ���е��� | ||
-> �հ�����ʤ�SMTP�����Ф���Υ���¿����spam�Ǥ��롣 | ||
o ��³��IP��DNS�εհ����(FQDN)����ưŪIP����䤵�����ϵ��� | ||
-> ưŪIP����ä�SMTP�����Ф���Υ���¿����spam�Ǥ��롣 | ||
o ��³����Ф��ơ����������³���ٱ䤵���� | ||
-> spam����������SMTP�����Ф�¿�������̤��Ĺ�®�˥���ۿ����뤳 | ||
�Ȥ������Ū�Ȥ��Ƥ��ꡢ�������ߤ������Ф��Ф��Ƥ�����ۿ��� | ||
�������³�����Ǥ��뷹����ͭ�롣 | ||
|
||
�Ȥ���3��ˡ�ΤߤǤ⡢���ʤ�⤤��Ω��spam���ӽ��Ǥ���ΤǤϤʤ����� | ||
�ͤ��ޤ����������⡢�嵭����ˡ�ϥ�����Ƥ��Τ�Τ�Ƚ�Ǥ��ʤ��Τǡ� | ||
�����å��ˤ�������٤����˷ڤ����Ȥ�ͽ�ۤ���ޤ��� | ||
|
||
�ǡ��ºݤˤɤΤ褦�˼������뤫�Ȥ������Ȥˤʤ�ȡ��嵭�Υڡ����Ǥ�MTA | ||
��qmail�Ǥ����������Ȥʤ�����������Ƥ��ơ�sendmail�Ȥ��ȹ礻�Ȥ� | ||
��ȼ��ϤǤʤ�Ȥ����ʤ���Фʤ�ʤ��褦�Ǥ��� | ||
|
||
����ˡ�ǹԤ��ʤ顢MILTER�����Ѥ����ե��륿���������٤��Ǥ��礦���� | ||
���餯�Ǥ�⤤�ѥե����ޥ�spam�����å��ʤ��Ƥ����Ȼפ��ޤ��� | ||
|
||
MILTER�����Ѥ���ˤ�libmilter�����Ѥ���C����ǥե��륿��������ޤ��� | ||
�ɥ�����Ȥ�sendmail�Υ������ǥ��쥯�ȥ����libmilter/docs/�ʲ��� | ||
ͭ��ޤ��Τǡ�����ͤ˺�Ȥ��ޤ�.....���������ʤ�������ˤ� | ||
MILTER�����ƥե��륿����Ȥ�����ޤ��Ȥ������ɥ����� | ||
�Ȥ��ɲ뵤�Ϥ�����ޤ���Ǥ���(^_^;���Ǥ��Τ��̤Υ��ץ������� | ||
�������뤳�Ȥˤ��ޤ����� | ||
|
||
��������������äưʲ�������α�դ��ޤ����� | ||
|
||
o �ե��륿�Ϥ�������Υ�����ץȸ���(sh, perl, ruby ...)�ǽ����� | ||
o �ɤ����ʤ�spam�����å��ʳ��ε�ǽ���ñ����������褦�ˤ��Ƥ��� | ||
������ | ||
o �ե��륿�ϡ֥ե��륿�פ��夦���餤�Ǥ�����ɸ�����Ϥ��ɤ�ǡ���� | ||
��ɸ����Ϥ˽��Ϥ�������ǵ�ǽ����褦�ˤ������� | ||
|
||
�Ȥꤢ�����֤��㤯���嵭��3����¸����뤿���smtp proxyŪ�ʥǡ���� | ||
���äƤߤޤ����� | ||
|
||
Install | ||
======= | ||
|
||
o cd /usr/local/ | ||
o tar xvzf smtp_wrapper-0.1.tar.gz | ||
o cd smtp_wrapper-0.1 | ||
o cc -o smtp_wrapper smtp_wrapper.c | ||
o vi filter_script | ||
o chmod +x filter_script | ||
o smtp_wrapper -h | ||
|
||
Usage : smtp_wrapper [-mh hostname] [-mp port] [-q backlog] | ||
[-sh smtpserver_hostname] [-sp smtpserver_port] | ||
[-t timeout_sec] [-d delay_sec] [-f filter] | ||
[-cm child_max] [-F] | ||
-mh hostname : my hostname [ANY] | ||
-mp port : my port [25] | ||
-q backlog : socket queue number [5] | ||
-sh smtpserver_hostname : real smtp hostname [localhost] | ||
-sp smtpserver_port : real smtp port [8025] | ||
-t timeout_sec : timeout second [no timeout] | ||
-d delay_sec : delay second for initial connection [0] | ||
-f filter : filter program | ||
[/usr/local/smtp_wrapper/smtp_filter] | ||
-cm child_max : max number of connection to real smtp daemon | ||
[10] | ||
-F : run in foreground | ||
|
||
sendmail������ | ||
============== | ||
|
||
o vi sendmail.mc | ||
�ʲ���������ɲ� | ||
DAEMON_OPTIONS(`Port=8025, Name=MTA')dnl | ||
o vi submit.mc | ||
�ʲ���������ɲ� | ||
DAEMON_OPTIONS(`Port=8025, Name=NoMTA, Addr=127.0.0.1, M=E')dnl | ||
o sendmail.cf, submit.cf�� | ||
|
||
sendmail.cf | ||
----------- | ||
O DaemonPortOptions=Port=8025, Name=MTA | ||
|
||
submit.cf | ||
--------- | ||
O DaemonPortOptions=Port=8025, Name=NoMTA, Addr=127.0.0.1, M=E | ||
|
||
��ư | ||
==== | ||
|
||
o vi /etc/rc.d/rc.local | ||
|
||
if [ -x /usr/local/smtp_wrapper-0.1/smtp_wrapper ] | ||
then | ||
/usr/local/smtp_wrapper-0.1/smtp_wrapper \ | ||
-t 600 \ | ||
-d 10 \ | ||
-f /usr/local/smtp_wrapper-0.1/filter_script | ||
echo ' smtp_wrapper' | ||
fi | ||
|
||
o reboot | ||
|
||
Figure | ||
====== | ||
|
||
+-----------------------------------------------------------+ | ||
| | | ||
| | | ||
+-----+ command +------------------+ command +----------------+ | | ||
| |--------->|(1) [2]|----------->| | | | ||
| MTA |SOCKET(25)| smtp_wrapper |SOCKET(8025)| MTA | | | ||
|(MUA)|<---------|[1] (2)|<-----------| (sendmail etc) | | | ||
| | response | | response +----------------+ | | ||
+-----+ | | (3) [3] | | | ||
| +------+----+------+ | | ||
| A P | | | ||
| | I | | | ||
| | P | | | ||
| | E | | | ||
| (stdout) | V (stdin) | | ||
| +--------+ | | ||
| | | | | ||
| | FILTER | | | ||
| | | | | ||
| +--------+ | | ||
| | | ||
| | | ||
+-----------------------------------------------------------+ | ||
|
||
o smtp_wrapper(��)�������MTA����ä�smtp(25)�ݡ��Ȥؤ���³��ƻ뤷�ޤ��� | ||
|
||
o ��³�������smtp_wrapper(��)�ϡ�`-d'���ץ����ǻ��ꤷ���ÿ�sleep���� | ||
��˻ҥץ�����(smtp_wrapper(��))�����������ʹߤ���³���Ȥ��̿���ҥץ� | ||
�����ˤޤ���������smtp(25)�ݡ��Ȥδƻ���֤��ޤ����ޤ�����³����� | ||
�������ǡ������߲�Ư���Ƥ���smtp_wrapper(��)�ο���`-mc'���ץ����ǻ� | ||
�ꤷ������ۤ��Ƥ����硢���ο���`-mc'���ץ����λ����ͤ�2ʬ��1̤�� | ||
�ˤʤ�ޤ�`-d'���ץ����ǻ��ꤷ���ÿ���sleep���֤��ޤ��� | ||
|
||
o smtp_wrapper(��)����³����IP���ɥ쥹��Ķ��ѿ�`SW_FROM_IP'�����ꤷ���� | ||
���ե��륿�ץ�������fork&exec���ޤ��� | ||
|
||
o smtp_wrapper(��)����³������Υ�å������Τ���`HELO|EHLO'��`MAIL FROM:'�� | ||
`RCPT TO:'����`DATA'���ޥ�ɤޤǤΥ�å������������MTA(��ޤǤϡ��Ԥ� | ||
�����ݡ��Ȥ�8025���ѹ�)�ȥե��륿�ץ��������Ϥ���MTA����α�����å��� | ||
������³�����Ϥ��ޤ������θ�`DATA'����`.'��ե��륿�ץ������Τߤ��� | ||
�����塢�ե��륿�ץ�����फ��α���(�����å����)���Ԥ��ޤ��� | ||
|
||
o �ե��륿�ץ������ϴĶ��ѿ�`SW_FROM_IP'��(ɬ�פǤ����)�����Ϥ��줿��� | ||
��������ʸ���������ʥ�å������������ʥ�å���������Ƚ�Ǥ��������ʥ�� | ||
��������Ƚ�Ǥ������ϼ����Ϥ��줿��å������Τ���`DATA<CR><LF>'���� | ||
`.<CR><LF>'�ޤǤ�ɸ����Ϥ˽��Ϥ����ޤ����ޤ�������å�������Ƚ�Ǥ��� | ||
����ľ���˽�λ���뤫��`DATA<CR><LF>'�ʳ��ǻϤޤ��å�������ɸ����� | ||
�˽��Ϥ����塢��λ�����ޤ��� | ||
|
||
o smtp_wrapper(��)�ϥե��륿�ץ�����फ��Υ�å�������`DATA<CR><LF>'�� | ||
�ϤޤäƤ�����硢����������ʥ�å������Ȥߤʤ��������MTA�˼����Ϥ��� | ||
�����ޤ���å�������`DATA<CR><LF>'�ʳ��ǻϤޤäƤ�����硢����������� | ||
��å�����(spam)�Ȥߤʤ�����³����`450'�ǻϤޤ������顼�������֤��ޤ��� | ||
|
||
o �ʹߡ�smtp_wrapper(��)����³������`QUIT<CR><LF>'��������ޤǡ��ޤ��� | ||
��³��<->smtp_wrapper(��)�֤Υ��ͥ���������Ǥ����ޤǡ��ޤ��� | ||
smtp_wrapper(��)<->�����MTA�֤Υ��ͥ���������Ǥ����ޤǾ嵭��ư�� | ||
���֤��ޤ��� | ||
|
||
Command sequence | ||
================ | ||
|
||
stat|command/response|in |out |stat|comment | ||
-----+----------------+---------+---------+----+------------------------- | ||
1 |QUIT |(1) | [2] |8 | | ||
| | | | | | ||
1 |HELO |(1) | [2][3]|1 | | ||
1 |RES(HELO) | (2) |[1] |1 | | ||
1 |MAIL FROM: |(1) | [2][3]|1 | | ||
1 |RES(MAIL FROM:) | (2) |[1] |1 | | ||
1 |RCPT TO: |(1) | [2][3]|1 | | ||
1 |RES(RCPT TO:) | (2) |[1] |1 | | ||
| | | | | | ||
1 |DATA |(1) | [3]|2 | | ||
2 |FAKERES(DATA) | |[1] |3 |354 fake ack | ||
| | | | | | ||
3 |MESSAGES |(1) | [3]|3 | | ||
[3 |ANYDATA | (3)|[1] |1 |450 temporary error] | ||
| | | | | | ||
3 |. |(1) | [3]|4 | | ||
| | | | | | ||
4 |DATA | (3)| [2] |5 | | ||
[4 |!DATA | (3)|[1] |1 |450 temporary error] | ||
| | | | | | ||
5 |RES(DATA) | (2) |---------|6 |no response | ||
| | | | |(already responsed 354) | ||
[5 |RES(DATA) | (2) |[1] |1 |!354 then 450 temporary | ||
| | | | |error for .] | ||
| | | | | | ||
6 |MESSAGES | (3)| [2] |6 | | ||
6 |. | (3)| [2] |7 | | ||
7 |RES(.) | (2) |[1] |1 | | ||
| | | | | | ||
8 |RES(QUIT) | (2) |[1] | |exit | ||
|
||
Filter | ||
====== | ||
|
||
�ե��륿�δ���Ū�ʹ�¤�ϰʲ��Τ褦�˺������Ƥ��������� | ||
|
||
o ɬ�פ˱����ơ��Ķ��ѿ�`SW_FROM_IP'�����ꤵ��Ƥ�����³���� | ||
IP�����IP����հ�����FQDN������å�����������³��Ƚ�Ǥ��� | ||
�ʤ�exit���Ƥ����������ޤ���exitľ����stdout�˽��Ϥ������� | ||
�κǽ��1�Ԥ�syslog��ͳ(mail.info)�ǵ�Ͽ����ޤ������κݤ� | ||
���Ϥˤ�`DATA<CR><LF>'��ޤ�ʤ��Dz�����(smtp_wrapper������ | ||
�ʥ��ȸ�Ƚ�Ǥ��Ƥ��ޤ��Τ�)�� | ||
|
||
o *ɬ��*����östdin��������Ϥ����ƥƥ�ݥ��ե�����˽� | ||
���Ʋ��������̾�stdin�����`HELO ...<CR><LF>'�ޤ���`EHLO ...<CR><LF>' | ||
�ޤ���`MAIL FROM: ...<CR><LF>' -> �����Ĥ���SMTP���ޥ�� | ||
-> `DATA<CR><LF>' -> �����ʸ -> `.<CR><LF>'�ν�ǥǡ��� | ||
�����ä����Ǥ��礦...�� | ||
|
||
o *ɬ��*����ҤΥƥ�ݥ��ե��������`RCPT TO:'�����ƤȴĶ� | ||
�ѿ�`SW_FROM_IP'�����Ƥ���������졼(�軰�ԥ�졼)������� | ||
������������³��Ƚ�Ǥ����ʤ�exit���Ƥ��������� | ||
|
||
smtp_wrapper�����Ѥ����(�����餯)sendmail�Ǥ�/etc/mail/access | ||
�����Ѥ����軰�ԥ�졼�����å��������ʤ��ʤ�ޤ���sendmail | ||
���鸫�����³������륵���Ф����Ƽ�ʬ����(smtp_wrapper)�� | ||
�Τ�Ƚ�ǤΤ��褦��̵������Ǥ� :-P | ||
|
||
o ɬ�פ˱����ơ���ҤΥƥ�ݥ��ե���������Ƥˤ������å� | ||
(spam,virus etc)��Ԥ���������³��Ƚ�Ǥ����ʤ�exit���Ƥ��� | ||
������ | ||
|
||
o ɬ�פ˱����ơ�����¾��ɬ�פʽ���(�إå������������Ʋ��⡢ | ||
������¸��)��ԤäƲ����� B-) | ||
|
||
o �ǽ�Ū�ˡ���������³��Ƚ�Ǥ��줿�ʤ顢��ҤΥƥ�ݥ��ե� | ||
���뤫��`DATA<CR><LF>' -> �����ʸ -> `.<CR><LF>'��stdout | ||
�˽��Ϥ�exit���Ƥ��������� | ||
|
Empty file.
Empty file.
Oops, something went wrong.