/* -*-C-*- $Id: scompfilter.c,v 1.1.1.1 2006/03/03 20:16:11 steve Exp $ scompfilter.c Distribution site: http://word-to-the-wise.com/scompfilter/ Author: Steve Atkins scompfilter is a unix filter to rewrite scomp complaints from AOL into a format that is more useful in a typical abuse desk. It replaces the opaque "Client TOS Notification" subject line with the original sender and original subject line taken from the body of the complaint. It's very lightweight, not doing any MIME extraction, simply assuming that the complaint is in the first plain text message/rfc822 attachment. This is a valid assumption for current AOL complaints. To compile: cc -o scompfilter scompfilter.c To use it with procmail, add a rule such as the following, before other processing is done: #Scomp rewrite script :0fw * ^From:.*scomp@aol.net | /path/to/scompfilter If you like this, you'll love Abacus, the only ticketing system built from the ground up to support ISP abuse and security workers - http://word-to-the-wise.com/abacus/ */ /* (c) Word to the Wise, LLC, 2003 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. This source code may not be used in any manner such that the resulting binary form is covered by any version of the GNU Public License. THIS SOFTWARE IS PROVIDED BY WORD TO THE WISE, LLC ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WORD TO THE WISE, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include struct lines; typedef struct lines { char *line; struct lines *next; struct lines *prev; } lines; const char tosnote[] = "Subject: Client TOS Notification"; int main(int argc, char **argv) { char linebuff[20000]; lines head; lines *tail=&head; lines *me; char *subject=0; char *from=0; char *p; while(fgets(linebuff, sizeof(linebuff), stdin) && 0!=memcmp(linebuff, tosnote, sizeof(tosnote)-1)) { fputs(linebuff, stdout); } while((!subject || !from) && fgets(linebuff, sizeof(linebuff), stdin)) { if(!subject && 0==memcmp("Subject: ", linebuff, 9)) { subject = strdup(linebuff+9); } if(!from && 0==memcmp("From: ", linebuff, 6)) { from = strdup(linebuff+6); } me = (lines*)malloc(sizeof(lines)); me->prev = tail; me->next = 0; me->line = strdup(linebuff); tail->next = me; tail = me; } if(from) { p=from; while(*p && *p != '\r' && *p != '\n') p++; *p = '\0'; } if(subject || from) { fputs("Subject: SCOMP: ", stdout); if(from) { printf("[%s] ", from); } if(subject) { fputs(subject, stdout); } else { fputs("\n", stdout); } } me = head.next; while(me) { fputs(me->line, stdout); me = me->next; } while(fgets(linebuff, sizeof(linebuff), stdin)) { fputs(linebuff, stdout); } return 0; }