Skip to content

Commit

Permalink
2016/05/08 23:53:12
Browse files Browse the repository at this point in the history
  • Loading branch information
MasahikoIto committed May 8, 2016
1 parent 3ba48be commit 65102b1
Show file tree
Hide file tree
Showing 16 changed files with 192 additions and 68 deletions.
7 changes: 7 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@
���� : - Starpit�Ǥܸۤ�����̵��98%�Υ��ѥ���ӽ� (S25R+tarpitting�ˤ�륹�ѥ��к�)
http://d.hatena.ne.jp/stealthinu/20060706/p5
- sample/smtp_filter1_starpit.sh
20??/??/?? Ver. 0.5
o ����ü�����ڤ�Υ����ʬ������
o sample�ǥ��쥯�ȥ�ʲ��Υ�����ץȤ˴ؤ��륻�����ƥ���(����ǥ��쥯�ȥ�ΰ�����)����������README���ɲá�
o read()���Ф��Ƥ�timeout�����꤬ͭ���Ȥʤ�褦�˽�����
o write()���Ф��Ƥ�timeout�����꤬ͭ���Ȥʤ�褦�˽�����
o SigTrap()����Ƭ��signal(sig, SIG_IGN)���ɲá�
o EHLO ���Ф��Ƥ� `504'���֤��Ƥ����Τ�`502'���֤��褦�˽���(Thunderbird�б�)
9 changes: 9 additions & 0 deletions CVS/Entries
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
D/sample////
/COPYING/1.1/Mon May 2 18:27:55 2005//
/Makefile/1.1/Sat Apr 29 04:18:49 2006//
/MISC/1.1/Mon May 22 08:24:05 2006//
/.CVS_KEEP/1.1/Wed May 24 07:33:29 2006/-kb/
/README/1.25/Tue Apr 17 02:19:46 2007//
/README.en/1.3/Tue Apr 17 02:20:30 2007//
/CHANGES/1.30/Mon Jan 2 11:10:20 2012//
/smtp_wrapper.c/1.34/Mon Mar 3 01:16:06 2014//
1 change: 1 addition & 0 deletions CVS/Repository
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
smtp_wrapper-current
1 change: 1 addition & 0 deletions CVS/Root
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/home/m-ito/cvs
18 changes: 15 additions & 3 deletions README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
smtp_wrapper-0.4 -- SMTP filtering support daemon
smtp_wrapper-0.5 -- SMTP filtering support daemon
Copyright (C) 2006 Masahiko Ito

These programs is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -26,6 +26,7 @@ History
2006/05/15 Ver. 0.2 release
2006/05/24 Ver. 0.3 release
2006/10/02 Ver. 0.4 release
2007/??/?? Ver. 0.5 release

What's this ?
=============
Expand Down Expand Up @@ -94,8 +95,8 @@ Install
=======

o cd /usr/local/
o tar xvzf smtp_wrapper-0.4.tar.gz
o ln -sf smtp_wrapper-0.4 smtp_wrapper
o tar xvzf smtp_wrapper-0.5.tar.gz
o ln -sf smtp_wrapper-0.5 smtp_wrapper
o cd smtp_wrapper
o cc -o smtp_wrapper smtp_wrapper.c
o vi smtp_filter1.sh # �ե��륿�ϳƼ����Ѱդ��Ʋ�����(for ip_filter)
Expand Down Expand Up @@ -400,3 +401,14 @@ o fetchmail
fetchmail��Ȥä�(�Ŀͤ�)������᡼���spam�к��ϡ�procmail
�Ⱦ�ҤΥե��륿�α����ǡ��⤷���ϥ٥����ϥե��륿�Ȥ��ȹ礻
�Ǥ�äơ����饤�����¦���б�����Τ��Ȥ���...��

o sample�ǥ��쥯�ȥ�ʲ��Υ�����ץȤ˴ؤ��Ƥϥ������ƥ��˴�
����ʬ������ޤ�������ե������̵�����/tmp��/var/tmp�˺���
���Ƥ���Τǡ�root�ʳ��Υ桼���ˤ�륷��ܥ�å���󥯹����
���餵����ǽ��������ޤ������Ѥ��륵���ФΥ�������桼����
�¼�Ū��root����¸�ߤ��ʤ����ϡ�����ˤʤ�ʤ��Ȼפ��ޤ�����
���ޤ�˫���줿��ΤǤϤ���ޤ��� :<

�����դꡢ���ֱ��Ѥ����Ѥ������Ϥ��줰���漫�ȤǸ�Ƥ����
ɬ�פʽ�����ܤ���������Ѥ��Ƥ���������

2 changes: 1 addition & 1 deletion README.en
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
smtp_wrapper-0.4 -- SMTP filtering support daemon
smtp_wrapper-0.5 -- SMTP filtering support daemon
Copyright (C) 2006 Masahiko Ito

These programs is free software; you can redistribute it and/or modify
Expand Down
Empty file added sample/.CVS_KEEP
Empty file.
15 changes: 15 additions & 0 deletions sample/CVS/Entries
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/show_retry2.sh/1.3/Wed May 24 00:42:37 2006//
/smtp_null_filter.sh/1.7/Wed May 24 02:57:34 2006//
/black_hostname_db/1.2/Wed May 24 04:22:56 2006/-kb/
/relay_allow_host_db/1.1/Wed May 24 04:23:36 2006//
/white_hostname_db/1.3/Wed May 24 04:23:52 2006//
/white_ip_db/1.3/Wed May 24 04:24:04 2006//
/black_ip_db/1.3/Wed May 24 07:31:49 2006/-kb/
/relay_allow_address_db/1.2/Wed May 24 07:28:46 2006//
/show_retry1.sh/1.11/Mon Feb 26 03:26:47 2007//
/smtp_filter.sh/1.16/Wed May 23 10:42:15 2007//
/smtp_filter1.sh/1.11/Wed May 23 10:42:33 2007//
/smtp_filter1_starpit.sh/1.4/Wed May 23 10:42:48 2007//
/smtp_filter2.sh/1.12/Wed May 23 10:43:03 2007//
/.CVS_KEEP/1.1/Mon Mar 3 01:16:12 2014/-kb/
D
1 change: 1 addition & 0 deletions sample/CVS/Repository
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
smtp_wrapper-current/sample
1 change: 1 addition & 0 deletions sample/CVS/Root
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/home/m-ito/cvs
25 changes: 13 additions & 12 deletions sample/show_retry1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# ex. cat /var/log/maillog | show_retry1.sh
#
PATH="/usr/local/smtp_wrapper:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"; export PATH
tmp="/tmp"
#-----------------------------------------------------------------
#
# 当日中の、完全に全てのアクセスを拒否されているIPの内、
Expand All @@ -31,33 +32,33 @@ date=`date +'%b %d' | sed -e 's/ *0/ /'`
# 当日中の、IPを含んだ(拒否|受付)メッセージを抽出[1]
cat $* |\
sed -e 's/ */ /g' |\
egrep -i "^${date} .*smtp_wrapper.*rejected by|^${date} .*smtp_wrapper.*child start" >/tmp/show_retry1.1.$$.tmp
egrep -i "^${date} .*smtp_wrapper.*rejected by|^${date} .*smtp_wrapper.*child start" >${tmp}/show_retry1.1.$$.tmp
#
# 受付メッセージから出現回数、IPを抽出&編集[2]
cat /tmp/show_retry1.1.$$.tmp |\
cat ${tmp}/show_retry1.1.$$.tmp |\
grep -i 'child start' |\
sed -e 's/^.*IP=//;s/(.*$//' |\
sort |\
uniq -c |\
grep -v '^ *1 ' |\
sort >/tmp/show_retry1.2.$$.tmp
sort >${tmp}/show_retry1.2.$$.tmp
#
# 拒否メッセージから出現回数、IPを抽出&編集[3]
cat /tmp/show_retry1.1.$$.tmp |\
cat ${tmp}/show_retry1.1.$$.tmp |\
grep -i 'rejected by' |\
sed -e 's/^.*IP=//;s/).*$//' |\
sort |\
uniq -c |\
sort >/tmp/show_retry1.3.$$.tmp
sort >${tmp}/show_retry1.3.$$.tmp
#
# 受付回数と拒否回数の等しい(つまり完全に拒否されている)IPを抽出[4]
join -t "," /tmp/show_retry1.2.$$.tmp /tmp/show_retry1.3.$$.tmp |\
join -t "," ${tmp}/show_retry1.2.$$.tmp ${tmp}/show_retry1.3.$$.tmp |\
sed -e 's/^ *//' |\
cut -d ' ' -f 2 |\
sort >/tmp/show_retry1.4.$$.tmp
sort >${tmp}/show_retry1.4.$$.tmp
#
# 拒否メッセージの間隔がINTERVAL秒以上のIP抽出&編集[5]
cat /tmp/show_retry1.1.$$.tmp |\
cat ${tmp}/show_retry1.1.$$.tmp |\
grep -i "smtp_wrapper.*rejected by" |\
sed -e 's/smtp_wrapper:.*IP=//;s/).*$//;s/:/ /g' |\
sort -t ' ' +6 -7 +2 -5 |\
Expand Down Expand Up @@ -102,16 +103,16 @@ END{
if (rapid == "NO"){
print ip;
}
}' >/tmp/show_retry1.5.$$.tmp
}' >${tmp}/show_retry1.5.$$.tmp
#
# [4][5]マッチングして、全ての受付がINTERVAL秒以上の間隔で拒否されているIPを抽出[6]
join /tmp/show_retry1.4.$$.tmp /tmp/show_retry1.5.$$.tmp >/tmp/show_retry1.6.$$.tmp
join ${tmp}/show_retry1.4.$$.tmp ${tmp}/show_retry1.5.$$.tmp >${tmp}/show_retry1.6.$$.tmp
#
# [6]にDNS逆引結果を付加して表示
for i in `cat /tmp/show_retry1.6.$$.tmp`
for i in `cat ${tmp}/show_retry1.6.$$.tmp`
do
echo -n $i " : "
host $i
done
#
rm -f /tmp/show_retry1.*.$$.tmp
rm -f ${tmp}/show_retry1.*.$$.tmp
6 changes: 6 additions & 0 deletions sample/smtp_filter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ PATH="/usr/local/smtp_wrapper:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:
export PATH
#============================================================
#
# timeout (This was bad idea :<)
#
#timeout=10m
#(sleep ${timeout}; kill -15 ${PPID}) &
#============================================================
#
# smtp_wrapperディレクトリ指定
#
smtp_wrapper_dir="/usr/local/smtp_wrapper"
Expand Down
6 changes: 6 additions & 0 deletions sample/smtp_filter1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ PATH="/usr/local/smtp_wrapper:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:
export PATH
#============================================================
#
# timeout (This was bad idea :<)
#
#timeout=10m
#(sleep ${timeout}; kill -15 ${PPID}) &
#============================================================
#
# smtp_wrapperディレクトリ指定
#
smtp_wrapper_dir="/usr/local/smtp_wrapper"
Expand Down
13 changes: 12 additions & 1 deletion sample/smtp_filter1_starpit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ PATH="/usr/local/smtp_wrapper:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:
export PATH
#============================================================
#
# timeout (This was bad idea :<)
#
#timeout=10m
#(sleep ${timeout}; kill -15 ${PPID}) &
#============================================================
#
# smtp_wrapperディレクトリ指定
#
smtp_wrapper_dir="/usr/local/smtp_wrapper"
Expand Down Expand Up @@ -64,7 +70,12 @@ spam_exit ()
logger -p mail.info -t ${sl_ident} "[$$]:HOST=${from_hostname}"
logger -p mail.info -t ${sl_ident} "[$$]:EXIT=$1"
logger -p mail.info -t ${sl_ident} "[$$]:REASON=$2"
sleep ${delay}
if [ "X$1" = "X3" -o "X$1" = "X5" ]
then
echo "NG: Black list ( $1 )"
else
sleep ${delay}
fi
rm -f ${tmp}/smtp_filter1_starpit.*.$$.tmp
exit $1
}
Expand Down
6 changes: 6 additions & 0 deletions sample/smtp_filter2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ PATH="/usr/local/smtp_wrapper:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:
export PATH
#============================================================
#
# timeout (This was bad idea :<)
#
#timeout=10m
#(sleep ${timeout}; kill -15 ${PPID}) &
#============================================================
#
# smtp_wrapperディレクトリ指定
#
smtp_wrapper_dir="/usr/local/smtp_wrapper"
Expand Down
Loading

0 comments on commit 65102b1

Please sign in to comment.