* Fixed: Botnet auth messages now propagate correctly throughout the botnet

This commit is contained in:
joonicks
2018-04-21 01:32:53 +02:00
parent 808269bb68
commit b4c6efaf0e
10 changed files with 43 additions and 49 deletions

View File

@@ -1,5 +1,6 @@
3.1 -- WORK IN PROGRESS (~April, 2018) 3.1 -- WORK IN PROGRESS (~April, 2018)
* Fixed: Botnet auth messages now propagate correctly throughout the botnet
* Added: Newbie mode warnings about config/userfiles readable by others (exposing passwords) * Added: Newbie mode warnings about config/userfiles readable by others (exposing passwords)
* Fixed: Issue #25, clients lost when doing reset, no more * Fixed: Issue #25, clients lost when doing reset, no more
* Fixed: compiler warnings and missing defines/conflicting defines with certain options * Fixed: compiler warnings and missing defines/conflicting defines with certain options

View File

@@ -97,7 +97,7 @@ void remove_chan(Chan *chan)
if (*pp == chan) if (*pp == chan)
{ {
*pp = chan->next; *pp = chan->next;
purge_banlist(chan); purge_linklist((void**)&chan->banlist);
purge_chanusers(chan); purge_chanusers(chan);
delete_vars(chan->setting,CHANSET_SIZE); delete_vars(chan->setting,CHANSET_SIZE);
Free(&chan->name); Free(&chan->name);
@@ -350,20 +350,6 @@ void delete_modemask(Chan *chan, char *mask, int mode)
#endif /* IRCD_EXTENSIONS */ #endif /* IRCD_EXTENSIONS */
void purge_banlist(Chan *chan)
{
Ban *ban,*next;
ban = chan->banlist;
while(ban)
{
next = ban->next;
Free((char**)&ban);
ban = next;
}
chan->banlist = NULL;
}
void channel_massmode(const Chan *chan, char *pattern, int filtmode, char mode, char typechar) void channel_massmode(const Chan *chan, char *pattern, int filtmode, char mode, char typechar)
{ {
ChanUser *cu; ChanUser *cu;

View File

@@ -194,18 +194,20 @@ Strp *prepend_strp(Strp **pp, const char *string)
} }
/* /*
* Free() a chain of Strp's * Free() a whole linked list of any suitable type (Strp, Banlist)
*/ */
void purge_strplist(Strp *sp) void purge_linklist(void **list)
{ {
Strp *nxt; Strp *sp,*nxt;
sp = *list;
while(sp) while(sp)
{ {
nxt = sp->next; nxt = sp->next;
Free((char**)&sp); Free((char**)&sp);
sp = nxt; sp = nxt;
} }
*list = NULL;
} }
/* /*

View File

@@ -152,7 +152,6 @@ char *find_nuh(char *);
Ban *make_ban(Ban **, char *, char *, time_t); Ban *make_ban(Ban **, char *, char *, time_t);
void delete_ban(Chan *, char *); void delete_ban(Chan *, char *);
void delete_modemask(Chan *, char *, int); void delete_modemask(Chan *, char *, int);
void purge_banlist(Chan *);
void channel_massmode(const Chan *, char *, int, char, char); void channel_massmode(const Chan *, char *, int, char, char);
void channel_massunban(Chan *, char *, time_t); void channel_massunban(Chan *, char *, time_t);
LS ChanUser *find_chanuser(Chan *, const char *); LS ChanUser *find_chanuser(Chan *, const char *);
@@ -280,7 +279,7 @@ LS void Free(char **) __attr(CORE_SEG, __regparm(1));
LS Strp *make_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2)); LS Strp *make_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2));
LS Strp *append_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2)); LS Strp *append_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2));
LS Strp *prepend_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2)); LS Strp *prepend_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2));
LS void purge_strplist(Strp *) __attr(CORE_SEG, __regparm(1)); LS void purge_linklist(void **) __attr(CORE_SEG, __regparm(1));
LS void dupe_strp(Strp *, Strp **) __attr(CORE_SEG, __regparm(2)); LS void dupe_strp(Strp *, Strp **) __attr(CORE_SEG, __regparm(2));
LS const int StrlenX(const char *, ...) __attr(CORE_SEG, __regparm(1)); LS const int StrlenX(const char *, ...) __attr(CORE_SEG, __regparm(1));
LS const int Strlen2(const char *, const char *) __attr(CORE_SEG, __regparm(2)); LS const int Strlen2(const char *, const char *) __attr(CORE_SEG, __regparm(2));

View File

@@ -689,8 +689,7 @@ void do_clearqueue(COMMAND_ARGS)
#ifdef DEBUG #ifdef DEBUG
debug("(do_clearqueue) purging sendq...\n"); debug("(do_clearqueue) purging sendq...\n");
#endif #endif
purge_strplist(current->sendq); purge_linklist((void**)&current->sendq);
current->sendq = NULL;
} }
#endif /* GENCMD_C */ #endif /* GENCMD_C */

View File

@@ -64,32 +64,35 @@ LS struct
*/ */
typedef struct LinkCmd typedef struct LinkCmd
{ {
char c1; char cmd[2];
char c2;
void (*func)(BotNet *, char *); void (*func)(BotNet *, char *);
int relay;
} LinkCmd; } LinkCmd;
#define RELAY_YES 1
#define RELAY_NO 0
LS const LinkCmd basicProto[] = LS const LinkCmd basicProto[] =
{ {
{ 'B', 'A', basicAuth }, { "BA", basicAuth, RELAY_NO },
{ 'B', 'B', basicBanner }, { "BB", basicBanner, RELAY_NO },
{ 'B', 'K', basicAuthOK }, { "BK", basicAuthOK, RELAY_NO },
{ 'B', 'L', basicLink }, { "BL", basicLink, RELAY_NO },
{ 'B', 'Q', basicQuit }, { "BQ", basicQuit, RELAY_NO },
{ 'C', 'O', netchanNeedop }, { "CO", netchanNeedop, RELAY_YES },
#ifdef SUPPRESS #ifdef SUPPRESS
{ 'C', 'S', netchanSuppress }, // experimental command supression { "CS", netchanSuppress, RELAY_YES }, // experimental command supression
#endif /* SUPPRESS */ #endif /* SUPPRESS */
{ 'P', 'A', partyAuth }, { "PA", partyAuth, RELAY_YES },
#ifdef REDIRECT #ifdef REDIRECT
{ 'P', 'C', partyCommand }, { "PC", partyCommand, RELAY_NO },
#endif /* REDIRECT */ #endif /* REDIRECT */
{ 'P', 'M', partyMessage }, { "PM", partyMessage, RELAY_NO },
{ 'U', 'T', ushareTick }, { "UT", ushareTick, RELAY_NO },
{ 'U', 'U', ushareUser }, { "UU", ushareUser, RELAY_NO },
{ 'U', 'D', ushareDelete }, { "UD", ushareDelete, RELAY_YES },
{ 0, 0, NULL }, { "\0\0", NULL, RELAY_NO },
}; };
LS int deadlinks = FALSE; LS int deadlinks = FALSE;
@@ -844,8 +847,6 @@ void netchanNeedop(BotNet *source, char *rest)
if (errno || guid < 1 || !channel) if (errno || guid < 1 || !channel)
return; return;
botnet_relay(source,"CO%i %s\n",guid,channel);
for(bn=botnetlist;bn;bn=bn->next) for(bn=botnetlist;bn;bn=bn->next)
{ {
if (bn->status != BN_LINKED) if (bn->status != BN_LINKED)
@@ -866,8 +867,6 @@ void netchanSuppress(BotNet *source, char *rest)
const char *cmd; const char *cmd;
int crc,i,j; int crc,i,j;
botnet_relay(source,"CS%s\n",rest);
cmd = chop(&rest); cmd = chop(&rest);
// convert command to const command // convert command to const command
@@ -1339,8 +1338,6 @@ void ushareDelete(BotNet *bn, char *rest)
} }
} }
} }
unchop(orig,rest);
botnet_relay(bn,"UD%s\n",orig);
} }
/* /*
@@ -1383,8 +1380,10 @@ not_a_botnet_connection:
for(i=0;basicProto[i].func;i++) for(i=0;basicProto[i].func;i++)
{ {
if (basicProto[i].c1 == rest[0] && basicProto[i].c2 == rest[1]) if (basicProto[i].cmd[0] == rest[0] && basicProto[i].cmd[1] == rest[1])
{ {
if (basicProto[i].relay == RELAY_YES)
botnet_relay(bn,"%s\n",rest);
basicProto[i].func(bn,rest+2); basicProto[i].func(bn,rest+2);
return; return;
} }

View File

@@ -111,7 +111,7 @@ void parse_join(char *from, char *rest)
current->lastchanban = 0; current->lastchanban = 0;
#endif /* CHANBAN */ #endif /* CHANBAN */
to_server("WHO %s\nMODE %s\nMODE %s b\n",rest,rest,rest); to_server("WHO %s\nMODE %s\nMODE %s b\n",rest,rest,rest);
purge_banlist(chan); purge_linklist((void**)&chan->banlist);
purge_chanusers(chan); purge_chanusers(chan);
#ifdef STATS #ifdef STATS

View File

@@ -406,8 +406,7 @@ void urlcapture(const char *rest)
{ {
if (n <= 0) if (n <= 0)
{ {
purge_strplist(sp->next); purge_linklist((void**)&sp->next);
sp->next = NULL;
return; return;
} }
n--; n--;

View File

@@ -178,7 +178,7 @@ int read_bigcharset(char *fname)
bigc = orig_fontlist; bigc = orig_fontlist;
orig_fontlist = bigc->next; orig_fontlist = bigc->next;
if (bigc->data) if (bigc->data)
purge_strplist(bigc->data); purge_linklist((void**)&bigc->data);
Free((char**)&bigc); Free((char**)&bigc);
} }

View File

@@ -269,6 +269,14 @@ void ec_ver(char *from, const char *to)
nobo_strcpy(VERSION); nobo_strcpy(VERSION);
} }
void ec_guid(char *from, const char *to)
{
char tmp[32];
sprintf(tmp,"%i",current->guid);
nobo_strcpy(tmp);
}
LS const struct LS const struct
{ {
void (*func)(char *, const char *); void (*func)(char *, const char *);
@@ -287,6 +295,7 @@ LS const struct
{ ec_server, "$server", 7 }, { ec_server, "$server", 7 },
{ ec_up, "$up", 3 }, { ec_up, "$up", 3 },
{ ec_ver, "$ver", 4 }, { ec_ver, "$ver", 4 },
{ ec_guid, "$guid", 5 },
{ NULL, "", 0 }, { NULL, "", 0 },
}; };