#include "module.h" #define AUTHOR "SGR" #define VERSION "1.00" /* ----------------------------------------------------------- * Name : ircd_webbiecheck * Author: SGR * Date : 17/11/2003 * ----------------------------------------------------------- * Functions: my_privmsgA, my_nickA, webbie_ctcp_check, * notice_and_set_modes_on_webbie. * Limitations: None Known * Tested: Ultimate(2.8.x), Unreal(3.2), Viagra, Ultimate(3.x) * ----------------------------------------------------------- * This version has been tested on Ultimate, Viagra and * Unreal. * * This modules has 20 configurable options * * Please read the comments by each one. * ----------------------------------------------------------- * * Version Changes: * * 1: works (i hope :P). * * ----------------------------------------------------------- */ /* ---------------------------------------------------------------------- */ /* START OF CONFIGURATION BLOCK - please read the comments :) */ /* ---------------------------------------------------------------------- */ /* NONE OF THE BELOW MESSAGES SHOULD BE LONGER THAN 450 characters - * including spaces. */ /* The strings below will be used to check for webbie clients. The string * does not need to be exact, but the string inside the "speach marks" must * at least be part of the overall CTCP VERSION reply. * e.g. I by entering "WebTV", all the following replies will match: * "WebTV" * "WebTV Version X.x.X" * "This_IS_WebTV" * * The checking is NOT case sensitive. Up to 3 different patterns can be * provided. */ #define WebbieReply1 "WebTV" //#define WebbieReply2 "JPilot" //#define WebbieReply3 "You appear to be using a trojan, very outdated or forbidden client." /* The below is _P_R_I_V_M_S_G_'d to users who are detected as WebTV users. */ #define You_Are_Webbie1 "Hey, you appear to we a WebTV user!" #define You_Are_Webbie2 "For help on the features we provide for \"webbies\"," #define You_Are_Webbie3 "please type: JOIN #Webbie" //#define You_Are_Webbie5 " " //#define You_Are_Webbie6 " " //#define You_Are_Webbie7 " " //#define You_Are_Webbie8 " " //#define You_Are_Webbie9 " " //#define You_Are_Webbie10 " " /* MAX of 5 modes. [These modes will be FORCED on webbies after that have connected. * Ideal for adding modes to tell users they are webbies or to apply extra security * like mode +i etc.. */ #define ModesToAdd "Vi" /* MAX of 5 modes. [These modes will we REVOKED from webbies after that have connected. * Ideal for removing modes usually imposed by an IRCd on connecting clients] */ #define ModesToTake "ws" char *s_WebbieServ = "WebbieCheck"; /* Nickname - NICKLEN character MAXIMUM */ /* (see your IRCd's protocall response for this) */ char *s_WebbieServHOST = "WebbieCheck.Network.Help.Bot"; /* HostMask: 64 character MAXIMUM */ char *s_WebbieServREALNAME = "WebbieCheck WebTV user dectector."; /* Realname 30 character MAXIMUM */ // Set to 1 or 0. 1 == Set checking to 'on' on load. // 0 == Set checking to 'off' on load int cDEFAULTMODE = 1; /* on load logging status * SET LOGGING [OFF|BASIC|USEFUL|VERBOSE|FULL]" * 0 1 2 3 4 * 0 - Off * 1 - Every Action * 2 - Every Match + Every Action + Every FAIL * 3 - Every New User Versioned + Every Match + Every Action * 4 - Detected User + Every New User Versioned + Every Match + Every Action * * This setting MUST be 0, 1, 2, 3 or 4 */ int cDEFAULTLOGLEVEL = 0; /* ---------------------------------------------------------------------- */ /* DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING */ /* ---------------------------------------------------------------------- */ int my_privmsgA(char *source, int ac, char **av); int my_nickA(char *source, int ac, char **av); int webbie_ctcp_check(User * u, char *buf); int notice_and_set_modes_on_webbie(User *u); int donotchecktruea = 0; int WebbieServLOGLEV = 0; int AnopeInit(int argc, char **argv) { Message *msg = NULL; int status; msg = createMessage("PRIVMSG", my_privmsgA); status = moduleAddMessage(msg, MOD_HEAD); msg = createMessage("NOTICE", my_privmsgA); status = moduleAddMessage(msg, MOD_HEAD); #if defined(IRC_ULTIMATE3) msg = createMessage("CLIENT", my_nickA); #else msg = createMessage("NICK", my_nickA); #endif status = moduleAddMessage(msg, MOD_TAIL); if (status == MOD_ERR_OK) { NEWNICK(s_WebbieServ, s_WebbieServ, s_WebbieServHOST, s_WebbieServREALNAME, "+ioS", 1); } moduleAddAuthor(AUTHOR); moduleAddVersion(VERSION); donotchecktruea = cDEFAULTMODE; WebbieServLOGLEV = cDEFAULTLOGLEVEL; alog("[ircd_webbiecheck] This module has loaded and is now active."); alog("[ircd_webbiecheck] For information see /msg %s HELP", s_WebbieServ); alog("[ircd_webbiecheck] ###################################################"); alog("[ircd_webbiecheck] ---------------------------------------------------"); alog("[ircd_webbiecheck] %s will commuicate via PRIVMSG _NOT_ NOTICES ", s_WebbieServ); alog("[ircd_webbiecheck] in most cases. This is NORMAL. [Webbies don't like"); alog("[ircd_webbiecheck] notices]"); alog("[ircd_webbiecheck] ---------------------------------------------------"); alog("[ircd_webbiecheck] ###################################################"); if (!cDEFAULTMODE) { alog("[ircd_webbiecheck] %s checking DISABLED. To activate chekcing now, use:", s_WebbieServ); alog("[ircd_webbiecheck] /msg %s SET CHECK ON", s_WebbieServ); } if (cDEFAULTMODE) { if (cDEFAULTMODE >= 1) { alog("[ircd_webbiecheck] %s - Checking activated", s_WebbieServ); } } if (!cDEFAULTLOGLEVEL) { alog("[ircd_webbiecheck] %s - Logging set to OFF. Use: /msg %s SET LOGGING ON - to enable.", s_WebbieServ, s_WebbieServ); } if (cDEFAULTLOGLEVEL == 1) { alog("[ircd_webbiecheck] %s - Logging set to BASIC.", s_WebbieServ); } if (cDEFAULTLOGLEVEL == 2) { alog("[ircd_webbiecheck] %s - Logging set to USEFUL.", s_WebbieServ); } if (cDEFAULTLOGLEVEL == 3) { alog("[ircd_webbiecheck] %s - Logging set to VERBOSE.", s_WebbieServ); } if (cDEFAULTLOGLEVEL == 4) { alog("[ircd_webbiecheck] %s - Logging set to FULL.", s_WebbieServ); } return MOD_CONT; } void AnopeFini(void) { send_cmd(s_WebbieServ, "QUIT :Module Unloaded!"); } int my_privmsgA(char *source, int ac, char **msg) { /* an uglier version of Rob's CatServ module code */ User *u; char *s; /* First, some basic checks */ if (ac != 2) { /* bleh */ return MOD_CONT; } if (!(u = finduser(source))) { return MOD_CONT; } /* non-user source */ if (*msg[0] == '#') { return MOD_CONT; } /* Channel message */ s = strchr(msg[0], '@'); if (s) { *s++ = 0; if (stricmp(s, ServerName) != 0) { return MOD_CONT; } } if ((stricmp(msg[0], s_WebbieServ)) == 0) { /* its for US! */ webbie_ctcp_check(u, msg[1]); return MOD_STOP; } else { return MOD_CONT; } } /*****************************************************************************/ int webbie_ctcp_check(User * u, char *buf) { char *isversion = strtok(buf, " "); char *s; char *t; if (!isversion) { return MOD_STOP; } if (stricmp(isversion, "\1PING") == 0) { if (!(s = strtok(NULL, ""))) { s = "\1"; } privmsg(s_WebbieServ, u->nick, "\1PING %s", s); return MOD_STOP; } if (skeleton) { notice_lang(s_WebbieServ, u, SERVICE_OFFLINE, s_WebbieServ); return MOD_STOP; } if (WebbieServLOGLEV > 3) { alog("[ircd_webbiecheck] - Got a message - starts: %s", isversion); } if (stricmp(isversion, "\1VERSION") == 0) { if (WebbieServLOGLEV > 3) { alog("[ircd_webbiecheck] - Its a VERSION!"); } if (donotchecktruea == 1) { if (!(s = strtok(NULL, ""))) { s = "\1"; } if (WebbieServLOGLEV > 3) { alog("[ircd_webbiecheck] - Checking | %s | against def lists.", s); } #ifdef WebbieReply1 if (stristr(s,WebbieReply1)) { notice_and_set_modes_on_webbie(u); return MOD_STOP; } #endif #ifdef WebbieReply2 if (stristr(s,WebbieReply2)) { notice_and_set_modes_on_webbie(u); return MOD_STOP; } #endif #ifdef WebbieReply3 if (stristr(s,WebbieReply3)) { notice_and_set_modes_on_webbie(u); return MOD_STOP; } #endif } } if (stricmp(isversion, "HELP") == 0) { s = strtok(NULL, " "); if (!s) { privmsg(s_WebbieServ, u->nick, "-----------------------------------------------------------------------"); privmsg(s_WebbieServ, u->nick, "%s checks users CTCP versions as they join the network.", s_WebbieServ); privmsg(s_WebbieServ, u->nick, "This is done so we can quickly remove mass-spam or clone bots."); privmsg(s_WebbieServ, u->nick, "If you match a forbidden client you may be forcefully removed"); privmsg(s_WebbieServ, u->nick, "from the network. For more information join the official help"); privmsg(s_WebbieServ, u->nick, "room."); if (is_oper(u)) { privmsg(s_WebbieServ, u->nick, " "); privmsg(s_WebbieServ, u->nick, "The module version is %s", VERSION); privmsg(s_WebbieServ, u->nick, " "); privmsg(s_WebbieServ, u->nick, "New defintions should be added to custom.dat"); privmsg(s_WebbieServ, u->nick, "Please remember to NOT modify the official.dat file - "); privmsg(s_WebbieServ, u->nick, "and to only add your own 'definitions' to the custom.dat"); privmsg(s_WebbieServ, u->nick, "file; offical.dat may get updated, check the anope forums."); privmsg(s_WebbieServ, u->nick, "This file [custom.dat] can be updated \"on the fly\" so no"); privmsg(s_WebbieServ, u->nick, "'reshashing' is needed. Please ensure there are NO blank lines."); privmsg(s_WebbieServ, u->nick, "in this file."); privmsg(s_WebbieServ, u->nick, " "); privmsg(s_WebbieServ, u->nick, "For help on setting %s options see /msg %s HELP SET", s_WebbieServ, s_WebbieServ); } privmsg(s_WebbieServ, u->nick, "-----------------------------------------------------------------------"); return MOD_CONT; } if (is_services_admin(u)) { if (stricmp(s, "NOTICES") == 0) { privmsg(s_WebbieServ, u->nick, "-----------------------------------------------------------------------"); privmsg(s_WebbieServ, u->nick, "These privmsgs will be privmsgd to uses when NOTIFY is set as the"); privmsg(s_WebbieServ, u->nick, "%s action when checking is on.", s_WebbieServ); privmsg(s_WebbieServ, u->nick, "-----------------------------------------------------------------------"); #ifdef You_Are_Webbie1 privmsg(s_WebbieServ, u->nick, You_Are_Webbie1); #endif #ifdef You_Are_Webbie2 privmsg(s_WebbieServ, u->nick, You_Are_Webbie2); #endif #ifdef You_Are_Webbie3 privmsg(s_WebbieServ, u->nick, You_Are_Webbie3); #endif #ifdef You_Are_Webbie4 privmsg(s_WebbieServ, u->nick, You_Are_Webbie4); #endif #ifdef You_Are_Webbie5 privmsg(s_WebbieServ, u->nick, You_Are_Webbie5); #endif #ifdef You_Are_Webbie6 privmsg(s_WebbieServ, u->nick, You_Are_Webbie6); #endif #ifdef You_Are_Webbie7 privmsg(s_WebbieServ, u->nick, You_Are_Webbie7); #endif #ifdef You_Are_Webbie8 privmsg(s_WebbieServ, u->nick, You_Are_Webbie8); #endif #ifdef You_Are_Webbie9 privmsg(s_WebbieServ, u->nick, You_Are_Webbie9); #endif #ifdef You_Are_Webbie10 privmsg(s_WebbieServ, u->nick, You_Are_Webbie10); #endif privmsg(s_WebbieServ, u->nick, "-----------------------------------------------------------------------"); return MOD_CONT; } if (stricmp(s, "SET") == 0) { privmsg(s_WebbieServ, u->nick, "-----------------------------------------------------------------------"); privmsg(s_WebbieServ, u->nick, "Syntax: SET ACTION [KILL|AKILL|GLOBOPS|ALOG|NOTICE]"); privmsg(s_WebbieServ, u->nick, "Syntax: SET CHECK [ALL|ON|OFF]"); privmsg(s_WebbieServ, u->nick, "Syntax: SET LOGGING [OFF|BASIC|USEFUL|VERBOSE|FULL]"); privmsg(s_WebbieServ, u->nick, " "); privmsg(s_WebbieServ, u->nick, " "); privmsg(s_WebbieServ, u->nick, "SET CHECK: Set if the CTCP VERSION on connect is actually used. This"); privmsg(s_WebbieServ, u->nick, " command is designed to stop the checks for a short time"); privmsg(s_WebbieServ, u->nick, " without a SRA having to unload the module. OFF means no"); privmsg(s_WebbieServ, u->nick, " clients will be checked at all."); privmsg(s_WebbieServ, u->nick, " "); privmsg(s_WebbieServ, u->nick, "SET LOGGING: This command sets how verbose %s's logging is. When set to", s_WebbieServ); privmsg(s_WebbieServ, u->nick, " OFF, there is no logging what-so-ever. When set to BASIC, logs"); privmsg(s_WebbieServ, u->nick, " of clients who ilicit ACTION are made to the logchan."); privmsg(s_WebbieServ, u->nick, " When set to USEFUL, CTCPServ will send logchan messages of"); privmsg(s_WebbieServ, u->nick, " the definition matched and the action ensuing it. VERBOSE"); privmsg(s_WebbieServ, u->nick, " puts all relevant info into the logchan, and finally FULL"); privmsg(s_WebbieServ, u->nick, " is used for debugging purposes. "); privmsg(s_WebbieServ, u->nick, " "); privmsg(s_WebbieServ, u->nick, "NOTE: If this module is unloaded these settings are lost."); privmsg(s_WebbieServ, u->nick, "-----------------------------------------------------------------------"); return MOD_CONT; } } return MOD_CONT; } if (stricmp(isversion, "SET") == 0) { if (!is_services_admin(u)) { return MOD_CONT; } s = strtok(NULL, " "); t = strtok(NULL, " "); if (!s || !t) { privmsg(s_WebbieServ, u->nick, "See \2/msg %s HELP SET\2 for more information.", s_WebbieServ); return MOD_CONT; } /* ------------ * Checking INT's * ------------ * OFF = 0 * ON = 1 * */ if (stricmp(s, "CHECK") == 0) { if (stricmp(t, "OFF") == 0) { donotchecktruea = 0; privmsg(s_WebbieServ, u->nick, "You sucessfully disabled CTCP VERSION checking."); wallops(s_WebbieServ, "%s set %s on connect CTCP VERSION checking OFF.", u->nick, s_WebbieServ); return MOD_CONT; } if (stricmp(t, "ON") == 0) { donotchecktruea = 1; privmsg(s_WebbieServ, u->nick, "You sucessfully enabled CTCP VERSION checking."); wallops(s_WebbieServ, "%s set %s on connect CTCP VERSION checking ON.", u->nick, s_WebbieServ); return MOD_CONT; } else { privmsg(s_WebbieServ, u->nick, "See \2/msg %s HELP SET\2 for more information.", s_WebbieServ); } return MOD_CONT; } /* ---------- * Logging INT's *----------- * 0 Off * 1 Every Action * 2 Every Match + Every Action + Every FAIL * 3 Every New User Versioned + Every Match + Every Action * 4 Detected User + Every New User Versioned + Every Match + Every Action */ if (stricmp(s, "LOGGING") == 0) { if (stricmp(t, "OFF") == 0) { WebbieServLOGLEV = 0; privmsg(s_WebbieServ, u->nick, "You sucessfully set %s logging to OFF.", s_WebbieServ); wallops(s_WebbieServ, "%s set sucessfully set %s logging to OFF.", u->nick, s_WebbieServ); return MOD_CONT; } if (stricmp(t, "BASIC") == 0) { WebbieServLOGLEV = 1; privmsg(s_WebbieServ, u->nick, "You sucessfully set %s logging to BASIC.", s_WebbieServ); wallops(s_WebbieServ, "%s set sucessfully set %s logging to BASIC.", u->nick, s_WebbieServ); return MOD_CONT; } if (stricmp(t, "USEFUL") == 0) { WebbieServLOGLEV = 2; privmsg(s_WebbieServ, u->nick, "You sucessfully set %s logging to USEFUL.", s_WebbieServ); wallops(s_WebbieServ, "%s set sucessfully set %s logging to USEFUL.", u->nick, s_WebbieServ); return MOD_CONT; } if (stricmp(t, "VERBOSE") == 0) { WebbieServLOGLEV = 3; privmsg(s_WebbieServ, u->nick, "You sucessfully set %s logging to VERBOSE.", s_WebbieServ); wallops(s_WebbieServ, "%s set sucessfully set %s logging to VERBOSE.", u->nick, s_WebbieServ); return MOD_CONT; } if (stricmp(t, "FULL") == 0) { WebbieServLOGLEV = 4; privmsg(s_WebbieServ, u->nick, "You sucessfully set %s logging to FULL.", s_WebbieServ); wallops(s_WebbieServ, "%s set sucessfully set %s logging to FULL.", u->nick, s_WebbieServ); return MOD_CONT; } } } return MOD_CONT; } int my_nickA(char *source, int ac, char **av) { User *u2; if (WebbieServLOGLEV > 3) { alog("[ircd_webbiecheck] - Hooked NICK/CLIENT Message"); } if (ac < 2) { return MOD_CONT; } if (WebbieServLOGLEV > 3) { alog("[ircd_webbiecheck] - Found a new user :D"); } #ifndef IRC_ULTIMATE3 if (*source) { return MOD_CONT; } #endif if (WebbieServLOGLEV > 3) { alog("[ircd_webbiecheck] - av0 %s av1 %s av2 %s", av[0], av[1], av[2] ); } if ((u2 = finduser(av[0]))) { if (donotchecktruea) { if (WebbieServLOGLEV > 2) { alog("[ircd_webbiecheck] Version Checking %s", u2->nick); } send_cmd(s_WebbieServ, "PRIVMSG %s :\1VERSION\1", u2->nick); } } else { if (WebbieServLOGLEV > 1) { alog("[ircd_webbiecheck] ERROR - could not find %s [Perhaps they Quit]", av[0]); } } return MOD_CONT; } /*-----------------------------------------------*/ int notice_and_set_modes_on_webbie(User *u) { char tsbuf[16]; char modes[6]; alog("\002%s\002 is a Webbie!", u->nick); #ifdef You_Are_Webbie1 privmsg(s_WebbieServ, u->nick, You_Are_Webbie1); #endif #ifdef You_Are_Webbie2 privmsg(s_WebbieServ, u->nick, You_Are_Webbie2); #endif #ifdef You_Are_Webbie3 privmsg(s_WebbieServ, u->nick, You_Are_Webbie3); #endif #ifdef You_Are_Webbie4 privmsg(s_WebbieServ, u->nick, You_Are_Webbie4); #endif #ifdef You_Are_Webbie5 privmsg(s_WebbieServ, u->nick, You_Are_Webbie5); #endif #ifdef You_Are_Webbie6 privmsg(s_WebbieServ, u->nick, You_Are_Webbie6); #endif #ifdef You_Are_Webbie7 privmsg(s_WebbieServ, u->nick, You_Are_Webbie7); #endif #ifdef You_Are_Webbie8 privmsg(s_WebbieServ, u->nick, You_Are_Webbie8); #endif #ifdef You_Are_Webbie9 privmsg(s_WebbieServ, u->nick, You_Are_Webbie9); #endif #ifdef You_Are_Webbie10 privmsg(s_WebbieServ, u->nick, You_Are_Webbie10); #endif #ifdef ModesToAdd snprintf(modes, sizeof(modes), "+%s", ModesToAdd); #if !defined(IRC_PTLINK) snprintf(tsbuf, sizeof(tsbuf), "%lu", u->timestamp); change_user_mode(u, modes, tsbuf); #else change_user_mode(u, modes, NULL); #endif #endif #ifdef ModesToTake snprintf(modes, sizeof(modes), "-%s", ModesToTake); #if !defined(IRC_PTLINK) snprintf(tsbuf, sizeof(tsbuf), "%lu", u->timestamp); change_user_mode(u, modes, tsbuf); #else change_user_mode(u, modes, NULL); #endif #endif return MOD_STOP; }