/** * Akills any user that joins defined channel. Used as a spambot trap! * * The ON?OFF switch is a bit of a hack. The module will kill anyone * that joins the trap channel (not IRCops) regarless on the switch. * What the switch really does, is create the trap channel and keep * it open and visible. * **/ #include "module.h" #define TRAPCHAN "#AKill" /* Trap channel name */ #define TRAPEXPI "86400" /* One day: 24*60*60 */ #define TRAPTOPI "Spambot trap channel. \002Do not join!!!\002" #define TRAPREAS "[auto] No SPAM bots allowed on this network!" #define AUTHOR "dengel" #define VERSION "0.2" int myJoin(char *source, int ac, char **av); int cs_joinkill(User *u); int AnopeInit(int argc, char **argv) { Command *c; Message *msg=NULL,*msg2=NULL; c = createCommand("joinkill", cs_joinkill, is_services_admin, -1, -1, -1, -1, -1); msg = createMessage("JOIN",myJoin); alog("cs_joinkill.so: Added Message handler for 'JOIN' Status: %d", moduleAddMessage(msg,MOD_TAIL)); alog("cs_joinkill.so: Add Command 'joinkill' Status: %d", moduleAddCommand(CHANSERV, c, MOD_HEAD)); moduleAddAuthor(AUTHOR); moduleAddVersion(VERSION); } int myJoin(char *source, int ac, char **av) { char mask[USERMAX + HOSTMAX + 2]; time_t expires; char *newchan = sstrdup(av[0]); User *u; if(stricmp(av[0], TRAPCHAN) != 0) { return MOD_CONT; } if ((!*source) || (!newchan) || (ac < 1) || (readonly)) { return MOD_CONT; } if (!stristr(av[0],"#")) { return MOD_CONT; } u = finduser(source); if (!u || is_oper(u)) { return MOD_CONT; } expires = dotime(TRAPEXPI); expires += time(NULL); strncpy(mask, "*@", 3); /* Use *@" for the akill's, */ strncat(mask, u->host, HOSTMAX); add_akill(NULL, mask, "OperServ", expires, TRAPREAS); check_akill(u->nick, u->username, u->host, NULL, NULL); alog("cs_joinkill: Akill for %s (%s)", source, mask) ; if (WallOSAkill) { wallops(s_OperServ, "cs_joinkill: Akill %s (%s) on trapchan (%s)", source, mask, newchan); } free(newchan); return MOD_CONT; } int cs_joinkill(User * u) { char *option = strtok(NULL,""); Channel *c; if(option) { char *newchan = sstrdup(TRAPCHAN); if(stricmp(option,"ON")==0) { #if defined(IRC_BAHAMUT) send_cmd(s_ChanServ, "SJOIN %lu %s", (c ? c->creation_time : time(NULL)), newchan); #elif defined(IRC_HYBRID) send_cmd(NULL, "SJOIN %ld %s + :@%s", time(NULL), chan, s_ChanServ); #else send_cmd(s_ChanServ, "JOIN %s", newchan); #endif send_cmd(s_ChanServ, "MODE %s +o %s %lu", newchan, s_ChanServ, time(NULL)); send_cmd(s_ChanServ, "MODE %s -psi", newchan); send_cmd(s_ChanServ, "TOPIC %s :%s", newchan, TRAPTOPI); notice(s_ChanServ,u->nick,"Trap channel \002%s\002 turned \002ON\002.",newchan); } else if(stricmp(option,"OFF")==0) { send_cmd(s_ChanServ, "PART %s", newchan); notice(s_ChanServ,u->nick,"Trap channel \002%s\002 turned \002OFF\002.",newchan); } else { notice(s_ChanServ,u->nick,"Syntax: /msg ChanServ JOINKILL [\002ON\002|\002OFF\002]"); } free(newchan); } else { notice(s_ChanServ,u->nick,"Syntax: /msg ChanServ JOINKILL [\002ON\002|\002OFF\002]"); } return MOD_CONT; } void AnopeFini(void) { send_cmd(s_ChanServ, "PART %s", TRAPCHAN); alog("Unloading module cs_joinkill.so"); }