summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-11-22 15:00:03 -0800
committerJohn Denker <jsd@av8n.com>2012-11-22 15:00:03 -0800
commit53f82741570be28861d3774069ee2faaf976aac9 (patch)
tree3bcf36a681b2fc2e6a5316cc7e6ed1a3c491c434 /tools
parent5ae2655e357717dfcf51242154700ee947ea05db (diff)
protect against spam what would loop due to Delievered-to: field
Diffstat (limited to 'tools')
-rw-r--r--tools/skrewt.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/tools/skrewt.c b/tools/skrewt.c
index ed257e0..70265da 100644
--- a/tools/skrewt.c
+++ b/tools/skrewt.c
@@ -125,7 +125,9 @@ int mypid;
/* Content-Type: text/plain; charset="us-ascii" */
/* Content-Type: multipart/mixed; boundary="1170861315-1262462055-1341954763=:92165" */
//
-void parse_content(const string type_spec_line, string &maintype, string &boundary) {
+
+void parse_content(const string type_spec_line,
+ string &maintype, string &boundary) {
//xxx cerr << "parser called with: " << type_spec_line << endl;
string get_type(type_spec_line);
@@ -194,6 +196,7 @@ public:
string date;
string message_id;
string content_type;
+ string delivered_to;
int msgsize;
vector<string> bigbuf;
int saw_blank_line;
@@ -347,6 +350,8 @@ int skrewt::headers(){
subject = rest;
} else if (headword == "content-type") {
content_type = rest;
+ } else if (headword == "delivered-to") {
+ delivered_to = rest;
}
//xxxx cout << headrec.length() << " ... ";
recno++;
@@ -385,26 +390,26 @@ int skrewt::interstage(){
}
// The logic here is: In order:
-// 1) If whitelisted, accept. No greylisting, no spam-checking.
-// 2) If blacklisted, reject. No greylisting, no spam-checking.
-// 3) If good reputation, spam-check it and send it on its way.
-// 4) If no reputation, greylist.
-// 5) If bad reputation, ????
+// 1:: If whitelisted, accept. No greylisting, no spam-checking.
+// 2:: If blacklisted, reject. No greylisting, no spam-checking.
+// 3:: If good reputation, spam-check it and send it on its way.
+// 4:: If no reputation, greylist.
+// 5:: If bad reputation, ????
// Expanding item 3 to the next level of detail:
-// 3a) If some domain vouches for this sender-IP via SPF,
+// 3a:: If some domain vouches for this sender-IP via SPF,
// then the reputation is bound to the domain.
-// 3c) If some domain vouches for the message vie DKIM,
+// 3c:: If some domain vouches for the message vie DKIM,
// then the reputation is bound to the domain.
-// 3d) If no SPF or DKIM, then the reputation attaches
+// 3d:: If no SPF or DKIM, then the reputation attaches
// to the sender-IP.
// Expanding item 4 to the next level of detail:
-// 4a) If the greylisting database says this message is ripe
+// 4a:: If the greylisting database says this message is ripe
// spam-check it. If it's OK, use it to count toward reputation.
-// 4b) If it is previously unseen or too old, start greylisting
+// 4b:: If it is previously unseen or too old, start greylisting
// timer from scratch. Reject with temporary error.
-// 4c) If it is in the "green" state, let the timer
+// 4c:: If it is in the "green" state, let the timer
// continue from where it is. Reject with temporary error.
// Note: Reputation normally attaches to a domain.
@@ -486,6 +491,19 @@ int skrewt::interstage(){
#endif
list<string> badnews;
+ int whitelisted(0);
+
+ if (subject.find("sesame") != string::npos
+ && subject.find("swordfish") != string::npos) {
+ whitelisted++;
+ }
+
+ if (delivered_to.length()){
+ cerr << progid << "Delivered-to: <<<" << delivered_to << ">>>" << endl;
+ }
+ if (toLower(trim(delivered_to)) == "jean@av8n.com") {
+ badnews.push_back("Looping Delivered-to: " + delivered_to);
+ }
if (subject.find("-please-bounce-this-") != string::npos) {
badnews.push_back("by request");
@@ -499,7 +517,7 @@ int skrewt::interstage(){
badnews.push_back("no message-id");
}
- if (badnews.size()){
+ if (badnews.size() && !whitelisted){
cerr << progid << " " << join(", ", badnews) << endl;
if (error_exit){
cerr << progid << " '" << from