1 /**************************************************************************
2 ** (c) Copyright 2007, Andromeda Technology & Automation
3 ** This is free software; you can redistribute it and/or modify it under the
4 ** terms of the GNU General Public License, see the file COPYING.
5 ***************************************************************************
6 ** MODULE INFORMATION *
7 ***********************
8 ** FILE NAME : spamdetect.cpp
9 ** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring
10 ** VERSION NUMBER : $Revision: 1.2 $
17 ***************************************************************************
18 ** ADMINISTRATIVE INFORMATION *
19 ********************************
20 ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
21 ** CREATION DATE : Nov 14, 2007
22 ** LAST UPDATE : Nov Nov 14, 2007
24 **************************************************************************/
26 /*****************************
27 $Log: spamdetect.cpp,v $
28 Revision 1.2 2007-11-21 15:14:26 arjen
31 Revision 1.1 2007/11/14 16:20:05 arjen
32 New program: spamdetect.
33 Expirimental utility to log manually reported spam and have
34 Gnucomo detect the spammer's IP address.
36 *****************************/
38 static const char *RCSID = "$Id: spamdetect.cpp,v 1.2 2007-11-21 15:14:26 arjen Exp $";
46 int main(int argc, char *argv[])
48 const char *usage = "Usage: spamdetect\n";
54 // From here, the original spam starts. Something like
55 // -------- Forwarded Message -------- or -------- Original Message --------
57 regex fwd_header("---- .+ Message -----");
58 regex received("^Received:");
60 regex subject("^Subject:");
61 regex returnpath("^Return-Path:");
63 openlog("gnucomo", 0, LOG_MAIL);
66 while (std::cin >> line)
68 //std::cout << "[" << state << "] checking " << line << "\n"; // DEBUG
72 if (line == fwd_header)
79 // Inside the forwarded header
80 if (line == received || line == from || line == returnpath || line == subject)
87 if (line == regex("^[^ ]+: "))
89 //std::cout << "Header: " << header << "\n"; // DEBUG
90 syslog(LOG_WARNING, "%s", (char *)header);
94 else if (line == String(""))