diff --git a/VERSIONS b/VERSIONS index e7374a2..7b5b88f 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,5 +1,8 @@ 3.0.99p4 -- WORK IN PROGRESS (~March, 2018) + * Added: New host information commands: HOSTINFO, MEMINFO, CPUINFO. + * Added: New configuration option: hostinfo + * Fixed: Custom ld script fintuning the core order. * Changed: Rewrite of ALIAS aliasing routine, adding features. * Fixed: RawDNS, again... * Fixed: Save procvars only once in session file. diff --git a/config/ldtest.c b/config/ldtest.c index 45f6078..80e1d1b 100644 --- a/config/ldtest.c +++ b/config/ldtest.c @@ -9,13 +9,22 @@ #define S(x) x,sizeof(x) -__page(".text.e") +#if 0 + *(.text.e) /* RARE */ + *(.text.d) /* INIT */ main + *(.text.b) /* CFG1 */ func2 + *(.text.c) /* CMD1 */ func1 + *(.text.a) /* CORE */ + *(.text.f) /* DBUG */ +#endif + +__page(".text.c") int function1(int a) { return a + 1; } -__page(".text.c") +__page(".text.b") int function2(int a) { return a + 2; @@ -24,7 +33,7 @@ int function2(int a) __page(".text.d") int main(int argc, char **argv) { - if (((void*)main < (void*)function1) && ((void*)function1 < (void*)function2)) + if (((void*)main < (void*)function2) && ((void*)function2 < (void*)function1)) write(1,S("yes\n")); else write(1,S("no\n")); diff --git a/configure b/configure index 0f1f02d..aa6a09d 100755 --- a/configure +++ b/configure @@ -59,6 +59,7 @@ do dynamode ) ft_dynamode=$yesno ;; dyncmd ) ft_dyncmd=$yesno ;; greet ) ft_greet=$yesno ;; + hostinfo ) ft_hostinfo=$yesno ;; idwrap ) ft_idwrap=$yesno ;; ircd_ext ) ft_ircd_ext=$yesno ;; md5 ) ft_md5=$yesno ;; @@ -107,7 +108,7 @@ do case "$feature" in debug | botnet | telnet | alias | seen | session | dyncmd | newbie | wingate | md5 | sha \ - | ctcp | dccfile | uptime | redirect | greet | perl | profiling | tcl | dynamode | web \ + | ctcp | dccfile | uptime | redirect | greet | perl | profiling | tcl | dynamode | web | hostinfo \ | note | notify | trivia | toybox | bounce | stats | rawdns | ircd_ext | idwrap | chanban | python ) case _"$optarg"_ in _yes_ | _no_ | __ ) @@ -152,6 +153,8 @@ do dyncmd_no ) ft_dyncmd=no ;; greet_yes | greet_ ) ft_greet=yes ;; greet_no ) ft_greet=no ;; + hostinfo_yes | hostinfo_ ) ft_hostinfo=yes ;; + hostinfo_no ) ft_hostinfo=no ;; idwrap_yes | idwrap_ ) ft_idwrap=yes ;; idwrap_no ) ft_idwrap=no ;; ircd_ext_yes | ircd_ext_ ) ft_ircd_ext=yes ;; @@ -210,6 +213,7 @@ do dynamode ) ft_dynamode=no ;; dyncmd ) ft_dyncmd=no ;; greet ) ft_greet=no ;; + hostinfo ) ft_hostinfo=no ;; idwrap ) ft_idwrap=no ;; ircd_ext ) ft_ircd_ext=no ;; md5 ) ft_md5=no ;; @@ -258,6 +262,7 @@ do ft_dynamode=yes ft_dyncmd=yes ft_greet=yes + ft_hostinfo=yes ft_ircd_ext=yes ft_md5=yes ft_newbie=yes @@ -296,6 +301,8 @@ Features and packages: --with-botnet Botnet support --with-debug Debug support --with-dyncmd Dynamic command levels support + --with-hostinfo Support for code that reveals/displays/shares information about the host + that the bot is running on. --with-newbie Newbie support --with-profiling Profiling (gcc+gprof) --with-seen SEEN support @@ -876,10 +883,10 @@ TESTC=config/ldtest.c echo $ac_n "checking for friendly ld ... "$ac_c -$CC -o $TESTP $TESTC -Wl,-T,src/ld/mech.ldscript 1> /dev/null 2> /dev/null +$CC -o $TESTP $TESTC -Wl,-T,src/ld/elf64-x86-64 1> /dev/null 2> /dev/null if [ -x $TESTP ]; then if [ `$TESTP` = "yes" ]; then - ldscript='-Wl,-T,ld/mech.ldscript' + ldscript='-Wl,-T,ld/elf64-x86-64' has_ldscript=yes fi fi @@ -1058,6 +1065,13 @@ else test -z "$ans" -o "$ans" = y -o "$ans" = Y -o "$ans" = yes -o "$ans" = YES -o "$ans" = Yes -o "$ans" = internal && def_sha='#define SHACRYPT' fi +def_hostinfo='#undef HOSTINFO' +unset ans +echo $ac_n "Host info support? ......................... [Y/n] "$ac_c +test "$ft_hostinfo" && echo "$ft_hostinfo" && ans=$ft_hostinfo +test -z "$ft_hostinfo" && read ans +test -z "$ans" -o "$ans" = y -o "$ans" = Y -o "$ans" = yes -o "$ans" = YES -o "$ans" = Yes && def_hostinfo='#define HOSTINFO' + def_newbie='#undef NEWBIE' unset ans echo $ac_n "Newbie support? ............................ [Y/n] "$ac_c @@ -1231,6 +1245,7 @@ sed " s|@DEF_DYNCMD@|$def_dyncmd|; s|@DEF_DYNAMODE@|$def_dynamode|; s|@DEF_GREET@|$def_greet|; +s|@DEF_HOSTINFO@|$def_hostinfo|; s|@DEF_IDWRAP@|$def_idwrap|; s|@DEF_IRCD_EXT@|$def_ircd_ext|; s|@DEF_MD5@|$def_md5|; diff --git a/src/Makefile.in b/src/Makefile.in index e5d6a0d..1ef524d 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -43,14 +43,14 @@ CHMOD = chmod INCS = config.h mcmd.h defines.h global.h h.h structs.h text.h OFILES = alias.o auth.o bounce.o chanban.o channel.o core.o \ - ctcp.o debug.o dns.o dynamode.o function.o greet.o help.o irc.o \ + ctcp.o debug.o dns.o dynamode.o function.o greet.o help.o hostinfo.o irc.o \ kicksay.o main.o net.o net_chan.o note.o notify.o ons.o parse.o \ perl.o prot.o python.o redirect.o reset.o seen.o shit.o socket.o \ spy.o stats.o tcl.o telnet.o toybox.o trivia.o uptime.o \ user.o vars.o web.o @MD5_O@ @SHA_O@ SRCFILES = alias.c auth.c bounce.c chanban.c channel.c core.c \ - ctcp.c debug.c dns.c dynamode.c function.c greet.c help.c irc.c \ + ctcp.c debug.c dns.c dynamode.c function.c greet.c help.c hostinfo.c irc.c \ kicksay.c main.c net.c net_chan.c note.c notify.c ons.c parse.c \ perl.c prot.c python.c redirect.c reset.c seen.c shit.c socket.c \ spy.c stats.c tcl.c telnet.c toybox.c trivia.c uptime.c \ @@ -155,6 +155,9 @@ greet.o: greet.c $(INCS) help.o: help.c $(INCS) usage.h $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF) +hostinfo.o: hostinfo.c $(INCS) + $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF) + irc.o: irc.c $(INCS) $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF) diff --git a/src/alias.c b/src/alias.c index b142faa..9b55b44 100644 --- a/src/alias.c +++ b/src/alias.c @@ -159,7 +159,9 @@ void afmt(char *copy_to, const char *src, const char *input) argend++; } } -// debug("args #%i-#%i, characters %i-%i\n",startnum,endnum,argstart-input,argend-input); +#ifdef DEBUG + debug("(afmt) args #%i-#%i, characters %i-%i\n",startnum,endnum,argstart-input,argend-input); +#endif /* DEBUG */ while(*argstart && argstart < argend && dest <= BUFTAIL) *(dest++) = *(argstart++); continue; @@ -169,7 +171,9 @@ void afmt(char *copy_to, const char *src, const char *input) *(dest++) = *(src++); } *dest = 0; -// debug("start %i end %i spc %i\n",startnum,endnum,spc); +#ifdef DEBUG + debug("(afmt) start %i end %i spc %i\n",startnum,endnum,spc); +#endif /* DEBUG */ } #ifndef ALIASTEST diff --git a/src/config.h.in b/src/config.h.in index 70bafe6..1a03820 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -187,6 +187,11 @@ #undef CHANBAN #endif /* IRCD_EXTENSIONS */ +/* + * HOSTINFO: share information about the host that the bot is running on + */ +@DEF_HOSTINFO@ + /* * FASTNICK: faster nick regain if the nick is seen when released * Enables code that is potentially dangerous if an attacker aquires diff --git a/src/gencmd.c b/src/gencmd.c index 5110e44..a4606d2 100644 --- a/src/gencmd.c +++ b/src/gencmd.c @@ -1,7 +1,7 @@ /* EnergyMech, IRC bot software - Copyright (c) 1997-2009 proton + 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 @@ -223,6 +223,11 @@ struct /* * Level 100 */ +#ifdef HOSTINFO + { 0, "HOSTINFO", "do_hostinfo", 100 | CCPW | GAXS }, + { 0, "MEMINFO", "do_meminfo", 100 | CCPW | GAXS }, + { 0, "CPUINFO", "do_cpuinfo", 100 | CCPW | GAXS }, +#endif /* HOSTINFO */ #ifdef RAWDNS { 0, "DNSSERVER", "do_dnsserver", 100 | CCPW | GAXS }, { 0, "DNSROOT", "do_dnsroot", 100 | CCPW | GAXS | CARGS }, diff --git a/src/h.h b/src/h.h index 15114c1..0ac80b8 100644 --- a/src/h.h +++ b/src/h.h @@ -581,6 +581,13 @@ LS void check_dynamode(Chan *) __page(CORE_SEG); #endif /* DYNAMODE */ +#ifdef HOSTINFO + +LS void do_hostinfo(COMMAND_ARGS) __page(CMD1_SEG); +LS void do_meminfo(COMMAND_ARGS) __page(CMD1_SEG); +LS void do_cpuinfo(COMMAND_ARGS) __page(CMD1_SEG); + +#endif /* HOSTINFO */ /* * */ diff --git a/src/ld/mech.ldscript b/src/ld/mech.ldscript deleted file mode 100644 index e3106ce..0000000 --- a/src/ld/mech.ldscript +++ /dev/null @@ -1,105 +0,0 @@ -OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") -OUTPUT_ARCH(i386) -ENTRY(_start) -SEARCH_DIR(/lib); -SEARCH_DIR(/usr/lib); -SEARCH_DIR(/usr/local/lib); -SECTIONS -{ - . = 0x08048000 + SIZEOF_HEADERS; - .interp : { *(.interp) } - .hash : { *(.hash) } - .dynsym : { *(.dynsym) } - .dynstr : { *(.dynstr) } - .gnu.version_d : { *(.gnu.version_d) } - .gnu.version_r : { *(.gnu.version_r) } - .rel.text : { *(.rel.text) *(.rel.gnu.linkonce.t*) } - .rela.text : { *(.rela.text) *(.rela.gnu.linkonce.t*) } - .rel.data : { *(.rel.data) *(.rel.gnu.linkonce.d*) } - .rela.data : { *(.rela.data) *(.rela.gnu.linkonce.d*) } - .rel.rodata : { *(.rel.rodata) *(.rel.gnu.linkonce.r*) } - .rela.rodata : { *(.rela.rodata) *(.rela.gnu.linkonce.r*) } - .rel.got : { *(.rel.got) } - .rela.got : { *(.rela.got) } - .rel.ctors : { *(.rel.ctors) } - .rela.ctors : { *(.rela.ctors) } - .rel.dtors : { *(.rel.dtors) } - .rela.dtors : { *(.rela.dtors) } - .rel.init : { *(.rel.init) } - .rela.init : { *(.rela.init) } - .rel.fini : { *(.rel.fini) } - .rela.fini : { *(.rela.fini) } - .rel.bss : { *(.rel.bss) } - .rela.bss : { *(.rela.bss) } - .rel.plt : { *(.rel.plt) } - .rela.plt : { *(.rela.plt) } - .init : { *(.init) } =0x9090 - .plt : { *(.plt) } - .text : - { - *(.text) - *(.text.d) /* INIT */ - *(.text.e) /* RARE */ - *(.text.c) /* CMD1 */ - *(.text.a) /* CORE */ - *(.text.f) /* DBUG */ - *(.text.b) /* CFG1 */ - *(.stub) - *(.gnu.warning) - *(.gnu.linkonce.t*) - } =0x9090 - _etext = .; - PROVIDE (etext = .); - .fini : { *(.fini) } =0x9090 - .rodata : { *(.rodata) *(.gnu.linkonce.r*) } - .rodata1 : { *(.rodata1) } - . = ALIGN(0x1000) + (. & (0x1000 - 1)); - .data : - { - *(.data) - *(.gnu.linkonce.d*) - CONSTRUCTORS - } - .data1 : { *(.data1) } - .ctors : { *(.ctors) } - .dtors : { *(.dtors) } - .got : { *(.got.plt) *(.got) } - .dynamic : { *(.dynamic) } - .sdata : { *(.sdata) } - _edata = .; - PROVIDE (edata = .); - __bss_start = .; - .sbss : { *(.sbss) *(.scommon) } - .bss : - { - *(.dynbss) - *(.bss) - *(COMMON) - } - . = ALIGN(32 / 8); - _end = . ; - PROVIDE (end = .); - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .debug 0 : { *(.debug) } - .line 0 : { *(.line) } - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_sfnames 0 : { *(.debug_sfnames) } - .debug_aranges 0 : { *(.debug_aranges) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_info 0 : { *(.debug_info) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_line 0 : { *(.debug_line) } - .debug_frame 0 : { *(.debug_frame) } - .debug_str 0 : { *(.debug_str) } - .debug_loc 0 : { *(.debug_loc) } - .debug_macinfo 0 : { *(.debug_macinfo) } - .debug_weaknames 0 : { *(.debug_weaknames) } - .debug_funcnames 0 : { *(.debug_funcnames) } - .debug_typenames 0 : { *(.debug_typenames) } - .debug_varnames 0 : { *(.debug_varnames) } -} diff --git a/src/mega.c b/src/mega.c index 4d34a39..c70b3c3 100644 --- a/src/mega.c +++ b/src/mega.c @@ -24,6 +24,7 @@ #include "function.c" #include "greet.c" #include "help.c" +#include "hostinfo.c" #include "irc.c" #include "kicksay.c" #include "main.c" diff --git a/src/ons.c b/src/ons.c index 2762ecf..89cb8e8 100644 --- a/src/ons.c +++ b/src/ons.c @@ -449,9 +449,10 @@ recheck_alias: { if (!Strcasecmp(alias->alias,command)) { - afmt(amem,alias->format,msg); + unchop(command,msg); + afmt(amem,alias->format,command); #ifdef DEBUG - debug("(on_msg) [ALIAS] %s %s --> %s\n",command,msg,amem); + debug("(on_msg) [ALIAS] %s --> %s\n",command,amem); #endif /* DEBUG */ msg = amem; pt = chop(&msg);