Permalink
Browse files

Fix addbot Tcl command. Fixes #470

Found by: Geo
Patch by: Geo
Fixes: #470

In short, fix Tcl command addbot inputs so the following three formats all work:
  - ipaddress/botport/userport
  - ipv4address:botport/userport    [marked as DEPRECATED]
  - [ipv6address]:botport/userport  [marked as DEPRECATED]

* Remove old +bot syntax (:) from BOTNET docs
* Allow ipaddress/botport/userport format; allow ipv4address:botport/userport format; allow [ipv6address]:botport/userport format
* Update tcl-commands.doc
* Prevent IPv4 address from being added inside []s
Also create user entry only after validating address strings
  • Loading branch information...
vanosg committed Nov 12, 2017
1 parent 82dd0b4 commit 5d9da79dd6b8b9a8f392701dbdd343e8dae73644
Showing with 51 additions and 17 deletions.
  1. +6 −6 doc/sphinx_source/mainDocs/botnet.rst
  2. +5 −1 doc/sphinx_source/mainDocs/tcl-commands.rst
  3. +38 −8 src/tcluser.c
  4. +2 −2 src/version.h
@@ -1,5 +1,5 @@
Botnet Sharing and Linking
Last revised: June 29, 2016
Last revised: Nov 09, 2017
==========================
Botnet Sharing and Linking
@@ -121,10 +121,10 @@ Here is an example scenario:
BotA is on lame.org listening on port 3333, and BotB is on irc.org
listening on port 4444. First, you have to add each Bot to the other's
userfile. On BotA, you would type '.+bot BotB irc.org:4444'. If BotB is
userfile. On BotA, you would type '.+bot BotB irc.org 4444'. If BotB is
on a common channel with BotA, BotB's hostmask is automatically added.
Otherwise, you have to add the hostmask manually with the '.+host'
command. On BotB, you would type '.+bot BotA lame.org:3333'.
command. On BotB, you would type '.+bot BotA lame.org 3333'.
At this point, you can link the two bots by typing '.link BotA' on BotB (or '.link BotB' on BotA). The bots will now give themselves random passwords which are *not* stored encrypted in the userfile. Note that you can link as many bots as you wish to your botnet.
@@ -213,7 +213,7 @@ Making bots share user records
On Lamestbot::
.+bot Lameshare eggdrop.com:3333
.+bot Lameshare eggdrop.com 3333
This command adds a user record to
Lamestbot for Lameshare. Lameshare is running from eggdrop.com and is
@@ -233,7 +233,7 @@ Making bots share user records
On Lameshare::
.+bot Lamestbot best.com:3333/5555
.+bot Lamestbot best.com 3333/5555
Again this will add a user on
Lameshare called Lamestbot with the domain of best.com. The bot has
@@ -258,7 +258,7 @@ Making bots share user records
On Lamestbot::
.+bot beldin llama.com:3333
.+bot beldin llama.com 3333
.botattr beldin s|s #eggdrop
@@ -322,7 +322,11 @@ adduser <handle> [hostmask]
^^^^^^^^^^^^^^^^^^^^^^^^^
addbot <handle> <address>
^^^^^^^^^^^^^^^^^^^^^^^^^
Description: adds a new bot to the userlist with the handle and botaddress given (with no password and no flags)
Description: adds a new bot to the userlist with the handle and botaddress given (with no password and no flags). <address> format is one of:
- ipaddress/botport/userport
- ipv4address:botport/userport [DEPRECATED]
- [ipv6address]:botport/userport [DEPRECATED]
Returns: 1 if successful; 0 if the bot already exists
View
@@ -26,6 +26,7 @@
#include "chan.h"
#include "tandem.h"
#include "modules.h"
#include "string.h"
extern Tcl_Interp *interp;
extern struct userrec *userlist;
@@ -294,6 +295,8 @@ static int tcl_addbot STDVAR
{
struct bot_addr *bi;
char *p, *q;
int i, colon=0, braced = 0, ipv6 = 0, count = 0;
BADARGS(3, 3, " handle address");
@@ -307,20 +310,47 @@ static int tcl_addbot STDVAR
get_user_by_handle(userlist, argv[1]))
Tcl_AppendResult(irp, "0", NULL);
else {
userlist = adduser(userlist, argv[1], "none", "-", USER_BOT);
bi = user_malloc(sizeof(struct bot_addr));
#ifdef TLS
bi->ssl = 0;
for (i=0; argv[2][i]; i++) {
if (argv[2][i] == ':') {
count++;
colon=i;
}
if (argv[2][i] == ']') {
braced = i;
}
}
if (count > 1) {
ipv6 = 1;
}
if ((!ipv6 && braced)
#ifndef IPV6
|| (ipv6)
#endif
#ifdef IPV6
if ((q = strchr(argv[2], '/'))) {
) {
Tcl_AppendResult(irp, "0", NULL);
return TCL_OK;
}
/* Check that the char following the / is not null */
if ((q = strrchr(argv[2], '/'))) {
if (!q[1]) {
*q = 0;
q = 0;
}
} else
}
if (!ipv6) {
if (!(q = strchr(argv[2], ':'))) {
q = strchr(argv[2], '/');
}
} else if (braced && (colon > braced)) {
q = strrchr(argv[2], ':');
} else {
q = strchr(argv[2], '/');
}
userlist = adduser(userlist, argv[1], "none", "-", USER_BOT);
bi = user_malloc(sizeof(struct bot_addr));
#ifdef TLS
bi->ssl = 0;
#endif
q = strchr(argv[2], ':');
if (!q) {
bi->address = user_malloc(strlen(argv[2]) + 1);
strcpy(bi->address, argv[2]);
View
@@ -27,5 +27,5 @@
*/
#define EGG_STRINGVER "1.8.2"
#define EGG_NUMVER 1080207
#define EGG_PATCH "sslfatal"
#define EGG_NUMVER 1080208
#define EGG_PATCH "addbot"

0 comments on commit 5d9da79

Please sign in to comment.