The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

m_antibear.cpp

Go to the documentation of this file.
00001 /*       +------------------------------------+
00002  *       | Inspire Internet Relay Chat Daemon |
00003  *       +------------------------------------+
00004  *
00005  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
00006  * See: http://www.inspircd.org/wiki/index.php/Credits
00007  *
00008  * This program is free but copyrighted software; see
00009  *            the file COPYING for details.
00010  *
00011  * ---------------------------------------------------
00012  */
00013 
00014 #include "inspircd.h"
00015 #include "xline.h"
00016 
00017 /* $ModDesc: Sends a numeric on connect which cripples a common type of trojan/spambot */
00018 
00019 class ModuleAntiBear : public Module
00020 {
00021  private:
00022 
00023  public:
00024         ModuleAntiBear(InspIRCd* Me) : Module(Me)
00025         {
00026 
00027                 Implementation eventlist[] = { I_OnUserRegister, I_OnPreCommand };
00028                 ServerInstance->Modules->Attach(eventlist, this, 2);
00029         }
00030 
00031         virtual ~ModuleAntiBear()
00032         {
00033         }
00034 
00035         virtual Version GetVersion()
00036         {
00037                 return Version("$Id: m_antibear.cpp 10291 2008-08-25 20:35:51Z w00t $",VF_VENDOR,API_VERSION);
00038         }
00039 
00040         virtual int OnPreCommand(std::string &command, std::vector<std::string> &parameters, User *user, bool validated, const std::string &original_line)
00041         {
00042                 if (command == "NOTICE" && !validated && parameters.size() > 1 && user->GetExt("antibear_timewait"))
00043                 {
00044                         if (!strncmp(parameters[1].c_str(), "\1TIME Mon May 01 18:54:20 2006", 30))
00045                         {
00046                                 ZLine* zl = new ZLine(ServerInstance, ServerInstance->Time(), 86400, ServerInstance->Config->ServerName,
00047                                                 "Unless you're stuck in a time warp, you appear to be a bear bot!", user->GetIPString());
00048                                 if (ServerInstance->XLines->AddLine(zl,NULL))
00049                                 {
00050                                         ServerInstance->XLines->ApplyLines();
00051                                 }
00052                                 else
00053                                         delete zl;
00054 
00055                                 return 1;
00056                         }
00057 
00058                         user->Shrink("antibear_timewait");
00059                         // Block the command, so the user doesn't receive a no such nick notice
00060                         return 1;
00061                 }
00062 
00063                 return 0;
00064         }
00065 
00066         virtual int OnUserRegister(User* user)
00067         {
00068                 user->WriteNumeric(439, "%s :This server has anti-spambot mechanisms enabled.", user->nick.c_str());
00069                 user->WriteNumeric(931, "%s :Malicious bots, spammers, and other automated systems of dubious origin are NOT welcome here.", user->nick.c_str());
00070                 user->WriteServ("PRIVMSG %s :\1TIME\1", user->nick.c_str());
00071                 user->Extend("antibear_timewait");
00072                 return 0;
00073         }
00074 };
00075 
00076 MODULE_INIT(ModuleAntiBear)