2018 progress

This commit is contained in:
joonicks
2018-03-09 01:29:18 +01:00
parent e5ad9bb990
commit f9d37e65a4
13 changed files with 186 additions and 456 deletions

View File

@@ -447,9 +447,3 @@ listcheck:
}
to_user(from,"You are now officially immortal");
}
#ifdef MD5CRYPT
void do_md5(COMMAND_ARGS)
{
}
#endif /* MD5CRYPT */

View File

@@ -138,7 +138,11 @@ int write_session(void)
#ifdef RAWDNS
Strp *p;
#endif /* RAWDNS */
#ifdef ALIAS
Alias *alias;
#endif /* ALIAS */
Server *sp;
Spy *spy;
Chan *chan;
Mech *bot;
UniVar *varval;
@@ -155,6 +159,83 @@ int write_session(void)
to_file(sf,"dnsserver %s\n",inet_ntoa(ia_ns[j]));
#endif /* RAWDNS */
to_file(sf,"set ctimeout %i\n",ctimeout);
for(sp=serverlist;sp;sp=sp->next)
{
to_file(sf,"server %s %i %s\n",sp->name,(sp->port) ? sp->port : 6667,
(sp->pass[0]) ? sp->pass : "");
}
#ifdef BOTNET
if (linkpass)
to_file(sf,"set linkpass %s\n",linkpass);
if (linkport)
to_file(sf,"set linkport %i\n",linkport);
if (autolink)
to_file(sf,"set autolink 1\n");
for(cfg=netcfglist;cfg;cfg=cfg->next)
{
to_file(sf,"link %i %s",cfg->guid,(cfg->pass) ? cfg->pass : MATCH_ALL);
if (cfg->host)
to_file(sf," %s %i",cfg->host,cfg->port);
to_file(sf,"\n");
}
#endif /* BOTNET */
#ifdef BOUNCE
if (bounce_port)
to_file(sf,"set bncport %i\n",bounce_port);
#endif /* BOUNCE */
#ifdef WEB
if (webport)
to_file(sf,"set webport %i\n",webport);
#endif /* WEB */
#ifdef UPTIME
if (uptimehost && Strcasecmp(uptimehost,defaultuptimehost))
to_file(sf,"set uphost %s\n",uptimehost);
if (uptimeport)
to_file(sf,"set upport %i\n",uptimeport);
if (uptimenick)
to_file(sf,"set upnick %s\n",uptimenick);
#endif /* UPTIME */
#ifdef TRIVIA
if (triv_qfile)
to_file(sf,"set qfile %s\n",triv_qfile);
to_file(sf,"set qdelay %i\n",triv_qdelay);
to_file(sf,"set qchar %c\n",triv_qchar);
#endif /* TRIVIA */
#ifdef SEEN
if (seenfile)
to_file(sf,"set seenfile %s\n",seenfile);
#endif /* SEEN */
#ifdef DYNCMD
/*
* because of "chaccess XXX disable" its best to save chaccess last
*/
for(j=0;mcmd[j].name;j++)
{
if (acmd[j] != mcmd[j].defaultaccess)
{
if (acmd[j] == 250)
to_file(sf,"chaccess %s disable\n",mcmd[j].name);
else
to_file(sf,"chaccess %s %i\n",mcmd[j].name,(int)acmd[j]);
}
}
#endif /* DYNCMD */
#ifdef ALIAS
for(alias=aliaslist;alias;alias=alias->next)
{
to_file(sf,"alias %s %s\n",alias->alias,alias->format);
}
#endif /* ALIAS */
for(bot=botlist;bot;bot=bot->next)
{
to_file(sf,"nick %i %s\n",bot->guid,bot->wantnick);
@@ -214,77 +295,20 @@ int write_session(void)
}
}
}
}
to_file(sf,"set ctimeout %i\n",ctimeout);
for(sp=serverlist;sp;sp=sp->next)
{
to_file(sf,"server %s %i %s\n",sp->name,(sp->port) ? sp->port : 6667,
(sp->pass[0]) ? sp->pass : "");
}
#ifdef TRIVIA
if (triv_qfile)
to_file(sf,"set qfile %s\n",triv_qfile);
to_file(sf,"set qdelay %i\n",triv_qdelay);
to_file(sf,"set qchar %c\n",triv_qchar);
#endif /* TRIVIA */
#ifdef UPTIME
if (uptimehost && Strcasecmp(uptimehost,defaultuptimehost))
to_file(sf,"set uphost %s\n",uptimehost);
if (uptimeport)
to_file(sf,"set upport %i\n",uptimeport);
if (uptimenick)
to_file(sf,"set upnick %s\n",uptimenick);
#endif /* UPTIME */
#ifdef SEEN
if (seenfile)
to_file(sf,"set seenfile %s\n",seenfile);
#endif /* SEEN */
#ifdef BOTNET
if (linkpass)
to_file(sf,"set linkpass %s\n",linkpass);
if (linkport)
to_file(sf,"set linkport %i\n",linkport);
if (autolink)
to_file(sf,"set autolink 1\n");
for(cfg=netcfglist;cfg;cfg=cfg->next)
{
to_file(sf,"link %i %s",cfg->guid,(cfg->pass) ? cfg->pass : MATCH_ALL);
if (cfg->host)
to_file(sf," %s %i",cfg->host,cfg->port);
to_file(sf,"\n");
}
#endif /* BOTNET */
#ifdef BOUNCE
if (bounce_port)
to_file(sf,"set bncport %i\n",bounce_port);
#endif /* BOUNCE */
#ifdef WEB
if (webport)
to_file(sf,"set webport %i\n",webport);
#endif /* WEB */
#ifdef DYNCMD
/*
* because of "chaccess XXX disable" its best to save chaccess last
*/
for(j=0;mcmd[j].name;j++)
{
if (acmd[j] != mcmd[j].defaultaccess)
// SPY files
for(spy=bot->spylist;spy;spy=spy->next)
{
if (acmd[j] == 250)
to_file(sf,"chaccess %s disable\n",mcmd[j].name);
else
to_file(sf,"chaccess %s %i\n",mcmd[j].name,(int)acmd[j]);
if (spy->t_dest == SPY_FILE)
{
if (spy->src && spy->dest)
to_file(sf,"spy %s > %s\n",spy->src,spy->dest);
#ifdef DEBUG
else
debug("spy to session fail\n");
#endif /* DEBUG */
}
}
}
#endif /* DYNCMD */
close(sf);
return(TRUE);

View File

@@ -132,7 +132,7 @@ struct
{ 0, "READ", "do_read", 40 | CCPW },
#endif /* NOTE */
#ifdef STATS
{ 0, "INFO", "do_info", 40 | CCPW | CAXS | DCC },
{ 0, "INFO", "do_info", 40 | CCPW | REDIR | CAXS | DCC },
#endif /* STATS */
/*
@@ -227,7 +227,7 @@ struct
{ 0, "DNSSERVER", "do_dnsserver", 100 | CCPW | GAXS },
{ 0, "DNSROOT", "do_dnsroot", 100 | CCPW | GAXS | CARGS },
#endif /* RAWDNS */
{ 0, "CORE", "do_core", 100 | CCPW | DCC },
{ 0, "CORE", "do_core", 100 | CCPW | REDIR | DCC },
{ 0, "DIE", "do_die", 100 | CCPW | GAXS },
{ 0, "RESET", "do_reset", 100 | CCPW | GAXS | NOCMD },
{ 0, "SHUTDOWN", "do_shutdown", 100 | CCPW | GAXS | NOPUB | NOCMD },
@@ -235,7 +235,7 @@ struct
{ 0, "DEBUG", "do_debug", 100 | CCPW | GAXS },
#endif /* DEBUG */
#ifdef PYTHON
#ifdef PLEASE_HACK_MY_SHELL
#ifdef PLEASE_HACK_MY_SHELL
{ 0, "PYTHON", "do_python", 100 | CCPW | GAXS | CARGS },
#endif /* PLEASE_HACK_MY_SHELL */
{ 0, "PYTHONSCRIPT", "do_pythonscript", 100 | CCPW | GAXS | CARGS },

View File

@@ -40,8 +40,8 @@
#define DEFAULTCMDCHAR '-'
#define MECHUSERLOGIN "v3.energymech.net"
BEG const char VERSION[] MDEF("3.0.99p3");
BEG const char SRCDATE[] MDEF("July 24th, 2009");
BEG const char VERSION[] MDEF("3.0.99p4");
BEG const char SRCDATE[] MDEF("March 5th, 2018");
#ifdef __CYGWIN__
BEG const char BOTCLASS[] MDEF("WinMech");
#else /* ! CYGWIN */

View File

@@ -257,7 +257,7 @@ LS void cfg_shit(char *) __page(CFG1_SEG);
LS void cfg_user(char *) __page(CFG1_SEG);
void mirror_user(User *) __page(CORE_SEG);
void mirror_userlist(void) __page(CORE_SEG);
LS void addtouser(Strp **, const char *) __attr(CORE_SEG, __regparm (2) );
LS void addtouser(Strp **, const char *, int) __attr(CORE_SEG, __regparm (3) );
LS int remfromuser(Strp **, const char *) __attr(CORE_SEG, __regparm (2) );
/*

View File

@@ -168,12 +168,6 @@ help_loop:
return;
}
/*
* We dont want to show help for "../../../../../../etc/passwd"
*/
if (!is_safepath(rest))
return;
pt = Strcpy(line,HELPDIR);
for(i=0;(rest[i]);i++)
{
@@ -184,6 +178,20 @@ help_loop:
pt++;
}
*pt = 0;
/*
* We dont want to show help for "../../../../../../etc/passwd"
*/
if (!is_safepath(line))
#ifdef DEBUG
{
debug("(do_help) unsafe help filename (%s), exiting\n",line);
return;
}
#else
return;
#endif /* DEBUG */
#ifdef DEBUG
debug("(do_help) help file check: %s\n",line);
#endif /* DEBUG */

View File

@@ -850,16 +850,27 @@ int main(int argc, char **argv, char **envp)
versiononly = TRUE;
break;
case 'h':
/*
#define TEXT_PSWITCH1 " -p <string> encrypt <string> using the password hashing algorithm,\n"
#define TEXT_PSWITCH2 " output the result and then quit.\n"
#define TEXT_DSWITCH " -d start mech in debug mode\n"
#define TEXT_OSWITCH " -o <file> write debug output to <file>\n"
#define TEXT_XSWITCH " -X write a debug file before exit\n"
*/
to_file(1,TEXT_USAGE,executable);
to_file(1,TEXT_FSWITCH);
to_file(1,TEXT_CSWITCH);
to_file(1,TEXT_FSWITCH
TEXT_CSWITCH
TEXT_PSWITCH1
TEXT_PSWITCH2
#ifdef DEBUG
to_file(1," -d start mech in debug mode\n");
to_file(1," -o <file> write debug output to <file>\n");
to_file(1," -X write a debug file before exit\n");
TEXT_DSWITCH
TEXT_OSWITCH
TEXT_XSWITCH
#endif /* DEBUG */
to_file(1,TEXT_HSWITCH);
to_file(1,TEXT_VSWITCH);
TEXT_HSWITCH
TEXT_VSWITCH);
_exit(0);
case 'c':
makecore = TRUE;
@@ -887,6 +898,13 @@ int main(int argc, char **argv, char **envp)
}
do_fork = TRUE;
break;
case 'p':
++argv;
if (*argv)
to_file(1,"%s\n",makepass(*argv));
else
to_file(1,"error: Missing argument for -p <string>\n");
_exit(0);
case 'X':
debug_on_exit = TRUE;
break;

View File

@@ -1016,7 +1016,7 @@ void ushareUser(BotNet *bn, char *rest)
#ifdef DEBUG
debug("(ushareUser) user %s ++ mask/chan %s\n",user->name,rest);
#endif /* DEBUG */
addtouser((c == '*') ? &user->mask : &user->chan,rest);
addtouser((c == '*') ? &user->mask : &user->chan,rest,TRUE);
}
}
}

View File

@@ -129,10 +129,16 @@
#define TEXT_SIGUSR1 "QUIT :Switching servers... (SIGUSR1)\n"
#define TEXT_USAGE "Usage: %s [switches [args]]\n"
#define TEXT_FSWITCH " -f <file> read configuration from <file>\n"
#define TEXT_CSWITCH " -c make core file instead of coredebug/reset\n"
#define TEXT_HSWITCH " -h show this help\n"
#define TEXT_VSWITCH " -v show EnergyMech version\n"
#define TEXT_FSWITCH " -f <file> read configuration from <file>\n"
#define TEXT_CSWITCH " -c make core file instead of coredebug/reset\n"
#define TEXT_HSWITCH " -h show this help\n"
#define TEXT_VSWITCH " -v show EnergyMech version\n"
#define TEXT_PSWITCH1 " -p <string> encrypt <string> using the password hashing algorithm,\n"
#define TEXT_PSWITCH2 " output the result and then quit.\n"
#define TEXT_DSWITCH " -d start mech in debug mode\n"
#define TEXT_OSWITCH " -o <file> write debug output to <file>\n"
#define TEXT_XSWITCH " -X write a debug file before exit\n"
#define TEXT_HDR_VERS "EnergyMech %s, %s\n"
#define TEXT_HDR_DATE "Compiled on " __DATE__ " " __TIME__ "\n"

View File

@@ -69,12 +69,12 @@ void cfg_pass(char *rest)
void cfg_mask(char *rest)
{
addtouser(&cfgUser->mask,rest);
addtouser(&cfgUser->mask,rest,TRUE);
}
void cfg_chan(char *rest)
{
addtouser(&cfgUser->chan,rest);
addtouser(&cfgUser->chan,rest,TRUE);
}
LS struct
@@ -447,8 +447,8 @@ void rehash_chanusers(void)
}
}
__attr(CORE_SEG, __regparm (2))
void addtouser(Strp **pp, const char *string)
__attr(CORE_SEG, __regparm (3))
void addtouser(Strp **pp, const char *string, int rehash)
{
Strp *um;
@@ -463,7 +463,8 @@ void addtouser(Strp **pp, const char *string)
set_mallocdoer(addtouser);
*pp = um = (Strp*)Calloc(sizeof(Strp) + strlen(string));
Strcpy(um->p,string);
rehash_chanusers();
if (rehash)
rehash_chanusers();
}
__attr(CORE_SEG, __regparm (2))
@@ -1133,6 +1134,7 @@ void do_user(COMMAND_ARGS)
Strp *ump;
char *handle,*pt,*mask,*nick,*chan,*anum,*pass,*encpass;
char mode;
char tmpmask[NUHLEN];
int change;
int newaccess,uaccess;
union usercombo combo;
@@ -1209,27 +1211,31 @@ void do_user(COMMAND_ARGS)
/*
* convert and check nick/mask
*/
if ((mask = nick2uh(from,nick)) == NULL)
if ((mask = nick2uh(from,nick)) == NULL) // nick2uh uses nuh_buf
return;
Strcpy(tmpmask,mask);
#ifdef DEBUG
debug("(do_user) nick2uh(from \"%s\", nick \"%s\") = mask \"%s\"\n",from,nick,tmpmask);
#endif /* DEBUG */
#ifdef NEWBIE
if (!matches(mask,"!@"))
if (!matches(tmpmask,"!@"))
{
to_user(from,"Problem adding %s (global mask)",mask);
to_user(from,"Problem adding %s (global mask)",tmpmask);
return;
}
if (matches("*@?*.?*",mask))
if (matches("*@?*.?*",tmpmask))
{
to_user(from,"Problem adding %s (invalid mask)",mask);
to_user(from,"Problem adding %s (invalid mask)",tmpmask);
return;
}
#endif /* NEWBIE */
format_uh(mask,FUH_USERHOST);
format_uh(tmpmask,FUH_USERHOST); // format_uh uses local temporary buffer but copies result back into tmpmask
/*
* dont duplicate users
*/
if (get_useraccess(mask,chan))
if (get_useraccess(tmpmask,chan))
{
to_user(from,"%s (%s) on %s is already a user",nick,mask,chan);
to_user(from,"%s (%s) on %s is already a user",nick,tmpmask,chan);
return;
}
/*
@@ -1246,9 +1252,12 @@ void do_user(COMMAND_ARGS)
* add_user() touches current->ul_save for us
*/
user = add_user(handle,encpass,newaccess);
addtouser(&user->mask,mask);
addtouser(&user->chan,chan);
to_user(from,"%s has been added as %s on %s",handle,mask,chan);
addtouser(&user->mask,tmpmask,FALSE); // does not run rehash_chanusers(), does not clobber nuh_buf
addtouser(&user->chan,chan,TRUE); // clobbers nuh_buf
#ifdef DEBUG
debug("(do_user) from %s, handle %s,\n\tmask %s (arg %s),\n\tuser->mask %s, chan %s\n",from,handle,mask,nick,user->mask,chan);
#endif /* DEBUG */
to_user(from,"%s has been added as %s on %s",handle,tmpmask,chan);
to_user(from,"Access level: %i%s%s",newaccess,(pass) ? " Password: " : "",(pass) ? pass : "");
#ifdef NEWUSER_SPAM
if ((newaccess != BOTLEVEL) && find_nuh(nick))
@@ -1418,7 +1427,7 @@ usage:
return;
}
#endif /* NEWBIE */
addtouser(&user->chan,mask);
addtouser(&user->chan,mask,TRUE);
change++;
}
else
@@ -1452,7 +1461,7 @@ usage:
return;
}
#endif /* NEWBIE */
addtouser(&user->mask,mask);
addtouser(&user->mask,mask,TRUE);
change++;
}