egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

a bug in botnet.c:botlink() code

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
amir
Guest





PostPosted: Tue Mar 05, 2002 8:10 pm    Post subject: Reply with quote

when botlink() is called with:

linker, idx, bot.


linker which is a string which represented the user who 'started' the linked is passed while the dns resolve AS IS which is dangerous, only after dns resolve is successful linker string is being copied over the dcc memory, only then its safe.


this bug is harmful, only when botlink() is called from bot_link(), which in there 'linker' comes from a line string (from botnet protocol)


I would advise using nmalloc(strlen(linker)+1) and strcpy()

(still using cptr to pass the pointer)


on sucessful dns resolve, copy and free

on failure dns resolve, just free


I have confirmed this bug to exists on bug eggdrop 1.6 and eggdrop 1.7 CVS trees.

--- botnet.c.orig Thu Feb 21 16:33:45 2002
+++ botnet.c Wed Mar 6 09:01:51 2002
@@ -1033,7 +1033,8 @@
strcpy(dcc[i].nick, nick);
strcpy(dcc[i].host, bi->address);
dcc[i].u.dns->ibuf = idx;
- dcc[i].u.dns->cptr = linker;
+ dcc[i].u.dns->cptr = get_data_ptr(strlen(linker) + 1);
+ strcpy(dcc[i].u.dns->cptr, linker);
dcc[i].u.dns->host = get_data_ptr(strlen(dcc[i].host) + 1);
strcpy(dcc[i].u.dns->host, dcc[i].host);
dcc[i].u.dns->dns_success = botlink_resolve_success;
@@ -1053,6 +1054,7 @@
putlog(LOG_BOTS, "*", DCC_LINKFAIL, dcc[i].nick);
strcpy(s, dcc[i].nick);
+ nfree(dcc[i].u.dns->cptr);
lostdcc(i);
autolink_cycle(s); /* Check for more auto-connections */
}
@@ -1066,6 +1068,7 @@
changeover_dcc(i, &DCC_FORK_BOT, sizeof(struct bot_info));
dcc[i].timeval = now;
strcpy(dcc[i].u.bot->linker, linker);
+ nfree(linker);
strcpy(dcc[i].u.bot->version, "(primitive bot)");
dcc[i].u.bot->numver = idx;
dcc[i].u.bot->port = dcc[i].port; /* Remember where i started */


[ This Message was edited by: amir on 2002-03-06 02:04 ]
Back to top
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber