progress (#18)

* Added: Signal handlers for SIGILL and SIGABRT ifdef DEBUG
 * Added: New command: CRASH, for debugging/development...
 * Changed: configure now defaults to optimizing for code size.
 * Added: configuration option --optimize=speed or --optimize=size
changes to configure #17
This commit is contained in:
joonicks 2018-03-21 22:49:46 +01:00 committed by GitHub
parent cf37c9b728
commit badf9f2771
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 541 additions and 218 deletions

14
.gitignore vendored
View File

@ -1,17 +1,21 @@
# emech .gitignore
energymech
# autogenerated files
src/Makefile
src/config.h
src/*.o
src/energymech
src/gencmd
src/mcmd.h
src/usercombo.h
# compiled files
energymech
src/energymech
src/*.o
src/gencmd
src/aliastest
src/safepathtest
# mech typical user config files
*~
*.bak
mech.passwd
@ -22,6 +26,8 @@ mech.session
root.zone*
trick.conf
# developer files
.use_size
conf
debug*
*.log

6
TODO
View File

@ -1,8 +1,10 @@
/*
* EnergyMech TODO (March 9th, 2018)
* EnergyMech TODO (March 16th, 2018)
*/
- URL grabber/log
- Toybox hangman game
- Support for MD5 and SHA enabled at the same time for compatibility/fallback
- SSL support for irc server/botnet

View File

@ -1,5 +1,9 @@
3.0.99p4 -- WORK IN PROGRESS (~March, 2018)
* Added: Signal handlers for SIGILL and SIGABRT ifdef DEBUG
* Added: New command: CRASH, for debugging/development...
* Changed: configure now defaults to optimizing for code size.
* Added: configuration option --optimize=speed or --optimize=size
* Added: STABLE/BETA/ALPHA status to individual features in configure.
* Fixed: If bot guid is changed or deleted in the config, and the bot
is reset, the connection associated with the removed guid

22
configure vendored
View File

@ -26,6 +26,9 @@ compile=no
install=no
silentopt=no
# default optimization goal, speed = -O2, size = -Os
optitype=size
for opt
do
@ -254,6 +257,8 @@ do
--no-cpuflags) cc_arch_opt=no ;;
--use-optimize) cc_optimize_opt=yes ;;
--no-optimize) cc_optimize_opt=no ;;
--optimize=speed) optitype=speed ;;
--optimize=size) optitype=size ;;
--use-gnudebug) cc_g_opt=yes ;;
--no-gnudebug) cc_g_opt=no ;;
--use-warnflag) cc_wall_opt=yes ;;
@ -539,10 +544,15 @@ if [ -z "$cc_pipe_opt" ]; then
fi
fi
oflag="-O2"
if [ "$optitype" = size ]; then
oflag="-Os"
fi
if [ -z "$cc_optimize_opt" ]; then
if $CC -O2 -o $TESTO $TESTC 1> /dev/null 2> /dev/null; then
cc_optimize_flag="-O2"
echo $ac_n "-O2 "$ac_c
if $CC $oflag -o $TESTO $TESTC 1> /dev/null 2> /dev/null; then
cc_optimize_flag="$oflag"
echo $ac_n "$oflag "$ac_c
fi
if [ -z "$cc_optimize_flag" ]; then
if $CC -O -o $TESTO $TESTC 1> /dev/null 2> /dev/null; then
@ -618,7 +628,7 @@ if [ -z "$endian" ]; then
$CC -o $TESTP $TESTC 1> /dev/null 2> /dev/null
if [ -x $TESTP ]; then
endian=`$TESTP`
if [ "$endian" == "1" ]; then
if [ "$endian" = 1 ]; then
endian="little"
else
endian="big"
@ -1308,12 +1318,12 @@ s|@PTSIZE_DEFINE64@|$PTSIZE_DEFINE64|;
s|@UNALIGNED_MEM@|$UNALIGNED_MEM|;
" < src/config.h.in >> src/config.h
if [ "$install" == "yes" ]; then
if [ "$install" = yes ]; then
make -C src energymech
exit
fi
if [ "$compile" == "yes" ]; then
if [ "$compile" = yes ]; then
make -C src energymech
exit
fi

View File

@ -65,16 +65,21 @@ all: $(INSTALLNAME)
# instead of doing extra parsing and handling while the bot is running.
#
mcmd.h: gencmd.c config.h structs.h
gencmd: gencmd.c socket.c config.h structs.h
$(CC) $(LFLAGS) -o gencmd gencmd.c
./gencmd > mcmd.h
mcmd.h: gencmd
./gencmd mcmd.h
usercombo.h: gencmd
./gencmd usercombo.h
install: $(INSTALLNAME)
$(CHMOD) $(INSTALLMODE) $(INSTALLNAME)
$(MV) $(INSTALLNAME) $(INSTALLDIR)
clean: FORCE
$(RM) $(INSTALLNAME) gencmd mcmd.h core $(TESTFILES) $(OFILES)
$(RM) $(INSTALLNAME) gencmd mcmd.h usercombo.h core $(TESTFILES) $(OFILES)
$(INSTALLNAME): $(OFILES)
$(CROSS_COMPILE)$(CC) $(LFLAGS) -o $(INSTALLNAME) $(OFILES) $(LPROF) $(LIBS) $(LDSCRIPT)
@ -245,7 +250,7 @@ uptime.o: uptime.c $(INCS)
urlcap.o: urlcap.c $(INCS)
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF)
user.o: user.c $(INCS)
user.o: user.c $(INCS) usercombo.h
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF)
vars.o: vars.c $(INCS) settings.h

View File

@ -177,9 +177,15 @@ void afmt(char *copy_to, const char *src, const char *input)
* associated commands
*
*/
/*---Help:ALIAS
/*
help:ALIAS
usage:ALIAS <newcommand> <command [arguments ...]>
file:../help/ALIAS
begin:
Create a command alias. Arguments in the form $#, $#- and $#-# will
Create or replace a command alias.
Arguments in the form $#, $#- and $#-# will
be replaced with the corresponding argument from input.
$0 The zeroeth argument (the aliased command).
@ -208,7 +214,8 @@ to replace built in commands. Aliases can recurse a
maximum of 20 times (to prevent infinite loops).
See also: unalias
---Helpend---*/
:end
*/
void do_alias(COMMAND_ARGS)
{
/*
@ -268,6 +275,17 @@ void do_alias(COMMAND_ARGS)
#endif
}
/*
help:UNALIAS
usage:UNALIAS <alias>
file:../help/UNALIAS
begin:
Remove an existing alias.
See also: alias
:end
*/
void do_unalias(COMMAND_ARGS)
{
/*
@ -292,4 +310,3 @@ void do_unalias(COMMAND_ARGS)
#endif /* not TEST */
#endif /* ALIAS */

View File

@ -417,10 +417,20 @@ int make_auth(const char *userhost, const User *user)
*
*/
/*---Help:AUTH:<password>
*/
/*---Help:VERIFY:<password>
*/
/*
help:AUTH
help:VERIFY
usage:AUTH <password>
usage:VERIFY <password>
file:../help/AUTH
file:../help/VERIFY
begin:
Authenticate yourself with the bot.
See also: passwd, setpass
:end
*/
void do_auth(COMMAND_ARGS)
{
#ifdef BOTNET

View File

@ -668,6 +668,17 @@ char *get_nuh(ChanUser *user)
*
*/
/*
help:JOIN
usage:JOIN <#channel> [key]
file:../help/JOIN
begin:
Makes the bot join a channel
See also: cycle, part
:end
*/
void do_join(COMMAND_ARGS)
{
/*
@ -688,6 +699,13 @@ void do_join(COMMAND_ARGS)
join_channel(channel,key);
}
/*
help:PART
usage:PART <#channel>
file:../help/PART
begin:
:end
*/
void do_part(COMMAND_ARGS)
{
/*
@ -708,6 +726,13 @@ void do_part(COMMAND_ARGS)
}
}
/*
help:CYCLE
usage:CYCLE [#channel]
file:../help/CYCLE
begin:
:end
*/
void do_cycle(COMMAND_ARGS)
{
/*
@ -717,6 +742,13 @@ void do_cycle(COMMAND_ARGS)
cycle_channel(CurrentChan);
}
/*
help:FORGET
usage:FORGET <#channel>
file:../help/FORGET
begin:
:end
*/
void do_forget(COMMAND_ARGS)
{
/*
@ -740,6 +772,13 @@ void do_forget(COMMAND_ARGS)
remove_chan(chan);
}
/*
help:CHANNELS
usage:CHANNELS (no arguments)
file:../help/CHANNELS
begin:
:end
*/
void do_channels(COMMAND_ARGS)
{
ChanUser *cu;
@ -784,6 +823,13 @@ void do_channels(COMMAND_ARGS)
table_send(from,1);
}
/*
help:WALL
usage:WALL [#channel] <message>
file:../help/WALL
begin:
:end
*/
void do_wall(COMMAND_ARGS)
{
ChanUser *cu;
@ -815,6 +861,13 @@ void do_wall(COMMAND_ARGS)
to_user(from,TEXT_SENTWALLOP,to);
}
/*
help:MODE
usage:MODE [#channel|botnick] <mode ...>
file:../help/MODE
begin:
:end
*/
void do_mode(COMMAND_ARGS)
{
/*
@ -844,6 +897,13 @@ void do_mode(COMMAND_ARGS)
}
}
/*
help:NAMES
usage:NAMES [#channel]
file:../help/NAMES
begin:
:end
*/
void do_names(COMMAND_ARGS)
{
ChanUser *cu;
@ -886,6 +946,13 @@ void do_names(COMMAND_ARGS)
}
}
/*
help:CCHAN
usage:CCHAN [#channel]
file:../help/CCHAN
begin:
:end
*/
void do_cchan(COMMAND_ARGS)
{
Chan *chan;
@ -907,6 +974,13 @@ void do_cchan(COMMAND_ARGS)
(current->activechan) ? current->activechan->name : TEXT_NONE);
}
/*
help:INVITE
usage:INVITE [#channel] [nick]
file:../help/INVITE
begin:
:end
*/
void do_invite(COMMAND_ARGS)
{
/*
@ -922,6 +996,20 @@ void do_invite(COMMAND_ARGS)
to_user(from,"User(s) invited to %s",to);
}
/*
help:ME
usage:ME [#channel] <message>
file:../help/ME
begin:
:end
*/
/*
help:SAY
usage:SAY [#channel] <message>
file:../help/SAY
begin:
:end
*/
void do_sayme(COMMAND_ARGS)
{
/*
@ -951,7 +1039,14 @@ void do_sayme(COMMAND_ARGS)
to_user_q(from,(CurrentCmd->name == C_SAY) ? FMT_PLAIN : "\001ACTION %s\001",rest);
}
void do_showusers(COMMAND_ARGS)
/*
help:WHO
usage:WHO
file:../help/WHO
begin:
:end
*/
void do_who(COMMAND_ARGS)
{
/*
* on_msg checks: CAXS
@ -1035,6 +1130,13 @@ void do_showusers(COMMAND_ARGS)
table_send(from,0);
}
/*
help:
usage:
file:../help/
begin:
:end
*/
void do_topic(COMMAND_ARGS)
{
/*
@ -1051,6 +1153,13 @@ void do_topic(COMMAND_ARGS)
to_user(from,ERR_NOTOPPED,to);
}
/*
help:
usage:
file:../help/
begin:
:end
*/
void do_showidle(COMMAND_ARGS)
{
/*
@ -1081,6 +1190,13 @@ void do_showidle(COMMAND_ARGS)
table_send(from,1);
}
/*
help:
usage:
file:../help/
begin:
:end
*/
void do_idle(COMMAND_ARGS)
{
ChanUser *cu,*cu2;

View File

@ -1,7 +1,7 @@
/*
EnergyMech, IRC bot software
Parts Copyright (c) 1997-2004 proton
Parts Copyright (c) 1997-2018 proton
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@ -1354,6 +1354,14 @@ void do_debug(COMMAND_ARGS)
to_user(from,"Unable to write debug information to file");
}
void do_crash(COMMAND_ARGS)
{
int *a;
a = NULL;
*a = 1; /* break time and space */
}
#endif /* ifndef TEST */
void debug(char *format, ...)

View File

@ -22,6 +22,10 @@
#include "config.h"
#include "structs.h"
char gsockdata[MAXLEN];
#include "socket.c"
/*
These are defined in config.h
@ -48,8 +52,8 @@
struct
{
int pass;
char *name;
char *func;
const char *name;
const char *func;
ulong flags;
char *cmdarg;
@ -129,7 +133,7 @@ struct
{ 0, "USERHOST", "do_ircwhois", 40 | CCPW | CARGS },
{ 0, "VOICE", "do_opvoice", 40 | CCPW | CAXS , "v+" },
{ 0, "WALL", "do_wall", 40 | CCPW | CAXS | CARGS | ACCHAN },
{ 0, "WHO", "do_showusers", 40 | CCPW | CAXS | DCC },
{ 0, "WHO", "do_who", 40 | CCPW | CAXS | DCC },
{ 0, "WHOIS", "do_ircwhois", 40 | CCPW | CARGS | DCC | REDIR | LBUF },
#ifdef NOTE
{ 0, "NOTE", "do_note", 40 | CCPW | CARGS },
@ -242,6 +246,7 @@ struct
{ 0, "SHUTDOWN", "do_shutdown", 100 | CCPW | GAXS | NOPUB | NOCMD },
#ifdef DEBUG
{ 0, "DEBUG", "do_debug", 100 | CCPW | GAXS },
{ 0, "CRASH", "do_crash", 100 | CCPW | GAXS },
#endif /* DEBUG */
#ifdef PYTHON
#ifdef PLEASE_HACK_MY_SHELL
@ -264,33 +269,31 @@ struct
#define __struct_acces 2
#define __struct_print 1
int main(int argc, char **argv)
void make_mcmd(void)
{
FILE *of;
usercombo combo;
char tmp[100];
char *pt,*tabs;
int i,j,wh;
int pass;
int ct;
int sl;
const char *pt;
char tmp[100],*tabs;
int i,j,wh,pass,ct,sl,fd;
OnMsg v;
unlink("mcmd.h");
fd = open("mcmd.h",O_WRONLY|O_CREAT|O_TRUNC,0644);
pass = __define_strng;
ct = 0;
printf("/""* This file is automatically generated from gencmd.c *""/\n");
printf("#ifndef TEST\n#ifndef MCMD_H\n#define MCMD_H 1\n\n");
to_file(fd,"/""* This file is automatically generated from gencmd.c *""/\n");
to_file(fd,"#ifndef TEST\n#ifndef MCMD_H\n#define MCMD_H 1\n\n");
while(pass)
{
if (pass == __struct_print)
{
printf("LS const OnMsg mcmd[] =\n{\n");
to_file(fd,"LS const OnMsg mcmd[] =\n{\n");
}
if (pass == __struct_acces)
{
printf("LS OnMsg_access acmd[] = \n{\n");
to_file(fd,"LS OnMsg_access acmd[] = \n{\n");
}
for(i=0;pre_mcmd[i].name;i++)
{
@ -315,17 +318,17 @@ int main(int argc, char **argv)
}
if (pass == __define_strng)
{
//printf("#define S_%s%s\t\"%s\"\n",pt,((strlen(pt) + 2) < 8) ? "\t" : "",pt);
//to_file(fd,"#define S_%s%s\t\"%s\"\n",pt,((strlen(pt) + 2) < 8) ? "\t" : "",pt);
}
if (pass == __define_print)
{
//printf("#define C_%s%s\tmcmd[%i].name\n",pt,((strlen(pt) + 2) < 8) ? "\t" : "",ct);
printf("BEG const char C_%s[]%s\tMDEF(\"%s\");\n",pt,((strlen(pt) + 3) < 8) ? "\t" : "",pt);
//to_file(fd,"#define C_%s%s\tmcmd[%i].name\n",pt,((strlen(pt) + 2) < 8) ? "\t" : "",ct);
to_file(fd,"BEG const char C_%s[]%s\tMDEF(\"%s\");\n",pt,((strlen(pt) + 3) < 8) ? "\t" : "",pt);
ct++;
}
if (pass == __struct_acces)
{
printf("\t%i,\t/""* %s *""/\n",
to_file(fd,"\t%i,\t/""* %s *""/\n",
pre_mcmd[wh].flags & CLEVEL,
pt);
}
@ -370,7 +373,7 @@ int main(int argc, char **argv)
sl = (sl & ~7) / 8;
tabs += sl;
printf( (pre_mcmd[wh].cmdarg) ? "{ C_%s,%s\t%s,%s%s\t, \"%s\"\t},\n" : "{ C_%s,%s\t%s,%s%s\t},\n",
to_file(fd,(pre_mcmd[wh].cmdarg) ? "{ C_%s,%s\t%s,%s%s\t, \"%s\"\t},\n" : "{ C_%s,%s\t%s,%s%s\t},\n",
pt,
((strlen(pt) + 5) < 8) ? "\t" : "",
pre_mcmd[wh].func,
@ -387,57 +390,97 @@ int main(int argc, char **argv)
}
if (pass == __define_print)
{
printf("\n#ifdef MAIN_C\n\n");
to_file(fd,"\n#ifdef MAIN_C\n\n");
}
if (pass == __struct_print)
{
printf("{ NULL, }};\n\n");
to_file(fd,"{ NULL, }};\n\n");
}
if (pass == __struct_acces)
{
printf("};\n\n");
to_file(fd,"};\n\n");
}
pass--;
}
printf("#define LOCALHOST_ULONG %lu\n",inet_addr("127.1"));
printf("#else /""* MAIN_C *""/\n\n");
printf("extern OnMsg mcmd[];\n");
printf("extern OnMsg_access acmd[];\n\n");
printf("#endif /""* MAIN_C *""/\n\n");
printf("#endif /""* MCMD_H *""/\n\n");
printf("#endif /""* TEST *""/\n\n");
to_file(fd,"#define LOCALHOST_ULONG %lu\n",inet_addr("127.1"));
to_file(fd,"#else /""* MAIN_C *""/\n\n");
to_file(fd,"extern OnMsg mcmd[];\n");
to_file(fd,"extern OnMsg_access acmd[];\n\n");
to_file(fd,"#endif /""* MAIN_C *""/\n\n");
to_file(fd,"#endif /""* MCMD_H *""/\n\n");
to_file(fd,"#endif /""* TEST *""/\n\n");
close(fd);
exit(0);
}
void make_usercombo(void)
{
usercombo combo;
int fd;
unlink("usercombo.h");
of = fopen("usercombo.h","w");
fd = open("usercombo.h",O_WRONLY|O_CREAT|O_TRUNC,0644);
fprintf(of,"/""* This file is automatically generated from gencmd.c *""/\n");
to_file(fd,"/""* This file is automatically generated from gencmd.c *""/\n");
#ifdef BOTNET
combo.comboflags = 0; combo.x.noshare = 1;
fprintf(of,"#define COMBO_NOSHARE\t0x%x\n",combo.comboflags);
to_file(fd,"#define COMBO_NOSHARE\t0x%x\n",combo.comboflags);
combo.comboflags = 0; combo.x.readonly = 1;
fprintf(of,"#define COMBO_READONLY\t0x%x\n",combo.comboflags);
to_file(fd,"#define COMBO_READONLY\t0x%x\n",combo.comboflags);
#endif /* BOTNET */
#ifdef GREET
combo.comboflags = 0; combo.x.greetfile = 1;
fprintf(of,"#define COMBO_GREETFILE\t0x%x\n",combo.comboflags);
to_file(fd,"#define COMBO_GREETFILE\t0x%x\n",combo.comboflags);
combo.comboflags = 0; combo.x.randline = 1;
fprintf(of,"#define COMBO_RANDLINE\t0x%x\n",combo.comboflags);
to_file(fd,"#define COMBO_RANDLINE\t0x%x\n",combo.comboflags);
#endif /* GREET */
#ifdef BOUNCE
combo.comboflags = 0; combo.x.bounce = 1;
fprintf(of,"#define COMBO_BOUNCE\t0x%x\n",combo.comboflags);
to_file(fd,"#define COMBO_BOUNCE\t0x%x\n",combo.comboflags);
#endif /* BOUNCE */
combo.comboflags = 0; combo.x.echo = 1;
fprintf(of,"#define COMBO_ECHO\t0x%x\n",combo.comboflags);
to_file(fd,"#define COMBO_ECHO\t0x%x\n",combo.comboflags);
combo.comboflags = 0; combo.x.aop = 1;
fprintf(of,"#define COMBO_AOP\t0x%x\n",combo.comboflags);
to_file(fd,"#define COMBO_AOP\t0x%x\n",combo.comboflags);
combo.comboflags = 0; combo.x.avoice = 1;
fprintf(of,"#define COMBO_AVOICE\t0x%x\n",combo.comboflags);
to_file(fd,"#define COMBO_AVOICE\t0x%x\n",combo.comboflags);
close(fd);
exit(0);
}
void test_help(void)
{
char tmp[PATH_MAX];
struct stat st;
int i,r;
for(i=0;pre_mcmd[i].name;i++)
{
sprintf(tmp,"../help/%s",pre_mcmd[i].name);
r = stat(tmp,&st);
if (r == -1 && errno == ENOENT)
to_file(1,"help for %s is missing\n",pre_mcmd[i].name);
}
exit(0);
}
int main(int argc, char **argv)
{
if (argv[1] && strcmp(argv[1],"usercombo.h") == 0)
make_usercombo();
if (argv[1] && strcmp(argv[1],"mcmd.h") == 0)
make_mcmd();
if (argv[1] && strcmp(argv[1],"testhelp") == 0)
test_help();
fclose(of);
return(0);
}

View File

@ -59,18 +59,12 @@ BEG const char ERR_NOCHANNELS[] MDEF("I'm not active on any channels");
BEG const char ERR_NOTOPPED[] MDEF("I'm not opped on %s");
BEG const char ERR_UNKNOWN_COMMAND[] MDEF("Squeeze me?");
BEG const char __SPYSTR_RAWIRC[] MDEF("rawirc");
BEG const char __SPYSTR_MESSAGE[] MDEF("message");
BEG const char __SPYSTR_STATUS[] MDEF("status");
BEG const char __SPYSTR_BOTNET[] MDEF("botnet");
#define SPYSTR_RAWIRC __SPYSTR_RAWIRC
#define SPYSTR_MESSAGE __SPYSTR_MESSAGE
#define SPYSTR_STATUS __SPYSTR_STATUS
#define SPYSTR_BOTNET __SPYSTR_BOTNET
BEG const char SPYSTR_RAWIRC[] MDEF("rawirc");
BEG const char SPYSTR_MESSAGE[] MDEF("message");
BEG const char SPYSTR_STATUS[] MDEF("status");
BEG const char SPYSTR_BOTNET[] MDEF("botnet");
#ifdef URLCAPTURE
BEG const char __SPYSTR_URL[] MDEF("url");
#define SPYSTR_URL __SPYSTR_URL
BEG const char SPYSTR_URL[] MDEF("url");
#endif /* URLCAPTURE */
BEG const char STR_MECHRESET[] MDEF("MECHRESET=");

243
src/h.h
View File

@ -106,14 +106,132 @@
}
#endif /* DEBUG */
LS int makecrc(const char *);
LS void send_supress(const char *, const char *);
LS void netchanSupress(BotNet *, char *);
LS Chan *find_channel(const char *, int) __attr(CORE_SEG, __regparm (2) );
LS Chan *find_channel_ac(const char *) __attr(CORE_SEG, __regparm (1) );
LS Chan *find_channel_ny(const char *) __attr(CORE_SEG, __regparm (1) );
LS ChanUser *find_chanuser(Chan *, const char *) __attr(CORE_SEG, __regparm (2) );
/*
170540 1728 3104 175372 2ad0c energymech-mega
*/
/* alias.c */
LS void afmt(char *, const char *, const char *) __page(CORE_SEG);
void do_alias(COMMAND_ARGS) __page(CMD1_SEG);
void do_unalias(COMMAND_ARGS) __page(CMD1_SEG);
/* auth.c */
/* bounce.c */
/* chanban.c */
/* channel.c */
LS Chan *find_channel(const char *, int) __attr(CORE_SEG, __regparm(2));
LS Chan *find_channel_ac(const char *) __attr(CORE_SEG, __regparm(1));
LS Chan *find_channel_ny(const char *) __attr(CORE_SEG, __regparm(1));
/* core.c */
/* ctcp.c */
/* debug.c */
void do_crash(COMMAND_ARGS) __page(RARE_SEG);
/* dns.c */
/* dynamode.c */
/* function.c */
LS void *Calloc(int) __attr(CORE_SEG, __regparm(1));
LS void Free(char **) __attr(CORE_SEG, __regparm(1));
LS const int Strlen(const char *, ...) __page(CORE_SEG);
LS const int Strlen2(const char *, const char *) __attr(CORE_SEG, __regparm(2));
LS int matches(const char *, const char *) __attr(CORE_SEG, __regparm(2));
LS int num_matches(const char *, const char *) __attr(CORE_SEG, __regparm(2));
LS int a2i(char *) __attr(CORE_SEG, __regparm(1));
LS int is_safepath(const char *, int) __attr(CORE_SEG, __regparm(2));
/* greet.c */
/* help.c */
/* hostinfo.c */
/* irc.c */
/* kicksay.c */
/* main.c */
LS int sig_hup_callback(char *) __page(RARE_SEG); /* rare */
LS void do_sighup(void) __page(CMD1_SEG);
LS void do_sigint(void) __page(RARE_SEG); /* rare */
LS void do_sigusr1(void) __page(CMD1_SEG);
LS void sig_alrm(int) __page(RARE_SEG); /* rare */
LS void sig_child(int) __page(RARE_SEG); /* rare */
LS void sig_bus(int) __page(CMD1_SEG);
LS void sig_hup(int) __page(RARE_SEG); /* rare */
LS void sig_int(int) __page(RARE_SEG); /* rare */
LS void sig_pipe(int) __page(CORE_SEG);
LS void sig_ill(int) __page(RARE_SEG);
LS void sig_abrt(int) __page(RARE_SEG);
LS void sig_segv(int, siginfo_t *, void *) __page(RARE_SEG);
//LS void sig_segv(int) __page(RARE_SEG); /* rare */
LS void sig_term(int) __page(RARE_SEG); /* rare */
LS void sig_usr1(int) __page(CMD1_SEG);
LS void sig_usr2(int) __page(DBUG_SEG); /* DEBUG */
LS void sig_suicide() __attr(RARE_SEG, __noreturn__); /* rare */
/* net.c */
/* net_chan.c */
LS int makecrc(const char *) __page(CORE_SEG);
LS void send_supress(const char *, const char *) __page(CORE_SEG);
LS void netchanSupress(BotNet *, char *) __page(CORE_SEG);
/* note.c */
/* notify.c */
/* ons.c */
/* parse.c */
/* perl.c */
/* prot.c */
/* python.c */
/* redirect.c */
/* reset.c */
/* seen.c */
/* shit.c */
/* socket.c */
LS ulong get_ip(const char *) __page(CORE_SEG);
LS int SockAccept(int) __page(CORE_SEG);
LS int SockConnect(char *, int, int) __page(CORE_SEG);
LS void SockFlags(int) __page(CORE_SEG);
LS int SockListener(int) __page(CORE_SEG);
LS int SockOpts(void) __page(CORE_SEG);
/* spy.c */
/* stats.c */
/* tcl.c */
/* telnet.c */
/* toybox.c */
/* trivia.c */
/* uptime.c */
/* urlcap.c */
LS void urlcapture(const char *) __page(CORE_SEG);
LS void do_urlhist(COMMAND_ARGS) __page(CMD1_SEG);
/* user.c */
LS void cfg_chan(char *) __page(CFG1_SEG);
LS void cfg_greet(char *) __page(CFG1_SEG);
LS void cfg_mask(char *) __page(CFG1_SEG);
LS void cfg_note(char *) __page(CFG1_SEG);
LS void cfg_opt(char *) __page(CFG1_SEG);
LS void cfg_pass(char *) __page(CFG1_SEG);
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 *, int) __attr(CORE_SEG, __regparm(3));
LS int remfromuser(Strp **, const char *) __attr(CORE_SEG, __regparm(2));
/* vars.c */
/* web.c */
/* ---------------------- */
LS ChanUser *find_chanuser(Chan *, const char *) __attr(CORE_SEG, __regparm(2));
LS Client *find_client(const char *) __page(CORE_SEG);
LS Mech *add_bot(int, char *) __page(CORE_SEG);
LS KickSay *find_kicksay(char *, char *) __page(CORE_SEG);
@ -133,23 +251,23 @@ LS int get_shitaction(const char *, const char *) __page(CORE_SEG);
LS int get_useraccess(const char *, const char *) __page(CORE_SEG);
LS int get_maxaccess(const char *) __page(CORE_SEG);
LS int Strcasecmp(const char *, const char *) __att2(CORE_SEG, const, __regparm (2) );
LS int Strcmp(const char *, const char *) __att2(CORE_SEG, const, __regparm (2) );
LS char *Strcat(char *, const char *) __attr(CORE_SEG, __regparm (2) );
LS char *Strchr(const char *, int) __att2(CORE_SEG, const, __regparm (2) );
LS char *Strcpy(char *, const char *) __attr(CORE_SEG, __regparm (2) );
LS char *Strdup(const char *) __attr(CORE_SEG, __regparm (1) );
LS void Strncpy(char *, const char *, int) __attr(CORE_SEG, __regparm (3) );
LS char *chop(char **) __attr(CORE_SEG, __regparm (1) );
LS int Strcasecmp(const char *, const char *) __attr(CORE_SEG, __regparm(2));
LS int Strcmp(const char *, const char *) __attr(CORE_SEG, __regparm(2));
LS char *Strcat(char *, const char *) __attr(CORE_SEG, __regparm(2));
LS char *Strchr(const char *, int) __attr(CORE_SEG, __regparm(2));
LS char *Strcpy(char *, const char *) __attr(CORE_SEG, __regparm(2));
LS char *Strdup(const char *) __attr(CORE_SEG, __regparm(1));
LS void Strncpy(char *, const char *, int) __attr(CORE_SEG, __regparm(3));
LS char *chop(char **) __attr(CORE_SEG, __regparm(1));
LS int get_number(const char *) __page(CORE_SEG);
LS int nickcmp(const char *, const char *) __att2(CORE_SEG, const, __regparm (2) );
LS char *nickcpy(char *, const char *) __attr(CORE_SEG, __regparm (2) );
LS int nickcmp(const char *, const char *) __attr(CORE_SEG, __regparm(2));
LS char *nickcpy(char *, const char *) __attr(CORE_SEG, __regparm(2));
LS char *cipher(char *) __page(CMD1_SEG);
LS char *cluster(char *) __page(CMD1_SEG);
LS char *find_nuh(char *) __page(CORE_SEG);
LS char *format_uh(char *, int) __page(CMD1_SEG);
LS char *get_channel(char *, char **) __attr(CMD1_SEG, __regparm (2) );
LS char *get_channel(char *, char **) __attr(CMD1_SEG, __regparm(2));
LS char *get_channel2(char *, char **) __page(CMD1_SEG);
LS char *get_nuh(ChanUser *) __page(CORE_SEG);
LS char *get_token(char **, const char *) __page(CORE_SEG);
@ -160,24 +278,13 @@ LS char *nick2uh(char *, char *) __page(CMD1_SEG);
LS char *randstring(char *) __page(CORE_SEG);
LS char *sockread(int, char *, char *) __page(CORE_SEG);
LS char *logtime(time_t) __page(CORE_SEG);
LS void table_buffer(const char *, ...) __attr(CMD1_SEG, format (printf, 1, 2) );
LS void table_send(const char *, const int) __attr(CMD1_SEG, __regparm (2) );
LS void table_buffer(const char *, ...) __attr(CMD1_SEG, format(printf, 1, 2));
LS void table_send(const char *, const int) __attr(CMD1_SEG, __regparm(2));
LS char *time2away(time_t) __page(CORE_SEG);
LS char *time2medium(time_t) __page(CORE_SEG);
LS char *time2small(time_t) __page(CMD1_SEG);
LS char *time2str(time_t) __page(CMD1_SEG);
LS char *tolowercat(char *dest, const char *src) __attr(CMD1_SEG, __regparm (2) );
/*
* socket.c
*/
LS ulong get_ip(const char *) __page(CORE_SEG);
LS int SockAccept(int) __page(CORE_SEG);
LS int SockConnect(char *, int, int) __page(CORE_SEG);
LS void SockFlags(int) __page(CORE_SEG);
LS int SockListener(int) __page(CORE_SEG);
LS int SockOpts(void) __page(CORE_SEG);
LS char *tolowercat(char *dest, const char *src) __attr(CMD1_SEG, __regparm(2));
LS int capslevel(char *) __page(CORE_SEG);
LS int check_mass(Chan *, ChanUser *, int) __page(CORE_SEG);
LS int compile_timer(HookTimer *, char *) __page(CORE_SEG); /* SCRIPTING */
@ -197,9 +304,9 @@ LS int read_seenlist_callback(char *) __page(CFG1_SEG);
LS int read_userlist(char *) __page(CFG1_SEG);
LS int read_userlist_callback(char *) __page(CFG1_SEG);
LS int reverse_mode(char *, Chan *, int, int) __page(CORE_SEG);
LS int to_file(int, const char *, ...) __attr(CORE_SEG, format (printf, 2, 3) );
LS int to_file(int, const char *, ...) __attr(CORE_SEG, format(printf, 2, 3));
LS int try_server(Server *, char *) __page(CORE_SEG);
LS int usercanmodify(const char *, const User *) __attr(CORE_SEG, __regparm (2) );
LS int usercanmodify(const char *, const User *) __attr(CORE_SEG, __regparm(2));
LS int write_seenlist(void) __page(CORE_SEG);
LS int write_session(void) __page(CORE_SEG);
LS int write_userlist(char *) __page(CORE_SEG);
@ -210,17 +317,8 @@ LS ulong stringhash(char *) __page(CORE_SEG);
/*
* function.c
*/
LS void *Calloc(int) __attr(CORE_SEG, __regparm (1) );
LS void Free(char **) __attr(CORE_SEG, __regparm (1) );
LS const int Strlen(const char *, ...) __page(CORE_SEG);
LS const int Strlen2(const char *, const char *) __attr(CORE_SEG, __regparm (2) );
LS int matches(const char *, const char *) __att2(CORE_SEG, const, __regparm (2) );
LS int num_matches(const char *, const char *) __att2(CORE_SEG, const, __regparm (2) );
LS int a2i(char *) __attr(CORE_SEG, __regparm (1) );
LS int is_safepath(const char *, int) __attr(CORE_SEG, __regparm (2) );
LS void afmt(char *, const char *, const char *) __page(CMD1_SEG);
LS void aucheck(User *) __attr(CORE_SEG, __regparm (1) );
LS void aucheck(User *) __attr(CORE_SEG, __regparm(1));
LS void change_authnick(char *, char *) __page(CORE_SEG);
LS void change_pass(User *, char *) __page(CMD1_SEG);
LS void chan_modestr(Chan *, char *) __page(CMD1_SEG);
@ -237,7 +335,7 @@ LS void cycle_channel(Chan *) __page(CORE_SEG);
LS void dcc_banner(Client *) __page(CORE_SEG);
LS void dcc_chat(char *) __page(CMD1_SEG);
LS int dcc_only_command(char *) __page(CMD1_SEG);
LS void debug(char *, ...) __attr(CORE_SEG, format (printf, 1, 2) );
LS void debug(char *, ...) __attr(CORE_SEG, format(printf, 1, 2));
LS void delete_auth(char *) __page(RARE_SEG); /* rare */
LS void delete_ban(Chan *, char *) __page(CORE_SEG);
LS void delete_modemask(Chan *, char *, int) __page(CORE_SEG);
@ -247,28 +345,8 @@ LS void deop_ban(Chan *, ChanUser *, char *) __page(CMD1_SEG);
LS void deop_screwban(Chan *, ChanUser *) __page(CMD1_SEG);
LS void deop_siteban(Chan *, ChanUser *) __page(CMD1_SEG);
/*
* user.c
*/
LS void cfg_chan(char *) __page(CFG1_SEG);
LS void cfg_greet(char *) __page(CFG1_SEG);
LS void cfg_mask(char *) __page(CFG1_SEG);
LS void cfg_note(char *) __page(CFG1_SEG);
LS void cfg_opt(char *) __page(CFG1_SEG);
LS void cfg_pass(char *) __page(CFG1_SEG);
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 *, int) __attr(CORE_SEG, __regparm (3) );
LS int remfromuser(Strp **, const char *) __attr(CORE_SEG, __regparm (2) );
/*
* commands
*/
LS void do_8ball(COMMAND_ARGS) __page(CMD1_SEG); /* TOYBOX */
LS void do_access(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_alias(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_auth(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_away(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_banlist(COMMAND_ARGS) __page(CMD1_SEG);
@ -332,14 +410,13 @@ LS void do_setpass(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_shit(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_shitlist(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_showidle(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_showusers(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_who(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_shutdown(COMMAND_ARGS) __page(RARE_SEG); /* rare */
LS void do_siteban(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_spy(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_time(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_topic(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_trivia(COMMAND_ARGS) __page(CMD1_SEG); /* TRIVIA */
LS void do_unalias(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_unban(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_upsend(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_upontime(COMMAND_ARGS) __page(CMD1_SEG);
@ -352,16 +429,16 @@ LS void do_whom(COMMAND_ARGS) __page(CMD1_SEG);
/*
* end of commands
*/
LS void fix_config_line(char *) __attr(CORE_SEG, __regparm (1) );
LS void fix_config_line(char *) __attr(CORE_SEG, __regparm(1));
LS void greet(void) __page(CMD1_SEG);
LS void join_channel(char *, char *) __page(CORE_SEG);
LS void kill_all_bots(char *) __attr(RARE_SEG, __noreturn__ ); /* rare */
LS void kill_all_bots(char *) __attr(RARE_SEG, __noreturn__); /* rare */
LS int make_auth(const char *, const User *) __page(CORE_SEG);
LS Ban *make_ban(Ban **, char *, char *, time_t) __page(CORE_SEG);
LS void make_chanuser(char *, char *) __attr(CORE_SEG, __regparm (2) );
LS void make_chanuser(char *, char *) __attr(CORE_SEG, __regparm(2));
LS void make_ireq(int, char *, char *) __page(CMD1_SEG);
LS void mass_action(Chan *, ChanUser *) __page(CORE_SEG);
LS void mech_exec(void) __attr(RARE_SEG, __noreturn__ ); /* rare */
LS void mech_exec(void) __attr(RARE_SEG, __noreturn__); /* rare */
LS void on_action(char *, char *, char *) __page(CORE_SEG);
LS void on_ctcp(char *, char *, char *) __page(CORE_SEG);
LS void on_join(Chan *, char *) __page(CORE_SEG);
@ -401,9 +478,6 @@ LS void parse_mode(char *, char *) __page(CORE_SEG);
LS void parse_notice(char *, char *) __page(CORE_SEG);
LS void parse_part(char *, char *) __page(CORE_SEG);
LS void parse_ping(char *, char *) __page(CORE_SEG);
#ifdef URLCAPTURE
LS void urlcapture(const char *) __page(CORE_SEG);
#endif /* URLCAPTURE */
LS void parse_privmsg(char *, char *) __page(CORE_SEG);
LS void parse_quit(char *, char *) __page(CORE_SEG);
LS void parse_topic(char *, char *) __page(CMD1_SEG);
@ -460,21 +534,6 @@ LS void whom_printbot(char *, BotInfo *, char *) __page(CMD1_SEG);
/*
* signals
*/
LS int sig_hup_callback(char *) __page(RARE_SEG);
LS void do_sighup(void) __page(CMD1_SEG);
LS void do_sigint(void) __page(RARE_SEG);
LS void do_sigusr1(void) __page(CMD1_SEG);
LS void sig_alrm(int) __page(RARE_SEG);
LS void sig_child(int) __page(RARE_SEG);
LS void sig_bus(int) __page(CMD1_SEG);
LS void sig_hup(int) __page(RARE_SEG);
LS void sig_int(int) __page(RARE_SEG);
LS void sig_pipe(int) __page(CORE_SEG);
LS void sig_segv(int) __page(RARE_SEG);
LS void sig_term(int) __page(RARE_SEG);
LS void sig_usr1(int) __page(CMD1_SEG);
LS void sig_usr2(int) __page(DBUG_SEG); /* DEBUG */
LS void sig_suicide() __attr(RARE_SEG, __noreturn__);
/*
* BOTNET prototypes
@ -778,12 +837,6 @@ LS void uptime_death(int) __page(RARE_SEG); /* rare */
#endif /* UPTIME */
#ifdef URLCAPTURE
LS void urlcapture(const char *) __page(CORE_SEG);
LS void do_urlhist(COMMAND_ARGS) __page(CMD1_SEG);
#endif /* ifdef URLCAPTURE */
/*
* WEB prototypes

View File

@ -183,14 +183,13 @@ help_loop:
* We dont want to show help for "../../../../../../etc/passwd"
*/
if (is_safepath(line,FILE_MUST_EXIST) != FILE_IS_SAFE)
#ifdef DEBUG
{
#ifdef DEBUG
debug("(do_help) unsafe help filename (%s), exiting\n",line);
#endif /* DEBUG */
to_user(from,"Help file for \"%s\" is unavailable.",rest);
return;
}
#else
return;
#endif /* DEBUG */
#ifdef DEBUG
debug("(do_help) help file check: %s\n",line);

View File

@ -131,8 +131,10 @@ char *randstring(char *file)
* SIGALRM Ignore ALRM signals
* SIGPIPE Ignore PIPE signals
* SIGINT Exit gracefully on ^C
* SIGBUS (Try to) Exit gracefully on bus faults
* SIGSEGV (Try to) Exit gracefully on segmentation violations
* SIGILL Illegal instruction (debug: report) quit
* SIGABRT abort(3) (debug: report) quit
* SIGBUS (Try to) Exit/restart gracefully on bus faults
* SIGSEGV (Try to) Exit/restart gracefully on segmentation violations
* SIGTERM Exit gracefully when killed
* SIGUSR1 Jump (a) bot to a new server
* SIGUSR2 Call run_debug() (dump `everything' to a debug file)
@ -337,6 +339,26 @@ void sig_int(int signum)
signal(SIGINT,sig_int);
}
/*
* SIGILL, Illegal instruction
*/
#ifdef DEBUG
void sig_ill(int crap)
{
debug("(sigill)\n");
}
#endif /* DEBUG */
/*
* SIGABRT, abort(3)
*/
#ifdef DEBUG
void sig_abrt(int crap)
{
debug("(sigabrt)\n");
}
#endif /* DEBUG */
/*
* SIGBUS is a real killer and cant be scheduled.
*/
@ -360,8 +382,16 @@ void sig_bus(int crap)
/*
* SIGSEGV shows no mercy, cant schedule it.
*/
void sig_segv(int crap)
#ifdef __x86_64__
#include <sys/ucontext.h>
#endif
void sig_segv(int crap, siginfo_t *si, void *uap)
{
#ifdef __x86_64__
mcontext_t *mctx;
greg_t *rsp,*rip; // general registers
#endif /* __x86_64__ */
time(&now);
respawn++;
@ -369,7 +399,17 @@ void sig_segv(int crap)
mechexit(1,exit);
#ifdef DEBUG
debug("(sigsegv)\n");
debug("(sigsegv) trying to access "mx_pfmt"\n",(mx_ptr)si->si_addr);
#ifdef __x86_64__
mctx = &((ucontext_t *)uap)->uc_mcontext;
rsp = &mctx->gregs[15]; // RSP, 64-bit stack pointer
rip = &mctx->gregs[16]; // RIP, 64-bit instruction pointer
debug("(sigsegv) Stack pointer: "mx_pfmt", Instruction pointer: "mx_pfmt"\n",(mx_ptr)*rsp,(mx_ptr)*rip);
debug("(sigsegv) sig_segv() = "mx_pfmt"\n",(mx_ptr)sig_segv);
debug("(sigsegv) do_crash() = "mx_pfmt"\n",(mx_ptr)do_crash);
#endif /* __x86_64__ */
if (debug_on_exit)
{
run_debug();
@ -859,15 +899,6 @@ execve( ./energymech, argv = { ./energymech <NULL> <NULL> <NULL> <NULL> }, 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
TEXT_CSWITCH
@ -1060,7 +1091,18 @@ execve( ./energymech, argv = { ./energymech <NULL> <NULL> <NULL> <NULL> }, envp
* wait until after recover_reset() cuz it might change makecore
*/
if (!makecore)
signal(SIGSEGV,sig_segv);
{
struct sigaction s;
s.sa_flags = SA_SIGINFO;
sigemptyset(&s.sa_mask);
s.sa_sigaction = sig_segv;
sigaction(SIGSEGV, &s, NULL);
//signal(SIGSEGV,sig_segv);
#ifdef DEBUG
signal(SIGILL,sig_ill);
signal(SIGABRT,sig_abrt);
#endif /* DEBUG */
}
doit();
}

View File

@ -339,50 +339,59 @@ void basicAuth(BotNet *bn, char *rest)
if (!pass || !*pass)
goto badpass;
if (linkpass == NULL || *linkpass == 0)
goto badpass;
switch(authtype)
{
case BNAUTH_PLAINTEXT:
/*
>> plain text given: "DomoOmiGato" stored "kooplook0988"
(reset_linkable) guid 1337 reset to linkable
(basicAuth) bad password [ guid = 1337 ]
*/
#ifdef DEBUG
debug(">> plain text given: \"%s\" stored \"%s\"\n",pass,rest);
#endif /* DEBUG */
if (Strcmp(pass,rest))
goto badpass;
break;
#ifdef SHACRYPT
case BNAUTH_SHA:
if (linkpass && *linkpass)
{
char *enc,temppass[24 + Strlen2(pass,linkpass)]; // linkpass is never NULL
char *enc,temppass[24 + Strlen2(pass,linkpass)]; // linkpass is never NULL
/* "mypass theirpass REMOTEsid LOCALsid" */
sprintf(temppass,"%s %s %i %i",linkpass,pass,bn->rsid,bn->lsid);
/* "mypass theirpass REMOTEsid LOCALsid" */
sprintf(temppass,"%s %s %i %i",linkpass,pass,bn->rsid,bn->lsid);
#ifdef DEBUG
debug(">> sha pass exchange: \"%s\"\n",temppass);
debug(">> sha pass exchange: \"%s\"\n",temppass);
#endif /* DEBUG */
enc = CRYPT_FUNC(temppass,rest);
enc = CRYPT_FUNC(temppass,rest);
#ifdef DEBUG
debug("(basicAuth) their = %s, mypass = %s :: sha = %s\n",
pass,linkpass,enc);
debug("(basicAuth) their = %s, mypass = %s :: sha = %s\n",
pass,linkpass,enc);
#endif /* DEBUG */
if (!Strcmp(enc,rest))
break;
if (!Strcmp(enc,rest))
break;
}
#endif /* SHACRYPT */
#ifdef MD5CRYPT
case BNAUTH_MD5:
if (linkpass && *linkpass)
{
char *enc,temppass[24 + Strlen2(pass,linkpass)]; // linkpass is never NULL
char *enc,temppass[24 + Strlen2(pass,linkpass)]; // linkpass is never NULL
/* "mypass theirpass REMOTEsid LOCALsid" */
sprintf(temppass,"%s %s %i %i",linkpass,pass,bn->rsid,bn->lsid);
/* "mypass theirpass REMOTEsid LOCALsid" */
sprintf(temppass,"%s %s %i %i",linkpass,pass,bn->rsid,bn->lsid);
#ifdef DEBUG
debug(">> md5 pass exchange: \"%s\"\n",temppass);
debug(">> md5 pass exchange: \"%s\"\n",temppass);
#endif /* DEBUG */
enc = CRYPT_FUNC(temppass,rest);
enc = CRYPT_FUNC(temppass,rest);
#ifdef DEBUG
debug("(basicAuth) their = %s, mypass = %s :: md5 = %s\n",
pass,linkpass,enc);
debug("(basicAuth) their = %s, mypass = %s :: md5 = %s\n",
pass,linkpass,enc);
#endif /* DEBUG */
if (!Strcmp(enc,rest))
break;
if (!Strcmp(enc,rest))
break;
}
#endif /* MD5CRYPT */
default:

View File

@ -18,6 +18,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef GENCMD_C
#define SOCKET_C
#include "config.h"
@ -263,13 +264,15 @@ int SockAccept(int sock)
return(s);
}
#endif /* GENCMD_C */
/*
* Format text and send to a socket or file descriptor
*/
int to_file(int sock, const char *format, ...)
{
va_list msg;
#ifdef DEBUG
#if defined(DEBUG) && !defined(GENCMD_C)
char *line,*rest;
int i;
#endif /* DEBUG */
@ -281,7 +284,7 @@ int to_file(int sock, const char *format, ...)
vsprintf(gsockdata,format,msg);
va_end(msg);
#ifdef DEBUG
#if defined(DEBUG) && !defined(GENCMD_C)
i = write(sock,gsockdata,strlen(gsockdata));
rest = gsockdata;
while((line = get_token(&rest,"\n"))) /* rest cannot be NULL */
@ -294,6 +297,8 @@ int to_file(int sock, const char *format, ...)
#endif /* DEBUG */
}
#ifndef GENCMD_C
/*
* Format a message and send it to the current bots server
* to_server needs a newline (\n) it wont manufacture it itself.
@ -672,3 +677,5 @@ int killsock(int sock)
}
return(TRUE);
}
#endif /* GENCMD_C */

View File

@ -39,9 +39,7 @@ LS const char SPY_DEFS[][12] =
"SPY_MESSAGE",
"SPY_RAWIRC",
"SPY_BOTNET",
#ifdef URLCAPTURE
"SPY_URL",
#endif /* URLCAPTURE */
};
#endif /* DEBUG */