#include #include #include #include #include "config.h" char UPLINK[255]; #ifdef USE_DCC struct aDccClient MyClient[MAXCLIENTS]; #endif char *snoop[]={"FA-Q","leet ","haxor",""}; int SNOOP=0; extern int DccCtr; /* from socket.c */ char *SuspendChan[MAXSUSPENDOPER]; time_t SuspendChanTime[MAXSUSPENDOPER]; char *SuspendOper[MAXSUSPENDOPER]; time_t SuspendOperTime[MAXSUSPENDOPER]; extern char *mynicks[]; char *NoGlineHost[MAXNOGLINES],*GlineHost[MAXGLINEHOST]; char *MultiUserHost[MAXMHOST],*SingleUserHost[MAXMHOST]; char sockbuf[MAXBUFSIZE],buf[MAXBUFSIZE],storebuf[MAXBUFSIZE]; char input_buffer[3][3*MAXBUFSIZE],*input_start,*input_end; char *token[256]; int sevsck,botsck; FILE *fludfile = NULL; char lastkill[255]="\0"; extern char *operchan[],*invitekiller[],*invitehosts[],*killchan[]; char LastKlr[20]; long D_JOIN=0,D_NICK=0,D_PART=0,D_MODE=0,D_KICK=0,D_SERVER=0,D_QUIT=0,D_USER=0; long N_JOIN=0,N_NICK=0,N_PART=0,N_MODE=0,N_KICK=0,N_SERVER=0,N_QUIT=0,N_USER=0; long D_TOTAL=0,N_TOTAL=0,D_SQUIT,N_SQUIT,N_OTHER=0,D_OTHER=0; long D_KILL=0,N_KILL=0,FLOODLOGS=0; long D_TOPIC=0,N_TOPIC=0; int CLONE_UP=3,CLONE_LO=3,CLONE_DIG=3,LOGHOST=0; int DO_AUTOKICK=0,DO_CORE=1; time_t S_TIME=0; int MAX_SESSIONS=5,MAX_ALLOWED=8; time_t NOWTIME,BotIdle,ServIdle; int SITE_CLONE=3,KILL_NICKFLOOD=1,num_servs=0; char server_list[40][100]; char controlbot[255]; int NETBURST=0,FLOODPROTECTION=1; main(int argc, char **argv) { int loop,loop2; char *envptr; if (argc <2) goto_bg(); strcpy(UPLINK,MYSERVER); if( (envptr=getenv("UPLINK")) != NULL) strcpy(UPLINK,envptr); #ifdef USE_DCC for(loop=0;loop 2) do_count(); k=chk_num(0); if(temp=strchr(token[0],'!')) { *temp='\0'; fromhost=temp+1; if((k>3) && (FLOODPROTECTION)) FloodProtect(token[0]+1,token[2]); parse(fromhost); continue; } nbc=0; if((!NETBURST) && (k>3) && ((!strcmp(token[nbc++],"SERVER")) || (!strcmp(token[nbc++],"SERVER")) )) { if(!NETBURST) { sprintf(buf,":%s PRIVMSG #uworld.floods :PROCESSING NETBURST %d\n", CHANSVR,nbc); writeln(sevsck,buf); } NETBURST=nbc; } if((!NETBURST) && (FLOODPROTECTION) && (!strchr(token[0],'.'))) { if((k>3) && ((*token[1]=='P') || (*token[1]=='I') || (!strncmp(token[1],"NO",2)))) FloodProtect(token[0]+1,token[2]); } if((!strcmp(token[0],"ERROR")) && (!strcmp(token[1],":Closing"))) { if(sckfd==sevsck) { close(sevsck); writelog("SQUIT"); destroy_nickhash(); squit_loop++; if(squit_loop > 5) { writelog("EXITING SQUIT LOOP"); exit(1); } if(NOWTIME - last_squit < 120) continue; last_squit = NOWTIME; if(k>5) { *token[5]++; if(*token[5] != '!') { clear_clients(); sevsck=sev_login(UPLINK); do_bots(); continue; } } } else /* client squit */ { close(botsck); botsck=bot_login(UPLINK); continue; } } if(k > 3) { if(!strcmp(token[3],":remakeuworld")) { close( botsck); botsck=bot_login(UPLINK); } else if(atoi(token[1])) { sevnum(atoi(token[1])); continue; } else if(!match(token[1],"KILL")) { record_kill(); continue; } else if(strcasecmp(token[0],":helpbot")) { if(strlen(token[3])>80) continue; if(strchr(token[3],'@')) continue;/* Should stop the silence bug */ if(!match(token[2],IRCHELP)) {do_helpirc(sevsck); continue; } else if(!strcasecmp(token[2],controlbot)) { OperCom(token[0]+1); continue; } else if( (*token[1]=='P') || (*token[1]=='I') || (!strncmp(token[1],"NO",2))) { for(ctr=0;*invitekiller[ctr];ctr++) { if(!strcasecmp(token[2],invitekiller[ctr])) { GetFromhost(token[0]+1,killbuf); sprintf(tempbuf,"MMG[%d] <%s!%s>",ctr,token[0]+1,killbuf); for(ctr=3;token[ctr];ctr++) { strcat(tempbuf," "); strcat(tempbuf,token[ctr]); } strcat(tempbuf,"\n"); mmg_log(tempbuf); if((!strcasecmp(lastkill,killbuf)) && (strcasecmp(LastKlr,token[2]))) { /*We've heard from this idiot already */ char ttbuf[1024],*tpt; tpt=killbuf; while( (*tpt=='*') ) tpt++; if( (!match("*telnet@*.wildstar.net",tpt)) || (!match("*telnet@*.wildstar.com",tpt)) ) { dump_nicklist(token[0]+1,"TELNET.FLOODERS"); } else { /* sprintf(ttbuf,"*%s",killbuf); do_gline(ttbuf,"MASSMESSAGE", "Unsolicited Mass Advertisements are prohibited - [Auto]", 3600); */ sprintf(ttbuf, "KILL %s Uworld!uworld.undernet.org :MASS MESSAGE KILL FROM %s\n", token[0]+1,killbuf); writeln(sevsck,ttbuf); } } strcpy(lastkill,killbuf); strcpy(LastKlr,token[2]); DccGlobal(tempbuf,DCC_MMG); sprintf(buf,":%s PRIVMSG #uworld.floods :%s",CHANSVR,tempbuf); writeln(sevsck,buf); break; } } continue; } else if(!strcasecmp(token[2],"chansvr")) { sprintf(buf, ":Chansvr NOTICE %s :Please use %s\n",token[0]+1,controlbot); writeln(sevsck,buf); continue; } else if(!match(token[2],USHELP)) {do_ushelp(sevsck); continue; } else if((!match(token[2],HELPBOT)) && (!match(token[3],":help"))) {do_helpem(sevsck); continue; } } } if(!helpsv) sevstuff(sevsck,fromhost); } /* END BUFFER INPUT */ strcpy(input_buffer[bf],input_start); } finishline(start) int start; { int i; i=start; while (token[i]) printf(" %s",token[i++]); } int chk_num(int start) { int j; j=start; while (token[j]) { j++; } return j; } do_scmd(int sck) {int i,j,k; char temp[512]; if(!i) i = 4; j=chk_num(0); strcpy(temp,""); if (j>4) for(i=4;i 8) { sprintf(buf,"NICK %s :1\n",token[0]); writeln(sevsck,buf); counter = 0; } if(counter = 5) { sprintf(buf,"KILL %s :GLOBAL KILL LINE \n",token[0]); writeln(sevsck,buf); } } do_count() { if(!strcmp(token[1],"KICK")) { D_KICK += strlen(storebuf); N_KICK++; } else if(!strcmp(token[1],"JOIN")) { D_JOIN += strlen(storebuf); N_JOIN++; } else if(!strcmp(token[1],"PART")) { D_PART += strlen(storebuf); N_PART++; } else if(!strcmp(token[1],"MODE")) { D_MODE += strlen(storebuf); N_MODE++; if((NETBURST) && strchr(token[0],'.')) { NETBURST=0; sprintf(buf,":%s PRIVMSG #uworld.floods :Netburst Complete\n", CHANSVR); writeln(sevsck,buf); } } else if(!strcmp(token[1],"SQUIT")) { D_SQUIT += strlen(storebuf); N_SQUIT++; } else if(!strcmp(token[1],"QUIT")) { D_QUIT += strlen(storebuf); N_QUIT++; } else if(!strcmp(token[1],"SERVER")) { D_SERVER += strlen(storebuf); N_SERVER++; } else if(!strcmp(token[1],"USER")) { D_USER += strlen(storebuf); N_USER++; } else if(!strcmp(token[1],"NICK")) { D_NICK += strlen(storebuf); N_NICK++; } else if(!strcmp(token[0],"NICK")) { D_NICK += strlen(storebuf); N_NICK++; } else if(!strcmp(token[1],"KILL")) { D_KILL += strlen(storebuf); N_KILL++; } else if(!strcmp(token[1],"TOPIC")) { D_TOPIC += strlen(storebuf); N_TOPIC++; } else { N_OTHER++; D_OTHER += strlen(storebuf); } } int load_serv(char *file) { FILE *infile; char line[500]; if( (infile=fopen(file,"r")) == NULL) return; for(num_servs=0;fgets(line,99,infile);num_servs++) { line[strlen(line)-1]='\0'; strcpy(server_list[num_servs],line); } fclose(infile); return; } int join_opchan(char *channel) { int loop; for(loop=0;operchan[loop];loop++) { if(strcasecmp(operchan[loop],channel)) continue; sprintf(buf,":CHANSVR JOIN #%s\n",operchan[loop]); writeln(sevsck,buf); sprintf(buf,"MODE #%s +pnotil Chansvr 1\n",operchan[loop]); writeln(sevsck,buf); } }