* 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)
* Fixed: Botnet auth messages now propagate correctly throughout the botnet
* Added: Newbie mode warnings about config/userfiles readable by others (exposing passwords)
* Fixed: Issue #25, clients lost when doing reset, no more
* 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)
{
*pp = chan->next;
purge_banlist(chan);
purge_linklist((void**)&chan->banlist);
purge_chanusers(chan);
delete_vars(chan->setting,CHANSET_SIZE);
Free(&chan->name);
@@ -350,20 +350,6 @@ void delete_modemask(Chan *chan, char *mask, int mode)
#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)
{
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)
{
nxt = sp->next;
Free((char**)&sp);
sp = nxt;
}
*list = NULL;
}
/*

View File

@@ -152,7 +152,6 @@ char *find_nuh(char *);
Ban *make_ban(Ban **, char *, char *, time_t);
void delete_ban(Chan *, char *);
void delete_modemask(Chan *, char *, int);
void purge_banlist(Chan *);
void channel_massmode(const Chan *, char *, int, char, char);
void channel_massunban(Chan *, char *, time_t);
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 *append_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 const int StrlenX(const char *, ...) __attr(CORE_SEG, __regparm(1));
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
debug("(do_clearqueue) purging sendq...\n");
#endif
purge_strplist(current->sendq);
current->sendq = NULL;
purge_linklist((void**)&current->sendq);
}
#endif /* GENCMD_C */

View File

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

View File

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

View File

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

View File

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

View File

@@ -269,6 +269,14 @@ void ec_ver(char *from, const char *to)
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
{
void (*func)(char *, const char *);
@@ -287,6 +295,7 @@ LS const struct
{ ec_server, "$server", 7 },
{ ec_up, "$up", 3 },
{ ec_ver, "$ver", 4 },
{ ec_guid, "$guid", 5 },
{ NULL, "", 0 },
};