mirror of
https://github.com/EnergyMech/energymech.git
synced 2025-12-17 15:36:50 +00:00
myconfig, configure option testing and fixing, monitor_fs()
This commit is contained in:
parent
db4842c42e
commit
5f0fdada3e
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@
|
||||
|
||||
|
||||
# autogenerated files
|
||||
myconfig
|
||||
src/Makefile
|
||||
src/config.h
|
||||
src/mcmd.h
|
||||
|
||||
2
Makefile
2
Makefile
@ -58,7 +58,7 @@ TRIVFILES = trivia/mkindex.c
|
||||
SRCFILES = src/alias.c src/auth.c src/bounce.c src/channel.c src/core.c src/ctcp.c src/debug.c src/dns.c \
|
||||
src/function.c src/gencmd.c src/greet.c src/help.c src/hostinfo.c src/irc.c src/kicksay.c src/main.c src/mega.c \
|
||||
src/net.c src/note.c src/notify.c src/ons.c src/parse.c src/partyline.c src/perl.c src/prot.c \
|
||||
src/python.c src/reset.c src/seen.c src/shit.c src/socket.c src/spy.c src/tcl.c \
|
||||
src/python.c src/reset.c src/seen.c src/shit.c src/io.c src/spy.c src/tcl.c \
|
||||
src/toybox.c src/trivia.c src/uptime.c src/user.c src/vars.c src/web.c \
|
||||
src/lib/md5.c src/lib/md5.h src/lib/string.c
|
||||
|
||||
|
||||
2
VERSIONS
2
VERSIONS
@ -1,5 +1,7 @@
|
||||
3.1 -- WORK IN PROGRESS (~April, 2018)
|
||||
|
||||
* Added: configure now saves the options selected in ./myconfig for later re-use
|
||||
* Fixed: Missing ifdef BOTNET in user.c
|
||||
* Added: Git version hash included in version string if git environment is found.
|
||||
* Added: RAND command (toybox). Usage: RAND [[min[-| ]]max|"nick"|"luser"]
|
||||
* Added: Energymech can now link with libmusl (--with-libmusl[=/PATH/TO/musl-gcc])
|
||||
|
||||
62
configure
vendored
62
configure
vendored
@ -879,6 +879,8 @@ fi
|
||||
#
|
||||
if [ "$has_md5" = yes ]; then
|
||||
echo "checking for MD5 in crypt() ... (cached) yes"
|
||||
elif [ "$ft_md5" = no ]; then
|
||||
has_md5=notest
|
||||
elif [ ! "$ft_md5" = no ]; then
|
||||
TESTC=config/pw.c
|
||||
echo $ac_n "checking for MD5 in crypt() ... "$ac_c
|
||||
@ -922,7 +924,9 @@ fi
|
||||
has_perl=no
|
||||
perlinclude=
|
||||
libperl=
|
||||
if [ ! "$ft_perl" = no ]; then
|
||||
if [ "$ft_perl" = no ]; then
|
||||
has_perl=notest
|
||||
elif [ ! "$ft_perl" = no ]; then
|
||||
echo $ac_n "checking for perl ... "$ac_c
|
||||
pinc1=`perl -MConfig -e 'print $Config{archlib}'`
|
||||
if [ -r $pinc1/CORE/perl.h -a -r $pinc1/CORE/EXTERN.h -a -r $pinc1/CORE/XSUB.h ]; then
|
||||
@ -943,7 +947,9 @@ fi
|
||||
# check for tcl
|
||||
#
|
||||
has_tcl=no
|
||||
if [ ! "$ft_tcl" = no ]; then
|
||||
if [ "$ft_tcl" = no ]; then
|
||||
has_tcl=notest
|
||||
elif [ ! "$ft_tcl" = no ]; then
|
||||
echo $ac_n "checking for tcl ... "$ac_c
|
||||
TESTC=config/tcl.c
|
||||
tclconfig=
|
||||
@ -990,7 +996,9 @@ fi
|
||||
# check for python
|
||||
#
|
||||
has_python=no
|
||||
if [ ! "$ft_python" = no ]; then
|
||||
if [ "$ft_python" = no ]; then
|
||||
has_python=notest
|
||||
elif [ ! "$ft_python" = no ]; then
|
||||
echo $ac_n "checking for python ... "$ac_c
|
||||
TESTC=config/python.c
|
||||
libpython=
|
||||
@ -1266,6 +1274,8 @@ unset ans
|
||||
$out $ac_n "[STABLE] Password hashing with MD5? (less secure) ... [Y/n] "$ac_c
|
||||
if [ "$has_md5" = no ]; then
|
||||
$out 'no (unsupported)'
|
||||
elif [ "$has_md5" = notest ]; then
|
||||
$out 'no'
|
||||
else
|
||||
test "$ft_md5" && $out "$ft_md5" && ans=$ft_md5
|
||||
test -z "$ft_md5" && read ans
|
||||
@ -1283,14 +1293,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
|
||||
|
||||
#
|
||||
# perl support not yet functional (2009-05-11)
|
||||
#
|
||||
def_perl='#undef PERL'
|
||||
unset ans
|
||||
$out $ac_n "[ ALPHA] Scripting with Perl? ....................... [y/N] "$ac_c
|
||||
if [ "$has_perl" = no ]; then
|
||||
$out 'no (unsupported)'
|
||||
elif [ "$has_perl" = notest ]; then
|
||||
$out 'no'
|
||||
else
|
||||
test "$ft_perl" && $out "$ft_perl" && ans=$ft_perl
|
||||
test -z "$ft_perl" && read ans
|
||||
@ -1302,6 +1311,8 @@ unset ans
|
||||
$out $ac_n "[ BETA ] Scripting with Python? ..................... [y/N] "$ac_c
|
||||
if [ "$has_python" = no ]; then
|
||||
$out 'no (unsupported)'
|
||||
elif [ "$has_python" = notest ]; then
|
||||
$out 'no'
|
||||
else
|
||||
test "$ft_python" && $out "$ft_python" && ans=$ft_python
|
||||
test -z "$ft_python" && read ans
|
||||
@ -1317,6 +1328,8 @@ unset ans
|
||||
$out $ac_n "[ BETA ] Scripting with Tcl? ........................ [y/N] "$ac_c
|
||||
if [ "$has_tcl" = no ]; then
|
||||
$out 'no (unsupported)'
|
||||
elif [ "$has_tcl" = notest ]; then
|
||||
$out 'no'
|
||||
else
|
||||
test "$ft_tcl" && $out "$ft_tcl" && ans=$ft_tcl
|
||||
test -z "$ft_tcl" && read ans
|
||||
@ -1496,17 +1509,46 @@ if [ "$compile" = yes ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
save_myconfig() {
|
||||
names="alias botnet bounce chanban ctcp dccfile debug dynamode dyncmd greet hostinfo idwrap ircd_ext libmusl md5
|
||||
netcfg newbie note notify perl profiling python rawdns redirect seen session sha stats suppress tcl
|
||||
telnet toybox trivia uptime urlcapture web wingate"
|
||||
echo "./configure \\" > ./myconfig
|
||||
chmod 755 ./myconfig
|
||||
for uu in $names
|
||||
do
|
||||
eval v="\$ft_$uu"
|
||||
case "$v" in
|
||||
yes) echo "--with-"$uu" \\" >> ./myconfig ;;
|
||||
no) echo "--without-"$uu" \\" >> ./myconfig ;;
|
||||
esac
|
||||
done
|
||||
test "$compile" = yes && echo "--compile \\" >> ./myconfig
|
||||
test "$install" = yes && echo "--install \\" >> ./myconfig
|
||||
test "$silentopt" = yes && echo "--silence=options \\" >> ./myconfig
|
||||
test "$ft_md5" = internal && echo "--md5=internal \\" >> ./myconfig
|
||||
test "$ft_sha" = internal && echo "--sha=internal \\" >> ./myconfig
|
||||
test "$optitype" = speed && echo "--optimize=speed \\" >> ./myconfig
|
||||
test "$optitype" = size && echo "--optimize=size \\" >> ./myconfig
|
||||
test "$cc_ofp_opt" = yes && echo "--use-ofp \\" >> ./myconfig
|
||||
test "$cc_ofp_opt" = yes && echo "--no-ofp \\" >> ./myconfig
|
||||
test ! "$try_libmusl" = no -a -x "$CC" && echo "--with-libmusl="$CC" \\" >> ./myconfig
|
||||
}
|
||||
|
||||
if [ -w ./myconfig -o ! -e ./myconfig ]; then
|
||||
save_myconfig
|
||||
fi
|
||||
|
||||
echo ''
|
||||
echo 'All done. You can now "make install"'
|
||||
if [ ! "$cores" = 1 ]; then
|
||||
echo "For speedy compiling, use \`\`make -j$cores''"
|
||||
fi
|
||||
echo ''
|
||||
echo "Your chosen ./configure options have been saved to ./myconfig"
|
||||
echo 'if you wish to save ./myconfig in its current state, chmod -w ./myconfig'
|
||||
echo ''
|
||||
echo 'Submit your bugreports at https://github.com/MadCamel/energymech/issues'
|
||||
echo ''
|
||||
echo 'You have read the README file I hope?'
|
||||
echo ''
|
||||
|
||||
# make: 7.962u 0.870s 0:08.52 103.6% 0+0k 0+0io 0pf+0w
|
||||
# make -j4: 8.779u 1.069s 0:03.11 316.0% 0+0k 0+0io 0pf+0w
|
||||
# make -j8: 8.977u 1.064s 0:02.92 343.4% 0+0k 0+0io 0pf+0w
|
||||
|
||||
@ -48,13 +48,13 @@ INCS = $(BASEINCLUDES) mcmd.h text.h usercombo.h
|
||||
TESTFILES = aliastest safepathtest
|
||||
|
||||
OFILES = alias.o auth.o bounce.o channel.o core.o ctcp.o debug.o dns.o function.o greet.o \
|
||||
help.o hostinfo.o irc.o kicksay.o main.o net.o note.o notify.o ons.o parse.o partyline.o \
|
||||
perl.o prot.o python.o reset.o seen.o shit.o socket.o spy.o tcl.o toybox.o \
|
||||
help.o hostinfo.o io.o irc.o kicksay.o main.o net.o note.o notify.o ons.o parse.o partyline.o \
|
||||
perl.o prot.o python.o reset.o seen.o shit.o spy.o tcl.o toybox.o \
|
||||
trivia.o uptime.o user.o vars.o web.o lib/string.o @MD5_O@ @SHA_O@
|
||||
|
||||
SRCFILES = alias.c auth.c bounce.c channel.c core.c ctcp.c debug.c dns.c function.c greet.c \
|
||||
help.c hostinfo.c irc.c kicksay.c main.c net.c note.c notify.c ons.c parse.c partyline.c \
|
||||
perl.c prot.c python.c reset.c seen.c shit.c socket.c spy.c tcl.c toybox.c \
|
||||
help.c hostinfo.c io.c irc.c kicksay.c main.c net.c note.c notify.c ons.c parse.c partyline.c \
|
||||
perl.c prot.c python.c reset.c seen.c shit.c spy.c tcl.c toybox.c \
|
||||
trivia.c uptime.c user.c vars.c web.c lib/string.c @MD5_C@ @SHA_C@
|
||||
|
||||
.PHONY: all clean mega-install mega mega-static test commands
|
||||
@ -66,7 +66,7 @@ all: $(INSTALLNAME)
|
||||
# instead of doing extra parsing and handling while the bot is running.
|
||||
#
|
||||
|
||||
gencmd: gencmd.c socket.c config.h structs.h
|
||||
gencmd: gencmd.c io.c config.h structs.h
|
||||
$(CC) $(LFLAGS) -o gencmd gencmd.c
|
||||
|
||||
mcmd.h: gencmd
|
||||
@ -182,6 +182,9 @@ help.o: help.c $(INCS) usage.h
|
||||
hostinfo.o: hostinfo.c $(INCS)
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF)
|
||||
|
||||
io.o: io.c $(INCS)
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF)
|
||||
|
||||
irc.o: irc.c $(INCS)
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF)
|
||||
|
||||
@ -227,9 +230,6 @@ seen.o: seen.c $(INCS)
|
||||
shit.o: shit.c $(INCS)
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF)
|
||||
|
||||
socket.o: socket.c $(INCS)
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF)
|
||||
|
||||
spy.o: spy.c $(INCS)
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF)
|
||||
|
||||
|
||||
@ -478,8 +478,8 @@ listcheck:
|
||||
checksum = "";
|
||||
if (user->pass)
|
||||
{
|
||||
sprintf(gsockdata,"%s %s %s",from,user->name,user->pass);
|
||||
checksum = makepass(gsockdata);
|
||||
sprintf(globaldata,"%s %s %s",from,user->name,user->pass);
|
||||
checksum = makepass(globaldata);
|
||||
}
|
||||
botnet_relay(NULL,"PA%s %s %s\n",user->name,from,checksum);
|
||||
#endif /* BOTNET */
|
||||
|
||||
@ -1059,8 +1059,8 @@ void update(SequenceTime *this)
|
||||
temp = TEXT_NOTINSERVLIST;
|
||||
if ((sp = find_server(current->server)))
|
||||
{
|
||||
sprintf(gsockdata,"%s:%i",(*sp->realname) ? sp->realname : sp->name,sp->port);
|
||||
temp = gsockdata;
|
||||
sprintf(globaldata,"%s:%i",(*sp->realname) ? sp->realname : sp->name,sp->port);
|
||||
temp = globaldata;
|
||||
}
|
||||
chantemp = (current->activechan) ? current->activechan->name : TEXT_NONE;
|
||||
send_spy(SPYSTR_STATUS,"C:%s AC:%i CS:%s",chantemp,x,temp);
|
||||
|
||||
16
src/debug.c
16
src/debug.c
@ -26,6 +26,9 @@
|
||||
#include "defines.h"
|
||||
#include "structs.h"
|
||||
#include "global.h"
|
||||
#ifdef TCL
|
||||
#include <tcl.h>
|
||||
#endif
|
||||
#include "h.h"
|
||||
#include "settings.h"
|
||||
|
||||
@ -231,11 +234,12 @@ LS struct
|
||||
#ifdef SCRIPTING
|
||||
LS const DEFstruct SCRIPTdefs[] =
|
||||
{
|
||||
{ HOOK_PARSE, "HOOK_PARSE" },
|
||||
{ HOOK_TIMER, "HOOK_TIMER" },
|
||||
{ HOOK_COMMAND, "HOOK_COMMAND" },
|
||||
{ HOOK_BOTNET, "HOOK_BOTNET" },
|
||||
{ HOOK_DCC_COMPLETE, "HOOK_DCC_COMPLETE" },
|
||||
{ MEV_PARSE, "MEV_PARSE" },
|
||||
{ MEV_TIMER, "MEV_TIMER" },
|
||||
{ MEV_COMMAND, "MEV_COMMAND" },
|
||||
{ MEV_BOTNET, "MEV_BOTNET" },
|
||||
{ MEV_DCC_COMPLETE, "MEV_DCC_COMPLETE" },
|
||||
{ MEV_DNSRESULT, "MEV_DNSRESULT" },
|
||||
#ifdef TCL
|
||||
{ .v.func=tcl_timer_jump, "tcl_timer_jump" },
|
||||
{ .v.func=tcl_parse_jump, "tcl_parse_jump" },
|
||||
@ -1293,7 +1297,7 @@ void debug_scripthook(void)
|
||||
debug(" ; func\t\t"mx_pfmt" %s\n",(mx_ptr)h->func,funcdef(SCRIPTdefs,h->func));
|
||||
debug(" ; guid\t\t%i\n",h->guid);
|
||||
debug(" ; flags\t\t%s (%i)\n",strdef(SCRIPTdefs,h->flags),h->flags);
|
||||
if (h->flags == HOOK_TIMER)
|
||||
if (h->flags == MEV_TIMER)
|
||||
{
|
||||
debug(" ; timer\t\t"mx_pfmt"\n",(mx_ptr)h->type.timer);
|
||||
debug(" ; timer.second1\t%s ( 0..29)\n",uint32tobin(30,h->type.timer->second1));
|
||||
|
||||
@ -406,6 +406,9 @@ enum {
|
||||
#ifdef URLCAPTURE
|
||||
#define SPY_URL 8
|
||||
#endif /* URLCAPTURE */
|
||||
#ifdef HOSTINFO
|
||||
#define SPY_SYSMON 9
|
||||
#endif /* HOSTINFO */
|
||||
|
||||
#define SPYF_ANY 1
|
||||
#define SPYF_CHANNEL (1 << SPY_CHANNEL)
|
||||
@ -456,14 +459,14 @@ enum {
|
||||
#endif /* __CYGWIN__ */
|
||||
|
||||
/*
|
||||
* scripting hooks
|
||||
* scripting events
|
||||
*/
|
||||
#define HOOK_PARSE 0
|
||||
#define HOOK_TIMER 1
|
||||
#define HOOK_COMMAND 2
|
||||
#define HOOK_BOTNET 3
|
||||
#define HOOK_DCC_COMPLETE 4
|
||||
#define HOOK_DNS 5
|
||||
#define MEV_PARSE 0
|
||||
#define MEV_TIMER 1
|
||||
#define MEV_COMMAND 2
|
||||
#define MEV_BOTNET 3
|
||||
#define MEV_DCC_COMPLETE 4
|
||||
#define MEV_DNSRESULT 5
|
||||
|
||||
/*
|
||||
*
|
||||
|
||||
@ -208,7 +208,7 @@ void dns_hook(char *host, char * resolved)
|
||||
backbot = current;
|
||||
for(hook=hooklist;hook;hook=hook->next)
|
||||
{
|
||||
if (hook->flags == HOOK_DNS && !stringcasecmp(host,hook->type.host))
|
||||
if (hook->flags == MEV_DNSRESULT && !stringcasecmp(host,hook->type.host))
|
||||
{
|
||||
for(current=botlist;current;current=current->next)
|
||||
{
|
||||
@ -881,7 +881,7 @@ void do_dns(COMMAND_ARGS)
|
||||
/* flip an IP backwards to resolve hostname */
|
||||
// a11.b22.c33.d44
|
||||
// d44.c33.b22.a11.in-addr.arpa
|
||||
dst = gsockdata;
|
||||
dst = globaldata;
|
||||
flipstep:
|
||||
src = host;
|
||||
dot = NULL;
|
||||
@ -902,9 +902,9 @@ flipstep:
|
||||
}
|
||||
stringcpy(stringcpy(dst,host),".in-addr.arpa");
|
||||
#ifdef DEBUG
|
||||
debug("(do_dns) host flipped to %s\n",gsockdata);
|
||||
debug("(do_dns) host flipped to %s\n",globaldata);
|
||||
#endif /* DEBUG */
|
||||
host = gsockdata;
|
||||
host = globaldata;
|
||||
}
|
||||
/* check if its in cache now */
|
||||
if ((res = poll_rawdns(host)))
|
||||
|
||||
@ -230,7 +230,7 @@ void table_buffer(const char *format, ...)
|
||||
int sz;
|
||||
|
||||
va_start(msg,format);
|
||||
sz = sizeof(Strp) + vsprintf(gsockdata,format,msg);
|
||||
sz = sizeof(Strp) + vsprintf(globaldata,format,msg);
|
||||
va_end(msg);
|
||||
|
||||
for(sp=&e_table;*sp;sp=&(*sp)->next)
|
||||
@ -239,7 +239,7 @@ void table_buffer(const char *format, ...)
|
||||
set_mallocdoer(table_buffer);
|
||||
*sp = (Strp*)Calloc(sz);
|
||||
/* Calloc sets to zero (*sp)->next = NULL; */
|
||||
stringcpy((*sp)->p,gsockdata);
|
||||
stringcpy((*sp)->p,globaldata);
|
||||
}
|
||||
|
||||
void table_send(const char *from, const int space)
|
||||
|
||||
@ -22,9 +22,9 @@
|
||||
#include "config.h"
|
||||
#include "structs.h"
|
||||
|
||||
char gsockdata[MAXLEN];
|
||||
char globaldata[MAXLEN];
|
||||
|
||||
#include "socket.c"
|
||||
#include "io.c"
|
||||
|
||||
/*
|
||||
|
||||
|
||||
18
src/global.h
18
src/global.h
@ -68,6 +68,9 @@ BEG const char SPYSTR_BOTNET[] MDEF("botnet");
|
||||
#ifdef URLCAPTURE
|
||||
BEG const char SPYSTR_URL[] MDEF("url");
|
||||
#endif /* URLCAPTURE */
|
||||
#ifdef URLCAPTURE
|
||||
BEG const char SPYSTR_SYSMON[] MDEF("sysmon");
|
||||
#endif /* URLCAPTURE */
|
||||
|
||||
BEG const char STR_MECHRESET[] MDEF("MECHRESET=");
|
||||
|
||||
@ -117,7 +120,7 @@ BEG User __internal_users[2];
|
||||
* generic output buffer, can be used as buffer in any `leaf' function
|
||||
* (functions that do not call any other non-trivial functions)
|
||||
*/
|
||||
BEG char gsockdata[MAXLEN];
|
||||
BEG char globaldata[MAXLEN];
|
||||
BEG char nick_buf[MAXHOSTLEN];
|
||||
BEG char nuh_buf[NUHLEN];
|
||||
|
||||
@ -452,6 +455,19 @@ LS coreServerGroup defaultServerGroup =
|
||||
"default" /* name */
|
||||
};
|
||||
|
||||
LS struct
|
||||
{
|
||||
const char *string;
|
||||
const int id;
|
||||
|
||||
} meventstrings[] = {
|
||||
{ "parse", MEV_PARSE },
|
||||
{ "timer", MEV_TIMER },
|
||||
{ "command", MEV_COMMAND },
|
||||
{ "botnet", MEV_BOTNET },
|
||||
{ "dcc_complete", MEV_DCC_COMPLETE },
|
||||
{ "dnsresult", MEV_DNSRESULT }};
|
||||
|
||||
#else /* MAIN_C */
|
||||
|
||||
extern const uchar tolowertab[];
|
||||
|
||||
91
src/h.h
91
src/h.h
@ -327,12 +327,33 @@ void do_usage(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
|
||||
/* hostinfo.c */
|
||||
|
||||
void monitor_fs(const char *);
|
||||
void select_monitor();
|
||||
void process_monitor();
|
||||
int parse_proc_status(char *line) __page(CMD1_SEG);
|
||||
int parse_proc_cpuinfo(char *line) __page(CMD1_SEG);
|
||||
void do_hostinfo(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
void do_meminfo(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
void do_cpuinfo(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
|
||||
/* io.c */
|
||||
|
||||
LS uint32_t get_ip(const char *) __page(CORE_SEG);
|
||||
LS void SockFlags(int) __page(CORE_SEG);
|
||||
LS int SockOpts(void) __page(CORE_SEG);
|
||||
LS int SockListener(int) __page(CORE_SEG);
|
||||
LS int SockConnect(char *, int, int) __page(CORE_SEG);
|
||||
LS int SockAccept(int) __page(CORE_SEG);
|
||||
int to_file(int sock, const char *format, ...);
|
||||
void to_server(char *format, ...);
|
||||
void to_user_q(const char *, const char *, ...);
|
||||
void to_user(const char *, const char *, ...);
|
||||
char *sockread(int, char *, char *);
|
||||
void readline(int, int (*)(char *));
|
||||
void remove_ks(KillSock *);
|
||||
int killsock(int);
|
||||
LS void do_clearqueue(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
|
||||
/* irc.c */
|
||||
|
||||
LS void make_ireq(int, const char *, const char *) __page(CMD1_SEG);
|
||||
@ -426,9 +447,6 @@ void select_botnet(void);
|
||||
void process_botnet(void);
|
||||
void do_link(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
void do_cmd(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
/* net_chan.c */
|
||||
|
||||
|
||||
|
||||
/* note.c */
|
||||
|
||||
@ -555,20 +573,24 @@ LS void do_unban(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
LS void do_banlist(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
|
||||
/* python.c */
|
||||
|
||||
#ifdef PYTHON
|
||||
|
||||
char *python_unicode2char(PyUnicodeObject *obj);
|
||||
#ifdef DEBUG_C
|
||||
PyObject *python_hook(PyObject *self, PyObject *args, PyObject *keywds);
|
||||
PyObject *python_unhook(PyObject *self, PyObject *args, PyObject *keywds);
|
||||
#endif
|
||||
//char *python_unicode2char(PyUnicodeObject *obj);
|
||||
//PyObject *python_userlevel(PyObject *self, PyObject *args, PyObject *keywds);
|
||||
//PyObject *python_to_server(PyObject *self, PyObject *args, PyObject *keywds);
|
||||
//PyObject *python_to_file(PyObject *self, PyObject *args, PyObject *keywds);
|
||||
//static PyObject *python_dcc_sendfile(PyObject *self, PyObject *args, PyObject *keywds);
|
||||
//PyObject *python_debug(PyObject *self, PyObject *args);
|
||||
//PyMODINIT_FUNC pythonInit(void);
|
||||
int python_parse_jump(char *, char *, Hook *);
|
||||
int python_timer_jump(Hook *hook);
|
||||
void python_dcc_complete(Client *client, int cps);
|
||||
PyObject *python_userlevel(PyObject *self, PyObject *args, PyObject *keywds);
|
||||
PyObject *python_to_server(PyObject *self, PyObject *args, PyObject *keywds);
|
||||
PyObject *python_to_file(PyObject *self, PyObject *args, PyObject *keywds);
|
||||
static PyObject *python_dcc_sendfile(PyObject *self, PyObject *args, PyObject *keywds);
|
||||
PyObject *python_debug(PyObject *self, PyObject *args);
|
||||
int python_dns_jump(char *host, char *resolved, Hook *hook);
|
||||
PyMODINIT_FUNC pythonInit(void);
|
||||
void init_python(void);
|
||||
void free_python(void);
|
||||
void do_python(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
@ -576,12 +598,6 @@ void do_pythonscript(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
|
||||
#endif /* PYTHON */
|
||||
|
||||
/* redirect.c */
|
||||
|
||||
int begin_redirect(char *, char *);
|
||||
void send_redirect(char *);
|
||||
void end_redirect(void);
|
||||
|
||||
/* reset.c */
|
||||
|
||||
char *recover_client(char *env);
|
||||
@ -613,24 +629,6 @@ void do_rshit(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
void do_shitlist(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
void do_clearshit(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
|
||||
/* socket.c */
|
||||
|
||||
LS uint32_t get_ip(const char *) __page(CORE_SEG);
|
||||
LS void SockFlags(int) __page(CORE_SEG);
|
||||
LS int SockOpts(void) __page(CORE_SEG);
|
||||
LS int SockListener(int) __page(CORE_SEG);
|
||||
LS int SockConnect(char *, int, int) __page(CORE_SEG);
|
||||
LS int SockAccept(int) __page(CORE_SEG);
|
||||
int to_file(int sock, const char *format, ...);
|
||||
void to_server(char *format, ...);
|
||||
void to_user_q(const char *, const char *, ...);
|
||||
void to_user(const char *, const char *, ...);
|
||||
char *sockread(int, char *, char *);
|
||||
void readline(int, int (*)(char *));
|
||||
void remove_ks(KillSock *);
|
||||
int killsock(int);
|
||||
LS void do_clearqueue(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
|
||||
/* spy.c */
|
||||
|
||||
void send_spy(const char *src, const char *format, ...);
|
||||
@ -639,6 +637,9 @@ void spy_typecount(Mech *bot);
|
||||
int spy_source(char *from, int *t_src, const char **src);
|
||||
char *urlhost(const char *);
|
||||
LS void urlcapture(const char *) __page(CORE_SEG);
|
||||
int begin_redirect(char *, char *);
|
||||
void send_redirect(char *);
|
||||
void end_redirect(void);
|
||||
void stats_loghour(Chan *chan, char *filename, int hour);
|
||||
void stats_plusminususer(Chan *chan, int plusminus);
|
||||
void do_spy(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
@ -649,20 +650,22 @@ LS void do_urlhist(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
/* tcl.c */
|
||||
#ifdef TCL
|
||||
|
||||
LS char *tcl_var_read(Tcl_TVInfo *vinfo, Tcl_Interp *I, char *n1, char *n2, int flags);
|
||||
LS char *tcl_var_write(Tcl_TVInfo *vinfo, Tcl_Interp *I, char *n1, char *n2, int flags);
|
||||
//LS char *tcl_var_read(Tcl_TVInfo *vinfo, Tcl_Interp *I, char *n1, char *n2, int flags);
|
||||
//LS char *tcl_var_write(Tcl_TVInfo *vinfo, Tcl_Interp *I, char *n1, char *n2, int flags);
|
||||
LS int tcl_timer_jump(Hook *hook);
|
||||
LS int tcl_parse_jump(char *from, char *rest, Hook *hook);
|
||||
LS void tcl_dcc_complete(Client *client, int cps);
|
||||
#ifdef DEBUG_C
|
||||
LS int tcl_hook(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]);
|
||||
LS int tcl_unhook(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]);
|
||||
LS int tcl_userlevel(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]);
|
||||
LS int tcl_debug(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]);
|
||||
LS int tcl_to_server(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]);
|
||||
LS int tcl_to_file(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]);
|
||||
LS int tcl_dcc_sendfile(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]);
|
||||
LS int tcl_dns_jump(char *host, char *resolved, Hook *hook);
|
||||
LS int tcl_dns(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]);
|
||||
#endif
|
||||
//LS int tcl_unhook(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]);
|
||||
//LS int tcl_userlevel(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]);
|
||||
//LS int tcl_debug(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]);
|
||||
//LS int tcl_to_server(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]);
|
||||
//LS int tcl_to_file(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]);
|
||||
//LS int tcl_dcc_sendfile(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]);
|
||||
//LS int tcl_dns_jump(char *host, char *resolved, Hook *hook);
|
||||
//LS int tcl_dns(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]);
|
||||
LS void init_tcl(void);
|
||||
LS void do_tcl(COMMAND_ARGS) __page(CMD1_SEG);
|
||||
|
||||
|
||||
104
src/hostinfo.c
104
src/hostinfo.c
@ -20,14 +20,13 @@
|
||||
*/
|
||||
#define HOSTINFO_C
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HOSTINFO
|
||||
#include "defines.h"
|
||||
#include "structs.h"
|
||||
#include "global.h"
|
||||
#include "h.h"
|
||||
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/inotify.h>
|
||||
|
||||
/*
|
||||
Emulate this, but use the same memory space:
|
||||
@ -279,11 +278,11 @@ void do_cpuinfo(COMMAND_ARGS)
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
n = read(fd,gsockdata,MSGLEN-2);
|
||||
gsockdata[n] = 0;
|
||||
n = read(fd,globaldata,MSGLEN-2);
|
||||
globaldata[n] = 0;
|
||||
close(fd);
|
||||
|
||||
rest = gsockdata;
|
||||
rest = globaldata;
|
||||
a1 = chop(&rest);
|
||||
a2 = chop(&rest);
|
||||
a3 = chop(&rest);
|
||||
@ -316,4 +315,99 @@ void do_cpuinfo(COMMAND_ARGS)
|
||||
omni+1,bogostr,cpustr,a1,a2,a3);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
struct
|
||||
{
|
||||
int value;
|
||||
char *str;
|
||||
|
||||
} in2str[] =
|
||||
{
|
||||
{ IN_ACCESS, "IN_ACCESS" }, // File was accessed (read)
|
||||
{ IN_ATTRIB, "IN_ATTRIB" }, // Metadata changed, e.g., permissions, timestamps, extended attributes, link count, UID, GID, etc.
|
||||
{ IN_CLOSE_WRITE, "IN_CLOSE_WRITE" }, // File opened for writing was closed
|
||||
{ IN_CLOSE_NOWRITE, "IN_CLOSE_NOWRITE" }, // File not opened for writing was closed
|
||||
{ IN_CREATE, "IN_CREATE" }, // File/directory created in watched directory
|
||||
{ IN_DELETE, "IN_DELETE" }, // File/directory deleted from watched directory
|
||||
{ IN_DELETE_SELF, "IN_DELETE_SELF" }, // Watched file/directory was itself deleted
|
||||
{ IN_MODIFY, "IN_MODIFY" }, // File was modified
|
||||
{ IN_MOVE_SELF, "IN_MOVE_SELF" }, // Watched file/directory was itself moved
|
||||
{ IN_MOVED_FROM, "IN_MOVED_FROM" }, // Generated for the directory containing the old filename when a file is renamed
|
||||
{ IN_MOVED_TO, "IN_MOVED_TO" }, // Generated for the directory containing the new filename when a file is renamed
|
||||
{ IN_OPEN, "IN_OPEN" }, // File was opened
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
char *inomask2str(uint32_t mask, char *dst)
|
||||
{
|
||||
const char *src;
|
||||
int i,n = 0;
|
||||
|
||||
for(i=0;in2str[i].str;i++)
|
||||
{
|
||||
if ((mask & in2str[i].value) == in2str[i].value)
|
||||
{
|
||||
if (n)
|
||||
dst[n++] = '|';
|
||||
src = in2str[i].str;
|
||||
for(;src[n];n++)
|
||||
dst[n] = src[n];
|
||||
}
|
||||
}
|
||||
dst[n] = 0;
|
||||
return(dst);
|
||||
}
|
||||
|
||||
#endif /* DEBUG */
|
||||
|
||||
int ino;
|
||||
|
||||
void monitor_fs(const char *file)
|
||||
{
|
||||
struct inotify_event *ivent;
|
||||
|
||||
ino = inotify_init();
|
||||
inotify_add_watch(ino,file,IN_ALL_EVENTS);
|
||||
#ifdef DEBUG
|
||||
debug("(monitor_fs) added notifier on %s [fd %i]\n",file,ino);
|
||||
#endif
|
||||
}
|
||||
|
||||
void select_monitor()
|
||||
{
|
||||
FD_SET(ino,&read_fds);
|
||||
}
|
||||
|
||||
void process_monitor()
|
||||
{
|
||||
struct inotify_event *ivent;
|
||||
char tmp[256];
|
||||
int n;
|
||||
|
||||
if (FD_ISSET(ino,&read_fds))
|
||||
{
|
||||
ivent = (struct inotify_event *)&globaldata;
|
||||
|
||||
n = read(ino,globaldata,sizeof(struct inotify_event));
|
||||
if (ivent->len > 0)
|
||||
read(ino,ivent->name,ivent->len);
|
||||
else
|
||||
*ivent->name = 0;
|
||||
#ifdef DEBUG
|
||||
debug("ino %i, n %i, sz %i\n",ino,n,sizeof(in2str));
|
||||
debug("wd %i, mask %lu, cookie %lu, len %lu, name %s\n",
|
||||
ivent->wd,ivent->mask,ivent->cookie,ivent->len,ivent->name);
|
||||
debug("%s\n",inomask2str(ivent->mask,tmp));
|
||||
debug("(process_monitor) ino %i bytes read, int wd = %i, uint32_t mask = %s (%lu), uint32_t cookie = %lu, uint32_t len = %lu, char name = %s\n",
|
||||
n,ivent->wd,inomask2str(ivent->mask,tmp),ivent->mask,ivent->cookie,ivent->len,ivent->name);
|
||||
#endif
|
||||
if ((ivent->mask & IN_CLOSE_WRITE) == IN_CLOSE_WRITE)
|
||||
return;
|
||||
send_global(SPYSTR_SYSMON,"Alert: Executable was touched");
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* HOSTINFO */
|
||||
|
||||
@ -281,19 +281,19 @@ int to_file(int sock, const char *format, ...)
|
||||
return(-1);
|
||||
|
||||
va_start(msg,format);
|
||||
vsprintf(gsockdata,format,msg);
|
||||
vsprintf(globaldata,format,msg);
|
||||
va_end(msg);
|
||||
|
||||
#if defined(DEBUG) && !defined(GENCMD_C)
|
||||
i = write(sock,gsockdata,strlen(gsockdata));
|
||||
rest = gsockdata;
|
||||
i = write(sock,globaldata,strlen(globaldata));
|
||||
rest = globaldata;
|
||||
while((line = get_token(&rest,"\n"))) /* rest cannot be NULL */
|
||||
debug("(out) {%i} %s\n",sock,nullstr(line));
|
||||
if (i < 0)
|
||||
debug("(out) {%i} errno = %i\n",sock,errno);
|
||||
return(i);
|
||||
#else /* DEBUG */
|
||||
return(write(sock,gsockdata,strlen(gsockdata)));
|
||||
return(write(sock,globaldata,strlen(globaldata)));
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
|
||||
@ -314,7 +314,7 @@ void to_server(char *format, ...)
|
||||
return;
|
||||
|
||||
va_start(msg,format);
|
||||
vsprintf(gsockdata,format,msg);
|
||||
vsprintf(globaldata,format,msg);
|
||||
va_end(msg);
|
||||
|
||||
/*
|
||||
@ -323,7 +323,7 @@ void to_server(char *format, ...)
|
||||
*/
|
||||
current->sendq_time += 2;
|
||||
|
||||
if (write(current->sock,gsockdata,strlen(gsockdata)) < 0)
|
||||
if (write(current->sock,globaldata,strlen(globaldata)) < 0)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
debug("[StS] {%i} errno = %i\n",current->sock,errno);
|
||||
@ -334,7 +334,7 @@ void to_server(char *format, ...)
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
rest = gsockdata;
|
||||
rest = globaldata;
|
||||
while((line = get_token(&rest,"\n"))) /* rest cannot be NULL */
|
||||
debug("[StS] {%i} %s\n",current->sock,line);
|
||||
#endif /* DEBUG */
|
||||
@ -531,7 +531,7 @@ char *sockread(int s, char *rest, char *line)
|
||||
}
|
||||
rdst = src;
|
||||
|
||||
n = read(s,gsockdata,MSGLEN-2);
|
||||
n = read(s,globaldata,MSGLEN-2);
|
||||
switch(n)
|
||||
{
|
||||
case 0:
|
||||
@ -540,8 +540,8 @@ char *sockread(int s, char *rest, char *line)
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
gsockdata[n] = 0;
|
||||
src = gsockdata;
|
||||
globaldata[n] = 0;
|
||||
src = globaldata;
|
||||
|
||||
while(*src)
|
||||
{
|
||||
12
src/main.c
12
src/main.c
@ -517,6 +517,10 @@ mainloop:
|
||||
select_bounce();
|
||||
#endif /* BOUNCE */
|
||||
|
||||
#ifdef HOSTINFO
|
||||
select_monitor();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* unset here, reset if needed in bot loop
|
||||
*/
|
||||
@ -790,6 +794,10 @@ restart_die:
|
||||
process_web();
|
||||
#endif /* WEB */
|
||||
|
||||
#ifdef HOSTINFO
|
||||
process_monitor();
|
||||
#endif
|
||||
|
||||
#ifdef TRIVIA
|
||||
trivia_tick();
|
||||
#endif /* TRIVIA */
|
||||
@ -1134,6 +1142,10 @@ int main(int argc, char **argv, char **envp)
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
|
||||
#ifdef HOSTINFO
|
||||
monitor_fs(executable);
|
||||
#endif
|
||||
|
||||
if (startup == 666)
|
||||
exit(0);
|
||||
startup = FALSE;
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
#include "greet.c"
|
||||
#include "help.c"
|
||||
#include "hostinfo.c"
|
||||
#include "io.c"
|
||||
#include "irc.c"
|
||||
#include "kicksay.c"
|
||||
#include "lib/string.c"
|
||||
@ -39,7 +40,6 @@
|
||||
#include "reset.c"
|
||||
#include "seen.c"
|
||||
#include "shit.c"
|
||||
#include "socket.c"
|
||||
#include "spy.c"
|
||||
#include "tcl.c"
|
||||
#include "toybox.c"
|
||||
|
||||
12
src/net.c
12
src/net.c
@ -185,15 +185,15 @@ void botnet_relay(BotNet *source, char *format, ...)
|
||||
if (!sz)
|
||||
{
|
||||
va_start(msg,format);
|
||||
vsprintf(gsockdata,format,msg);
|
||||
vsprintf(globaldata,format,msg);
|
||||
va_end(msg);
|
||||
sz = strlen(gsockdata);
|
||||
sz = strlen(globaldata);
|
||||
}
|
||||
|
||||
if (write(bn->sock,gsockdata,sz) < 0)
|
||||
if (write(bn->sock,globaldata,sz) < 0)
|
||||
botnet_deaduplink(bn);
|
||||
#ifdef DEBUG
|
||||
debug("[bnr] {%i} %s",bn->sock,gsockdata);
|
||||
debug("[bnr] {%i} %s",bn->sock,globaldata);
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
}
|
||||
@ -927,8 +927,8 @@ void partyAuth(BotNet *bn, char *rest)
|
||||
m = 0;
|
||||
if (user->pass)
|
||||
{
|
||||
sprintf(gsockdata,"%s %s %s",userhost,user->name,user->pass);
|
||||
m = passmatch(gsockdata,checksum);
|
||||
sprintf(globaldata,"%s %s %s",userhost,user->name,user->pass);
|
||||
m = passmatch(globaldata,checksum);
|
||||
}
|
||||
if (m)
|
||||
{
|
||||
|
||||
@ -511,7 +511,7 @@ recheck_alias:
|
||||
/*
|
||||
* does the hook match?
|
||||
*/
|
||||
if (hook->flags == HOOK_COMMAND && !stringcasecmp(command,hook->type.command))
|
||||
if (hook->flags == MEV_COMMAND && !stringcasecmp(command,hook->type.command))
|
||||
{
|
||||
if (hook->func(from,rest,hook))
|
||||
/* if the hook returns non-zero, the input should not be parsed internally */
|
||||
|
||||
@ -1513,7 +1513,7 @@ void parseline(char *rest)
|
||||
/*
|
||||
* does the hook match?
|
||||
*/
|
||||
if (hook->flags == HOOK_PARSE && !stringcasecmp(command,hook->type.command))
|
||||
if (hook->flags == MEV_PARSE && !stringcasecmp(command,hook->type.command))
|
||||
{
|
||||
if (hook->func(from,rest,hook))
|
||||
/* if the hook returns non-zero, the input should not be parsed internally */
|
||||
|
||||
10
src/prot.c
10
src/prot.c
@ -40,10 +40,10 @@ void send_kick(Chan *chan, const char *nick, const char *format, ...)
|
||||
va_list vargs;
|
||||
|
||||
/*
|
||||
* gsockdata safe to use since we're a `tail' function
|
||||
* globaldata safe to use since we're a `tail' function
|
||||
*/
|
||||
va_start(vargs,format);
|
||||
vsprintf(gsockdata,format,vargs);
|
||||
vsprintf(globaldata,format,vargs);
|
||||
va_end(vargs);
|
||||
|
||||
pp = &chan->kicklist;
|
||||
@ -51,11 +51,11 @@ void send_kick(Chan *chan, const char *nick, const char *format, ...)
|
||||
pp = &(*pp)->next;
|
||||
|
||||
set_mallocdoer(send_kick);
|
||||
*pp = new = (qKick*)Calloc(sizeof(qKick) + Strlen2(nick,gsockdata)); // gsockdata is never NULL
|
||||
*pp = new = (qKick*)Calloc(sizeof(qKick) + Strlen2(nick,globaldata)); // globaldata is never NULL
|
||||
/* Calloc sets to zero new->next = NULL; */
|
||||
|
||||
new->reason = stringcpy(new->nick,nick) + 1;
|
||||
stringcpy(new->reason,gsockdata);
|
||||
stringcpy(new->reason,globaldata);
|
||||
}
|
||||
|
||||
void push_kicks(Chan *chan)
|
||||
@ -589,7 +589,7 @@ void chanban_action(char *nick, char *channel, Shit *shit)
|
||||
cu->flags |= CU_CHANBAN;
|
||||
format_uh(nuh,1); // returns mask in 'nuh' buffer (nuh_buf)
|
||||
send_mode(CurrentChan,90,QM_RAWMODE,'+','b',(void*)nuh);
|
||||
send_kick(CurrentChan,nick,"%s (%s)",shit->reason,channel); // clobbers gsockdata
|
||||
send_kick(CurrentChan,nick,"%s (%s)",shit->reason,channel); // clobbers globaldata
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
61
src/python.c
61
src/python.c
@ -52,6 +52,7 @@ char *python_unicode2char(PyUnicodeObject *obj)
|
||||
{ /* try to get a valid char* from PyUnicode object.
|
||||
returned str must be free'd afterwards. */
|
||||
int sz = PyUnicode_GET_SIZE(obj);
|
||||
|
||||
wchar_t *wcs = (wchar_t*) malloc(sizeof(wchar_t) * sz);
|
||||
PyUnicode_AsWideChar(obj, wcs, sz);
|
||||
char *cs = (char*) malloc(sizeof(char) * (sz + 1));
|
||||
@ -67,6 +68,8 @@ static PyObject *python_error; /* emech exception object */
|
||||
|
||||
static PyObject *python_getvar(PyObject *self, PyObject *args)
|
||||
{ /* get some global var */
|
||||
int vartype;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (!current)
|
||||
{
|
||||
@ -74,9 +77,10 @@ static PyObject *python_getvar(PyObject *self, PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
int vartype;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &vartype))
|
||||
return NULL;
|
||||
|
||||
switch(vartype)
|
||||
{
|
||||
case PYVAR_guid:
|
||||
@ -108,12 +112,18 @@ static PyObject *python_is_chanuser(PyObject *self, PyObject *args, PyObject *ke
|
||||
{
|
||||
char *chan, *nick;
|
||||
static char *kwlist[] = {"chan", "nick", NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, keywds, "ss", kwlist, &chan, &nick))
|
||||
return NULL;
|
||||
|
||||
Chan *ch = (Chan*) find_channel(chan, CHAN_ANY);
|
||||
if (!ch) Py_RETURN_FALSE;
|
||||
|
||||
if (!ch)
|
||||
Py_RETURN_FALSE;
|
||||
|
||||
ChanUser *cu = find_chanuser(ch, nick);
|
||||
if (!cu) Py_RETURN_FALSE;
|
||||
if (!cu)
|
||||
Py_RETURN_FALSE;
|
||||
Py_RETURN_TRUE;
|
||||
}
|
||||
|
||||
@ -125,9 +135,10 @@ static PyObject *python_do_join(PyObject *self, PyObject *args, PyObject *keywds
|
||||
char *from, *to="", *rest;
|
||||
int cmdaccess = 100;
|
||||
static char *kwlist[] = {"from", "rest", "cmdaccess", NULL};
|
||||
if (!PyArg_ParseTupleAndKeywords(args, keywds, "ss|i", kwlist,
|
||||
&from, &rest, &cmdaccess))
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, keywds, "ss|i", kwlist, &from, &rest, &cmdaccess))
|
||||
return NULL;
|
||||
|
||||
do_join(from, to, rest, cmdaccess);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
@ -150,8 +161,10 @@ static PyObject *python_do_cycle(PyObject *self, PyObject *args, PyObject *keywd
|
||||
char *from, *to, *rest="";
|
||||
int cmdaccess = 100;
|
||||
static char *kwlist[] = {"from", "to", NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, keywds, "ss", kwlist, &from, &to))
|
||||
return NULL;
|
||||
|
||||
do_cycle(from, to, rest, cmdaccess);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
@ -241,11 +254,14 @@ static PyObject *python_find_nuh(PyObject *self, PyObject *args, PyObject *keywd
|
||||
{
|
||||
char *nick, *nuh;
|
||||
static char *kwlist[] = {"nick", NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, keywds, "s", kwlist, &nick))
|
||||
return NULL;
|
||||
nuh = find_nuh(nick);
|
||||
if (nuh == NULL) Py_RETURN_NONE;
|
||||
else return Py_BuildValue("s", nuh);
|
||||
|
||||
if ((nuh = find_nuh(nick)) == NULL)
|
||||
Py_RETURN_NONE;
|
||||
else
|
||||
return Py_BuildValue("s", nuh);
|
||||
}
|
||||
|
||||
/* From core.c */
|
||||
@ -296,10 +312,9 @@ PyObject *python_hook(PyObject *self, PyObject *args, PyObject *keywds)
|
||||
PyObject *cb, *funcname;
|
||||
char *type, *command, *cbname;
|
||||
int guid = 0, mode, sz1, sz2;
|
||||
|
||||
static char *kwlist[] = {"type", "command", "callback", "guid", NULL};
|
||||
if (!PyArg_ParseTupleAndKeywords(args, keywds, "ssO|i", kwlist,
|
||||
&type, &command, &cb, &guid))
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, keywds, "ssO|i", kwlist, &type, &command, &cb, &guid))
|
||||
return NULL;
|
||||
|
||||
/* check callback function */
|
||||
@ -335,13 +350,13 @@ PyObject *python_hook(PyObject *self, PyObject *args, PyObject *keywds)
|
||||
}
|
||||
|
||||
if (!stringcasecmp(type, "command"))
|
||||
mode = HOOK_COMMAND;
|
||||
mode = MEV_COMMAND;
|
||||
else
|
||||
if (!stringcasecmp(type, "dcc_complete"))
|
||||
mode = HOOK_DCC_COMPLETE;
|
||||
mode = MEV_DCC_COMPLETE;
|
||||
else
|
||||
if (!stringcasecmp(type, "parse"))
|
||||
mode = HOOK_PARSE;
|
||||
mode = MEV_PARSE;
|
||||
else
|
||||
if (!stringcasecmp(type, "timer"))
|
||||
{
|
||||
@ -354,7 +369,7 @@ PyObject *python_hook(PyObject *self, PyObject *args, PyObject *keywds)
|
||||
PyErr_SetString(python_error, "(python_hook) cant compile timer");
|
||||
return NULL;
|
||||
}
|
||||
mode = HOOK_TIMER;
|
||||
mode = MEV_TIMER;
|
||||
sz1 = sizeof(HookTimer);
|
||||
}
|
||||
else
|
||||
@ -378,13 +393,13 @@ PyObject *python_hook(PyObject *self, PyObject *args, PyObject *keywds)
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
case HOOK_COMMAND:
|
||||
case HOOK_PARSE:
|
||||
case MEV_COMMAND:
|
||||
case MEV_PARSE:
|
||||
stringcpy(hook->type.command, command);
|
||||
hook->func = python_parse_jump;
|
||||
break;
|
||||
default:
|
||||
/* case HOOK_TIMER: */
|
||||
/* case MEV_TIMER: */
|
||||
memcpy(hook->type.timer, &hooktimer, sizeof(HookTimer));
|
||||
hook->func = python_timer_jump;
|
||||
break;
|
||||
@ -469,7 +484,7 @@ void python_dcc_complete(Client *client, int cps)
|
||||
|
||||
for (hook = hooklist; hook; hook = hook->next)
|
||||
{
|
||||
if (hook->flags == HOOK_DCC_COMPLETE &&
|
||||
if (hook->flags == MEV_DCC_COMPLETE &&
|
||||
hook->guid && current && hook->guid == current->guid)
|
||||
{
|
||||
/* get callback object */
|
||||
@ -715,7 +730,7 @@ static PyObject *python_dns(PyObject *self, PyObject *args, PyObject *keywds)
|
||||
set_mallocdoer(python_dns);
|
||||
hook = (Hook*)Calloc(sizeof(Hook) + strlen(host));
|
||||
hook->guid = (current) ? current->guid : 0;
|
||||
hook->flags = HOOK_DNS;
|
||||
hook->flags = MEV_DNSRESULT;
|
||||
hook->next = hooklist;
|
||||
hooklist = hook;
|
||||
hook->type.host = stringcpy(hook->self, cbname) + 1;
|
||||
@ -889,9 +904,9 @@ PyMODINIT_FUNC pythonInit(void)
|
||||
PyModule_AddIntConstant(m, "define_debug", 0);
|
||||
#endif /* DEBUG */
|
||||
|
||||
PyModule_AddStringConstant(m, "HOOK_COMMAND", "command");
|
||||
PyModule_AddStringConstant(m, "HOOK_PARSE", "parse");
|
||||
PyModule_AddStringConstant(m, "HOOK_TIMER", "timer");
|
||||
PyModule_AddStringConstant(m, "MEV_COMMAND", "command");
|
||||
PyModule_AddStringConstant(m, "MEV_PARSE", "parse");
|
||||
PyModule_AddStringConstant(m, "MEV_TIMER", "timer");
|
||||
PyModule_AddStringConstant(m, "DCC_COMPLETE", "dcc_complete");
|
||||
|
||||
PyModule_AddIntConstant(m, "OK", 0);
|
||||
|
||||
@ -44,6 +44,7 @@ LS const char SPY_DEFS[][12] =
|
||||
"SPY_RAWIRC",
|
||||
"SPY_BOTNET",
|
||||
"SPY_URL",
|
||||
"SPY_SYSMON",
|
||||
};
|
||||
|
||||
#endif /* DEBUG */
|
||||
@ -178,6 +179,9 @@ struct
|
||||
#ifdef URLCAPTURE
|
||||
{ SPYSTR_URL, SPY_URL },
|
||||
#endif /* URLCAPTURE */
|
||||
#ifdef HOSTINFO
|
||||
{ SPYSTR_SYSMON, SPY_SYSMON },
|
||||
#endif
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
|
||||
18
src/tcl.c
18
src/tcl.c
@ -189,7 +189,7 @@ void tcl_dcc_complete(Client *client, int cps)
|
||||
vname = Tcl_NewStringObj("_cps",3);
|
||||
for(hook=hooklist;hook;hook=hook->next)
|
||||
{
|
||||
if (hook->flags == HOOK_DCC_COMPLETE &&
|
||||
if (hook->flags == MEV_DCC_COMPLETE &&
|
||||
hook->guid && current && hook->guid == current->guid)
|
||||
{
|
||||
Tcl_SetVar(energymech_tcl,"_filetarget",client->whom,0);
|
||||
@ -234,19 +234,19 @@ int tcl_hook(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[])
|
||||
return(TCL_ERROR);
|
||||
|
||||
if (!stringcasecmp(type,"command"))
|
||||
mode = HOOK_COMMAND;
|
||||
mode = MEV_COMMAND;
|
||||
else
|
||||
if (!stringcasecmp(type,"dcc_complete"))
|
||||
mode = HOOK_DCC_COMPLETE;
|
||||
mode = MEV_DCC_COMPLETE;
|
||||
else
|
||||
if (!stringcasecmp(type,"parse"))
|
||||
mode = HOOK_PARSE;
|
||||
mode = MEV_PARSE;
|
||||
else
|
||||
if (!stringcasecmp(type,"timer"))
|
||||
{
|
||||
if (compile_timer(&hooktimer,command) < 0)
|
||||
return(TCL_ERROR);
|
||||
mode = HOOK_TIMER;
|
||||
mode = MEV_TIMER;
|
||||
sz1 = sizeof(HookTimer);
|
||||
}
|
||||
else
|
||||
@ -265,13 +265,13 @@ int tcl_hook(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[])
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
case HOOK_COMMAND:
|
||||
case HOOK_PARSE:
|
||||
case MEV_COMMAND:
|
||||
case MEV_PARSE:
|
||||
stringcpy(hook->type.command,command);
|
||||
hook->func = tcl_parse_jump;
|
||||
break;
|
||||
default:
|
||||
/* case HOOK_TIMER: */
|
||||
/* case MEV_TIMER: */
|
||||
memcpy(hook->type.timer,&hooktimer,sizeof(HookTimer));
|
||||
hook->func = tcl_timer_jump;
|
||||
break;
|
||||
@ -499,7 +499,7 @@ int tcl_dns(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[])
|
||||
set_mallocdoer(tcl_dns);
|
||||
hook = (Hook*)Calloc(sizeof(Hook) + strlen(host));
|
||||
hook->guid = (current) ? current->guid : 0;
|
||||
hook->flags = HOOK_DNS;
|
||||
hook->flags = MEV_DNSRESULT;
|
||||
hook->next = hooklist;
|
||||
hooklist = hook;
|
||||
hook->type.host = stringcpy(hook->self,callback) + 1;
|
||||
|
||||
@ -637,7 +637,7 @@ void mirror_user(User *user)
|
||||
}
|
||||
current = backup; // assume my old identity
|
||||
#ifdef DEBUG
|
||||
debug("(x)\n");
|
||||
debug("(mirror_user) %s[%i] finished\n",user->name,user->x.x.access);
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
|
||||
@ -1585,7 +1585,9 @@ void change_pass(User *user, char *pass)
|
||||
if (strlen(user->pass) <= strlen(enc))
|
||||
{
|
||||
stringcpy(user->pass,enc);
|
||||
#ifdef BOTNET
|
||||
user->modcount++;
|
||||
#endif /* BOTNET */
|
||||
}
|
||||
/*
|
||||
* password is stuck in a solid malloc in a linked list
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user