일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- KOSPI
- 알고리즘
- 작성중
- unix
- adb
- 보안
- 도서
- eclipse35
- ubuntu
- 태터수정
- 코스피
- IT 키워드
- Audacity
- uml example
- 주식
- 안드로이드
- IPTV
- conemu
- 공매도
- UX
- Linux
- 기술사
- java
- Android
- Algorithm
- Eclipse
- Qmail
- 우분투
- LDAP
Archives
- Today
- Total
Do diffence
[hack] ./bin/qmail-remote 활용 본문
#!/usr/bin/perl
# 스탠다드 입력으로 메일 내용을 읽어들인다.
undef $/;
$inputdata = <STDIN>;
$/ = "\n";
$inputdata =~ /Subject: (.*)/;
$subject = $1;
$inputdata =~ /Received: from.*\(([0-9.]+)\)/;
$ip = $1;
# 시간을 구한다.
$now_string = localtime;
# 로그를 기록한다.
$logfile = "/var/log/qmail/remote.log";
open FH, ">>$logfile";
flock(FH,2);
# 반송메일을 드롭한다.
if ($subject =~ /(failure notice)/i) {
$inputdata =~ /(no mailbox here by that name)/i;
if ($1 eq "no mailbox here by that name") {
print FH "Droped!!(Nouser)\t$now_string\tIP:$ip\tTo:$ARGV[2]\tFrom:$ARGV[1]\tSubject:$subject\n";
close FH;
exit 2;
} else {
print FH "Droped!!(failure notice)\t$now_string\tIP:$ip\tTo:$ARGV[2]\tFrom:$ARGV[1]\tSubject:$subject - Other\n";
close FH;
}
} else {
print FH "OK!!\t\t\t$now_string\tIP:$ip\tTo:$ARGV[2]\tFrom:$ARGV[1]\tSubject:$subject\n";
close FH;
}
# 원래 qmail-remote 프로그램을 실행시킨다.
open (MAIL, "| /var/qmail/bin/qmail-remote-original $ARGV[0] $ARGV[1] $ARGV[2]");
print MAIL $inputdata;
close MAIL;
# 스탠다드 입력으로 메일 내용을 읽어들인다.
undef $/;
$inputdata = <STDIN>;
$/ = "\n";
$inputdata =~ /Subject: (.*)/;
$subject = $1;
$inputdata =~ /Received: from.*\(([0-9.]+)\)/;
$ip = $1;
# 시간을 구한다.
$now_string = localtime;
# 로그를 기록한다.
$logfile = "/var/log/qmail/remote.log";
open FH, ">>$logfile";
flock(FH,2);
# 반송메일을 드롭한다.
if ($subject =~ /(failure notice)/i) {
$inputdata =~ /(no mailbox here by that name)/i;
if ($1 eq "no mailbox here by that name") {
print FH "Droped!!(Nouser)\t$now_string\tIP:$ip\tTo:$ARGV[2]\tFrom:$ARGV[1]\tSubject:$subject\n";
close FH;
exit 2;
} else {
print FH "Droped!!(failure notice)\t$now_string\tIP:$ip\tTo:$ARGV[2]\tFrom:$ARGV[1]\tSubject:$subject - Other\n";
close FH;
}
} else {
print FH "OK!!\t\t\t$now_string\tIP:$ip\tTo:$ARGV[2]\tFrom:$ARGV[1]\tSubject:$subject\n";
close FH;
}
# 원래 qmail-remote 프로그램을 실행시킨다.
open (MAIL, "| /var/qmail/bin/qmail-remote-original $ARGV[0] $ARGV[1] $ARGV[2]");
print MAIL $inputdata;
close MAIL;