/* Newbot next share? */ static void bot_nlinked(int idx, char *par) { char *newbot = NULL, *next = NULL, *p = NULL, s[1024] = "", x = 0, *vversion = NULL, *vcommit = NULL; int i, vlocalhub = 0; time_t vbuildts = 0L; bool bogus = 0; newbot = newsplit(&par); next = newsplit(&par); s[0] = 0; if (!next[0]) { putlog(LOG_BOTS, "*", "Invalid eggnet protocol from %s (zapfing)", dcc[idx].nick); simple_snprintf(s, sizeof(s), "Disconnected %s (invalid bot)", dcc[idx].nick); dprintf(idx, "error invalid eggnet protocol for 'nlinked'\n"); } else if ((in_chain(newbot)) || (!strcasecmp(newbot, conf.bot->nick))) { /* Loop! */ putlog(LOG_BOTS, "*", "Loop detected %s (mutual: %s)", dcc[idx].nick, newbot); simple_snprintf(s, sizeof(s), "Detected loop: two bots exist named %s: disconnecting %s", newbot, dcc[idx].nick); dprintf(idx, "error Loop (%s)\n", newbot); } if (!s[0]) { for (p = newbot; *p; p++) if ((*p < 32) || (*p == 127)) bogus = 1; i = nextbot(next); if (i != idx) bogus = 1; if (bogus) { putlog(LOG_BOTS, "*", "Bogus link notice from %s! (%s -> %s)", dcc[idx].nick, next, newbot); simple_snprintf(s, sizeof(s), "Bogus link notice from: %s Disconnected", dcc[idx].nick); dprintf(idx, "error Bogus link notice from (%s -> %s)\n", next, newbot); } } if (s[0]) { chatout("*** %s\n", s); botnet_send_unlinked(idx, dcc[idx].nick, s); dprintf(idx, "bye %s\n", s); killsock(dcc[idx].sock); lostdcc(idx); return; } x = par[0]; if (x) par++; else x = '-'; if (par[0]) newsplit(&par); /* vnum */ if (par[0]) vlocalhub = atoi(newsplit(&par)); if (par[0]) vbuildts = atol(newsplit(&par)); if (par[0]) vcommit = newsplit(&par); if (par[0]) vversion = newsplit(&par); botnet_send_nlinked(idx, newbot, next, x, vlocalhub, vbuildts, vcommit, vversion); if (x == '!') { if (conf.bot->hub) chatout("*** (%s) %s %s.\n", next, "Linked to", newbot); else chatout("*** %s linked to botnet.\n", newbot); x = '-'; } addbot(newbot, dcc[idx].nick, next, x, vlocalhub, vbuildts, vcommit, vversion ? vversion : (char *) ""); }
/* Newbot next share? */ static void bot_nlinked(int idx, char *par) { char *newbot, *next, *p, s[1024], x; int bogus = 0, i; struct userrec *u; newbot = newsplit(&par); next = newsplit(&par); s[0] = 0; if (!next[0]) { putlog(LOG_BOTS, "*", "Invalid eggnet protocol from %s (zapfing)", dcc[idx].nick); simple_sprintf(s, "%s %s (%s)", MISC_DISCONNECTED, dcc[idx].nick, MISC_INVALIDBOT); dprintf(idx, "error invalid eggnet protocol for 'nlinked'\n"); } else if ((in_chain(newbot)) || (!egg_strcasecmp(newbot, botnetnick))) { /* Loop! */ putlog(LOG_BOTS, "*", "%s %s (mutual: %s)", BOT_LOOPDETECT, dcc[idx].nick, newbot); simple_sprintf(s, "%s %s: disconnecting %s", MISC_LOOP, newbot, dcc[idx].nick); dprintf(idx, "error Loop (%s)\n", newbot); } if (!s[0]) { for (p = newbot; *p; p++) if ((*p < 32) || (*p == 127) || ((p - newbot) >= HANDLEN)) bogus = 1; i = nextbot(next); if (i != idx) bogus = 1; } if (bogus) { putlog(LOG_BOTS, "*", "%s %s! (%s -> %s)", BOT_BOGUSLINK, dcc[idx].nick, next, newbot); simple_sprintf(s, "%s: %s %s", BOT_BOGUSLINK, dcc[idx].nick, MISC_DISCONNECTED); dprintf(idx, "error %s (%s -> %s)\n", BOT_BOGUSLINK, next, newbot); } if (bot_flags(dcc[idx].user) & BOT_LEAF) { putlog(LOG_BOTS, "*", "%s %s (%s %s)", BOT_DISCONNLEAF, dcc[idx].nick, newbot, BOT_LINKEDTO); simple_sprintf(s, "%s %s (to %s): %s", BOT_ILLEGALLINK, dcc[idx].nick, newbot, MISC_DISCONNECTED); dprintf(idx, "error %s\n", BOT_YOUREALEAF); } if (s[0]) { chatout("*** %s\n", s); botnet_send_unlinked(idx, dcc[idx].nick, s); dprintf(idx, "bye %s\n", BOT_ILLEGALLINK); killsock(dcc[idx].sock); lostdcc(idx); return; } x = par[0]; if (x) par++; else x = '-'; #ifndef NO_OLD_BOTNET if (dcc[idx].u.bot->numver < NEAT_BOTNET) i = atoi(par); else #endif i = base64_to_int(par); botnet_send_nlinked(idx, newbot, next, x, i); if (x == '!') { chatout("*** (%s) %s %s.\n", next, NET_LINKEDTO, newbot); x = '-'; } addbot(newbot, dcc[idx].nick, next, x, i); check_tcl_link(newbot, next); u = get_user_by_handle(userlist, newbot); if (bot_flags(u) & BOT_REJECT) { botnet_send_reject(idx, botnetnick, NULL, newbot, NULL, NULL); putlog(LOG_BOTS, "*", "%s %s %s %s", BOT_REJECTING, newbot, MISC_FROM, dcc[idx].nick); } }