mirror of
https://github.com/EnergyMech/energymech.git
synced 2025-12-29 16:14:43 +00:00
march 9-10
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# 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
|
||||
@@ -47,7 +47,7 @@ OFILES = alias.o auth.o bounce.o chanban.o channel.o core.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@
|
||||
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 \
|
||||
@@ -58,7 +58,12 @@ SRCFILES = alias.c auth.c bounce.c chanban.c channel.c core.c \
|
||||
|
||||
all: $(INSTALLNAME)
|
||||
|
||||
mcmd.h: gencmd.c config.h structs.h ;
|
||||
#
|
||||
# mcmd.h is generated at compile time to wrap up all command attributes more efficiently,
|
||||
# instead of doing extra parsing and handling while the bot is running.
|
||||
#
|
||||
|
||||
mcmd.h: gencmd.c config.h structs.h
|
||||
$(CC) $(LFLAGS) -o gencmd gencmd.c
|
||||
./gencmd > mcmd.h
|
||||
|
||||
@@ -74,17 +79,24 @@ $(INSTALLNAME): $(OFILES)
|
||||
@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment $(INSTALLNAME)
|
||||
@sz@ size $(INSTALLNAME)
|
||||
|
||||
mega: $(SRCFILES) $(INCS) usage.h
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -o $(INSTALLNAME) mega.c $(LPROF) $(LIBS) $(LDSCRIPT) $(PYINCLUDE) $(TCLINCLUDE)
|
||||
$(INSTALLNAME)-static: $(OFILES)
|
||||
$(CROSS_COMPILE)$(CC) $(LFLAGS) -o $(INSTALLNAME) $(OFILES) $(LPROF) $(LIBS) $(LDSCRIPT) -static
|
||||
@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment $(INSTALLNAME)
|
||||
@sz@ size $(INSTALLNAME)
|
||||
|
||||
|
||||
#
|
||||
# static targets
|
||||
# 'mega' versions
|
||||
# compiling the C files all at once (having all the code "visible" during the whole process) enables GCC to make more optimizations,
|
||||
# resulting in a smaller, more efficient, binary. this process uses lots more memory at compile time.
|
||||
#
|
||||
|
||||
$(INSTALLNAME)-static: $(OFILES)
|
||||
$(CROSS_COMPILE)$(CC) $(LFLAGS) -o $(INSTALLNAME) $(OFILES) $(LPROF) $(LIBS) $(LDSCRIPT) -static
|
||||
mega-install: mega $(SRCFILES) $(INCS) usage.h
|
||||
$(CHMOD) $(INSTALLMODE) $(INSTALLNAME)
|
||||
$(MV) $(INSTALLNAME) $(INSTALLDIR)
|
||||
|
||||
mega: $(SRCFILES) $(INCS) usage.h
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -o $(INSTALLNAME) mega.c $(LPROF) $(LIBS) $(LDSCRIPT) $(PYINCLUDE) $(TCLINCLUDE)
|
||||
@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment $(INSTALLNAME)
|
||||
@sz@ size $(INSTALLNAME)
|
||||
|
||||
@@ -220,4 +232,7 @@ web.o: web.c $(INCS)
|
||||
md5/md5.o: md5/md5.c $(INCS)
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< -o $@ -Imd5 $(CPROF)
|
||||
|
||||
sha/sha1.o: sha/sha1.c $(INCS)
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< -o $@ -Isha1 $(CPROF)
|
||||
|
||||
FORCE:
|
||||
|
||||
@@ -378,6 +378,15 @@
|
||||
*/
|
||||
#define RANDOM(min,max) (min + (rand() / (RAND_MAX / (max - min + 1))))
|
||||
|
||||
/* endianness */
|
||||
#ifndef LITTLE_ENDIAN
|
||||
@LIT_END@
|
||||
#endif /* LITTLE_ENDIAN */
|
||||
|
||||
#ifndef BIG_ENDIAN
|
||||
@BIG_END@
|
||||
#endif /* BIG_ENDIAN */
|
||||
|
||||
/* unaligned memory access */
|
||||
@UNALIGNED_MEM@
|
||||
|
||||
|
||||
16
src/core.c
16
src/core.c
@@ -244,9 +244,9 @@ int write_session(void)
|
||||
*/
|
||||
for(j=0;VarName[j].name;j++)
|
||||
{
|
||||
varval = &bot->setting[j];
|
||||
if (IsProc(j))
|
||||
varval = varval->proc_var;
|
||||
continue;
|
||||
varval = &bot->setting[j];
|
||||
if (IsChar(j))
|
||||
{
|
||||
if (VarName[j].v.num != varval->char_var)
|
||||
@@ -1208,8 +1208,10 @@ void do_core(COMMAND_ARGS)
|
||||
}
|
||||
|
||||
i = Strcmp(current->nick,current->wantnick);
|
||||
table_buffer((i) ? TEXT_CURRNICKWANT : TEXT_CURRNICKHAS,current->nick,current->wantnick);
|
||||
table_buffer(TEXT_CURRGUID,current->guid);
|
||||
if (i)
|
||||
table_buffer(TEXT_CURRNICKWANT,current->nick,current->wantnick,current->guid);
|
||||
else
|
||||
table_buffer(TEXT_CURRNICKHAS,current->nick,current->guid);
|
||||
table_buffer(TEXT_USERLISTSTATS,u,su,EXTRA_CHAR(su),bu,EXTRA_CHAR(bu));
|
||||
|
||||
pt = tmp;
|
||||
@@ -1382,12 +1384,12 @@ void do_server(COMMAND_ARGS)
|
||||
ServerGroup *sg;
|
||||
Server *sp,*dp,**spp;
|
||||
char *server,*aport,*pass;
|
||||
char addc,*last,*quitmsg = "Trying new server, brb...";
|
||||
char addc,*last,*quitmsg = TEXT_TRYNEWSERVER;
|
||||
int n,iport,sgi;
|
||||
|
||||
if (CurrentCmd->name == C_NEXTSERVER)
|
||||
{
|
||||
quitmsg = "Switching servers...";
|
||||
quitmsg = TEXT_SWITCHSERVER;
|
||||
to_user(from,FMT_PLAIN,quitmsg);
|
||||
goto do_server_jump;
|
||||
}
|
||||
@@ -1615,7 +1617,7 @@ void do_nick(COMMAND_ARGS)
|
||||
return;
|
||||
}
|
||||
guid = a2i(nick);
|
||||
backup = current;
|
||||
backup = current;
|
||||
if (!errno)
|
||||
{
|
||||
nick = chop(&rest);
|
||||
|
||||
@@ -303,6 +303,7 @@ enum {
|
||||
#define BNAUTH_PLAINTEXT 0
|
||||
#define BNAUTH_DES 1
|
||||
#define BNAUTH_MD5 2
|
||||
#define BNAUTH_SHA 3
|
||||
|
||||
#endif /* BOTNET */
|
||||
|
||||
|
||||
39
src/dns.c
39
src/dns.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
|
||||
@@ -64,25 +64,7 @@ LS int dnsserver = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
char *type_textlist[] =
|
||||
{
|
||||
NULL,
|
||||
"A",
|
||||
"NS",
|
||||
"MD",
|
||||
"MF",
|
||||
"CNAME",
|
||||
"SOA",
|
||||
"MB",
|
||||
"MG",
|
||||
"MR",
|
||||
"NULL",
|
||||
"WKS",
|
||||
"PTR",
|
||||
"HINFO",
|
||||
"MINFO",
|
||||
"MX",
|
||||
"TXT",
|
||||
};
|
||||
{ NULL, "A", "NS", "MD", "MF", "CNAME", "SOA", "MB", "MG", "MR", "NULL", "WKS", "PTR", "HINFO", "MINFO", "MX", "TXT", };
|
||||
#endif /* DEBUG */
|
||||
|
||||
void init_rawdns(void)
|
||||
@@ -164,17 +146,17 @@ const char *get_dns_token(const char *src, const char *packet, char *dst, int sz
|
||||
|
||||
int make_query(char *packet, const char *hostname)
|
||||
{
|
||||
dnsQuery *h;
|
||||
char *size,*dst;
|
||||
|
||||
/*
|
||||
* make a packet
|
||||
*/
|
||||
packet[0] = rand() >> 24;
|
||||
packet[1] = rand() >> 24;
|
||||
packet[2] = 1; // RD, recursion desired flag
|
||||
packet[3] = 0;
|
||||
((ulong*)packet)[1] = htonl(0x10000);
|
||||
((ulong*)packet)[2] = 0;
|
||||
memset(packet,0,12);
|
||||
h = (dnsQuery*)packet;
|
||||
h->qid = rand() & 0xffff;
|
||||
h->flags = htons(0x0100);; // Query = 0, Recursion Desired = 1
|
||||
h->questions = htons(1);
|
||||
size = packet + 12;
|
||||
dst = size + 1;
|
||||
while(*hostname)
|
||||
@@ -932,7 +914,10 @@ flipstep:
|
||||
return;
|
||||
}
|
||||
|
||||
make_ireq(PA_DNS,from,host);
|
||||
if (to && *to == '#')
|
||||
make_ireq(PA_DNS,to,host);
|
||||
else
|
||||
make_ireq(PA_DNS,from,host);
|
||||
rawdns(host);
|
||||
}
|
||||
|
||||
|
||||
71
src/net.c
71
src/net.c
@@ -30,12 +30,18 @@
|
||||
#include "text.h"
|
||||
#include "mcmd.h"
|
||||
|
||||
#ifdef MD5CRYPT
|
||||
#define md5banneropt " MD5"
|
||||
#if defined(SHACRYPT) || defined(MD5CRYPT)
|
||||
char *CRYPT_FUNC(const char *, const char *);
|
||||
#else
|
||||
#define md5banneropt
|
||||
#endif
|
||||
|
||||
const char banneropt[] = "BB%i %i PTA"
|
||||
#ifdef SHACRYPT
|
||||
" SHA"
|
||||
#endif /* SHACRYPT */
|
||||
#ifdef MD5CRYPT
|
||||
" MD5"
|
||||
#endif /* MD5CRYPT */
|
||||
"\n";
|
||||
|
||||
#ifdef TELNET
|
||||
char *telnetprompt = TEXT_ENTERNICKNAME;
|
||||
@@ -307,6 +313,10 @@ void basicAuth(BotNet *bn, char *rest)
|
||||
{
|
||||
if (!Strcmp(pass,"PTA"))
|
||||
authtype = BNAUTH_PLAINTEXT;
|
||||
#ifdef SHACRYPT
|
||||
if (!Strcmp(pass,"SHA"))
|
||||
authtype = BNAUTH_SHA;
|
||||
#endif /* SHACRYPT */
|
||||
#ifdef MD5CRYPT
|
||||
if (!Strcmp(pass,"MD5"))
|
||||
authtype = BNAUTH_MD5;
|
||||
@@ -334,6 +344,26 @@ void basicAuth(BotNet *bn, char *rest)
|
||||
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
|
||||
|
||||
/* "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);
|
||||
#endif /* DEBUG */
|
||||
enc = CRYPT_FUNC(temppass,rest);
|
||||
#ifdef DEBUG
|
||||
debug("(basicAuth) their = %s, mypass = %s :: sha = %s\n",
|
||||
pass,linkpass,enc);
|
||||
#endif /* DEBUG */
|
||||
if (!Strcmp(enc,rest))
|
||||
break;
|
||||
}
|
||||
#endif /* SHACRYPT */
|
||||
#ifdef MD5CRYPT
|
||||
case BNAUTH_MD5:
|
||||
if (linkpass && *linkpass)
|
||||
@@ -492,6 +522,10 @@ void basicBanner(BotNet *bn, char *rest)
|
||||
{
|
||||
if (!Strcmp(p,"PTA"))
|
||||
bn->opt.pta = TRUE;
|
||||
#ifdef SHACRYPT
|
||||
if (!Strcmp(p,"SHA"))
|
||||
bn->opt.sha = TRUE;
|
||||
#endif /* SHACRYPT */
|
||||
#ifdef MD5CRYPT
|
||||
if (!Strcmp(p,"MD5"))
|
||||
bn->opt.md5 = TRUE;
|
||||
@@ -510,7 +544,7 @@ void basicBanner(BotNet *bn, char *rest)
|
||||
if (bn->status == BN_UNKNOWN)
|
||||
{
|
||||
bn->controller = netbot = get_netbot();
|
||||
to_file(bn->sock,"BB%i %i PTA" md5banneropt "\n",netbot->guid,bn->lsid);
|
||||
to_file(bn->sock,banneropt,netbot->guid,bn->lsid);
|
||||
bn->status = BN_WAITAUTH;
|
||||
return;
|
||||
}
|
||||
@@ -533,12 +567,37 @@ void basicBanner(BotNet *bn, char *rest)
|
||||
if (bn->opt.md5 && (BNAUTH_MD5 > authtype))
|
||||
authtype = BNAUTH_MD5;
|
||||
#endif /* MD5CRYPT */
|
||||
#ifdef SHACRYPT
|
||||
if (bn->opt.sha && (BNAUTH_SHA > authtype))
|
||||
authtype = BNAUTH_SHA;
|
||||
#endif /* SHACRYPT */
|
||||
|
||||
switch(authtype)
|
||||
{
|
||||
case BNAUTH_PLAINTEXT:
|
||||
to_file(bn->sock,"BAPTA %s\n",linkpass);
|
||||
break;
|
||||
#ifdef SHACRYPT
|
||||
case BNAUTH_SHA:
|
||||
if ((cfg = find_netcfg(guid)))
|
||||
{
|
||||
if (cfg->pass && *cfg->pass)
|
||||
{
|
||||
char *enc,salt[8];
|
||||
char temppass[24 + Strlen2(cfg->pass,linkpass)]; // linkpass(procvar) is not NULL
|
||||
|
||||
/* "theirpass mypass LOCALsid REMOTEsid" */
|
||||
sprintf(temppass,"%s %s %i %i",cfg->pass,linkpass,bn->lsid,bn->rsid);
|
||||
#ifdef DEBUG
|
||||
debug(">> sha pass exchange: \"%s\"\n",temppass);
|
||||
#endif /* DEBUG */
|
||||
sprintf(salt,"$6$%04x",(rand() >> 16));
|
||||
enc = CRYPT_FUNC(temppass,salt);
|
||||
to_file(bn->sock,"BASHA %s\n",enc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* SHACRYPT */
|
||||
#ifdef MD5CRYPT
|
||||
case BNAUTH_MD5:
|
||||
if ((cfg = find_netcfg(guid)))
|
||||
@@ -1320,7 +1379,7 @@ void process_botnet(void)
|
||||
{
|
||||
bn->lsid = rand();
|
||||
bn->controller = netbot = get_netbot();
|
||||
if (to_file(bn->sock,"BB%i %i PTA" md5banneropt "\n",netbot->guid,bn->lsid) < 0)
|
||||
if (to_file(bn->sock,banneropt,netbot->guid,bn->lsid) < 0)
|
||||
{
|
||||
botnet_deaduplink(bn);
|
||||
}
|
||||
|
||||
12
src/spy.c
12
src/spy.c
@@ -163,8 +163,8 @@ struct
|
||||
{
|
||||
char *idstring;
|
||||
int typenum;
|
||||
|
||||
} spy_source_list[] =
|
||||
|
||||
} spy_source_list[] =
|
||||
{
|
||||
{ SPYSTR_STATUS, SPY_STATUS },
|
||||
{ SPYSTR_MESSAGE, SPY_MESSAGE },
|
||||
@@ -471,7 +471,15 @@ rspy_usage:
|
||||
* Dont just open anything.
|
||||
*/
|
||||
if (!is_safepath(dest))
|
||||
#ifdef NEWBIE
|
||||
{
|
||||
usage(from);
|
||||
to_user(from,"File/path does not exist or is inaccessible");
|
||||
return;
|
||||
}
|
||||
#else
|
||||
goto rspy_usage;
|
||||
#endif /* NEWBIE */
|
||||
t_dest = SPY_FILE;
|
||||
goto rspy_dest_ok;
|
||||
}
|
||||
|
||||
@@ -668,8 +668,9 @@ typedef struct BotNet
|
||||
|
||||
struct
|
||||
{
|
||||
ulong pta:1; /* plain text auth */
|
||||
ulong md5:1; /* md5 */
|
||||
ulong pta:1, /* plain text auth */
|
||||
sha:1, /* SHA */
|
||||
md5:1; /* MD5 */
|
||||
|
||||
} opt;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
|
||||
EnergyMech, IRC bot software
|
||||
Copyright (c) 2000-2009 proton
|
||||
Copyright (c) 2000-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
|
||||
@@ -74,9 +74,8 @@
|
||||
#define TEXT_SERVERDELETED "Server has been deleted: %s:%i"
|
||||
#define TEXT_MANYSERVMATCH "Several entries for %s exists, please specify port also"
|
||||
/* do_core() */
|
||||
#define TEXT_CURRNICKWANT "Current nick\t%s (Wanted: %s)"
|
||||
#define TEXT_CURRNICKHAS "Current nick\t%s"
|
||||
#define TEXT_CURRGUID "Guid\t%i"
|
||||
#define TEXT_CURRNICKWANT "Current nick\t%s (Wanted: %s) [#%i]"
|
||||
#define TEXT_CURRNICKHAS "Current nick\t%s [#%i]"
|
||||
#define TEXT_USERLISTSTATS "Users in userlist\t%i (%i Superuser%s, %i Bot%s)"
|
||||
#define TEXT_ACTIVECHANS "Active channels\t%s"
|
||||
#define TEXT_MOREACTIVECHANS "\t%s"
|
||||
@@ -87,6 +86,8 @@
|
||||
|
||||
#define TEXT_CURRSERVER "Current Server\t%s:%i"
|
||||
#define TEXT_CURRSERVERNOT "Current Server\t" TEXT_NOTINSERVLIST
|
||||
#define TEXT_TRYNEWSERVER "Trying new server, brb..."
|
||||
#define TEXT_SWITCHSERVER "Switching servers..."
|
||||
#define TEXT_SERVERONTIME "Server Ontime\t%s"
|
||||
#define TEXT_BOTMODES "Mode\t+%s"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user