1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-09 23:23:14 +02:00

+- Found a way to do +x IPv4 cloaking right.

+- Added set::cloak-keys { longvalue; longvalue; longvalue; }; for the cipher
This commit is contained in:
stskeeps
2001-04-11 01:52:12 +00:00
parent 220d739c8d
commit 9b5142a14d
6 changed files with 96 additions and 17 deletions
+3
View File
@@ -387,3 +387,6 @@
- Readded timestamp to log, accidentily got removed
- Made it so /stats C doesn't show the user@host of servers to non-opers
- Possibly fixed the vhost crashing bug, with much help from IpAddress
- Found a way to do +x IPv4 cloaking right.
- Added set::cloak-keys { longvalue; longvalue; longvalue; }; for the cipher
+10
View File
@@ -28,6 +28,10 @@
typedef struct zNetwork aNetwork;
struct zNetwork {
long key;
long key2;
long key3;
long keycrc;
unsigned x_inah:1;
char *x_ircnetwork;
char *x_defserv;
@@ -130,3 +134,9 @@ extern aConfiguration iConf;
#define iNAH iConf.network.x_inah
#define prefix_quit iConf.network.x_prefix_quit
#define STOPSE iConf.network.x_se
#define CLOAK_KEY1 iConf.network.key
#define CLOAK_KEY2 iConf.network.key2
#define CLOAK_KEY3 iConf.network.key3
#define CLOAK_KEYCRC iConf.network.keycrc
+22 -9
View File
@@ -34,7 +34,17 @@ static char sccxid[] = "@(#)cloak.c 9.00 7/12/99 UnrealIRCd";
#include <string.h>
#include "h.h"
#define CLOAK_KEY "()%289259248924924"
#undef KEY
#undef KEY2
#undef KEY3
#define KEY CLOAK_KEY1
#define KEY2 CLOAK_KEY2
#define KEY3 CLOAK_KEY3
#define POW_8 256L
#define POW_16 65536L
#define POW_32 4294967296L
/* The implementation here was originally done by Gary S. Brown. I have
borrowed the tables directly, and made some minor changes to the
@@ -157,7 +167,8 @@ char *hidehost(char *host)
static char cloaked[512];
static char h1[512];
static char h2[4][4];
long l[5];
static char h3[300];
unsigned long l[5];
int i;
char *p;
@@ -170,7 +181,7 @@ char *hidehost(char *host)
break;
if (!isdigit(*p) && !(*p == '.'))
{
break;
break;
}
}
if (!(*p))
@@ -182,13 +193,15 @@ char *hidehost(char *host)
{
strncpy(h2[i], p, 4);
}
ircsprintf(h3, "%s.%s", h2[0], h2[1]);
l[0] = ((crc32(h3, strlen(h3)) + KEY2) ^ KEY) ^ KEY3;
ircsprintf(h3, "%s.%s.%s", h2[0], h2[1], h2[2]);
l[1] = ((KEY2 + crc32(h3, strlen(h3))) ^ KEY) ^ KEY3;
l[4] = crc32(host, strlen(host));
for (i = 0; i <= 3; i++)
{
l[i] = crc32(h2[i], strlen(h2[i]));
}
l[3] += l[4];
ircsprintf(cloaked, "%X-%X-%X.%X", l[0], l[1], l[2], l[3]);
l[2] = ((l[4] + KEY2) ^ KEY)^ KEY3;
l[2] << 2; l[2] >> 2;
l[0] >> 1; l[0] << 1;
ircsprintf(cloaked, "%X.%X.%X.IP", l[2], l[1], l[0]);
return cloaked;
}
else if (*p == ':')
+42 -1
View File
@@ -1906,6 +1906,9 @@ int _conf_set(ConfigFile *conf, ConfigEntry *ce)
{
ConfigEntry *cep;
ConfigEntry *cepp;
char temp[512];
int i;
for (cep = ce->ce_entries; cep; cep = cep->ce_next)
{
@@ -2047,6 +2050,31 @@ int _conf_set(ConfigFile *conf, ConfigEntry *ce)
}
}
}
else if (!strcmp(cep->ce_varname, "cloak-keys"))
{
/* Count number of numbers there .. */
for (cepp = cep->ce_entries, i = 0; cepp; cepp = cepp->ce_next, i++) { }
if (i != 3)
{
config_error("%s:%i: set::cloak-keys: we want 3 values, not %i!",
cep->ce_fileptr->cf_filename, cep->ce_varlinenum,
i);
return 0;
}
/* i == 3 SHOULD make this true .. */
CLOAK_KEY1 = atol(cep->ce_entries->ce_varname);
CLOAK_KEY2 = atol(cep->ce_entries->ce_next->ce_varname);
CLOAK_KEY3 = atol(cep->ce_entries->ce_next->ce_next->ce_varname);
ircsprintf(temp, "%li.%li.%li", CLOAK_KEY1,
CLOAK_KEY2, CLOAK_KEY3);
CLOAK_KEYCRC = (long) crc32(temp, strlen(temp));
}
else
{
config_status("%s:%i: unknown directive set::%s",
cep->ce_fileptr->cf_filename, cep->ce_varlinenum,
cep->ce_varname);
}
}
}
#ifdef STRIPBADWORDS
@@ -2691,7 +2719,18 @@ void validate_configuration(void)
Warning("set::socks::quit-message is missing. Using default of \"Insecure SOCKS server\"");
ircstrdup(iConf.socksquitmessage, "Insecure SOCKS server");
}
if ((CLOAK_KEY1 < 10000) || (CLOAK_KEY2 < 10000) || (CLOAK_KEY3 < 10000))
{
if (!CLOAK_KEY1 || !CLOAK_KEY2 || !CLOAK_KEY3)
{
Error("set::cloak-keys are missing or is 0.");
Error("Add this in your config file:");
Error("set { cloak-keys { <big integer value>; <big integer value>; <big integer value>; };");
Error("The numbers must be purely random, and the same on every server you link to");
}
Error("set::cloak-keys are too easy to guess. Please select three other more absurd and crazy numbers - will increase security a lot");
}
/* Now for the real config */
if (conf_me)
{
@@ -3546,5 +3585,7 @@ void report_network(aClient *sptr)
sptr->name, STATS_SERVER);
sendto_one(sptr, ":%s %i %s :INAH: %i", me.name, RPL_TEXT, sptr->name,
iNAH);
sendto_one(sptr, ":%s %i %s :KEYCRC: %X", me.name, RPL_TEXT, sptr->name,
CLOAK_KEYCRC);
}
+16 -7
View File
@@ -1289,9 +1289,11 @@ int m_server_synch(aClient *cptr, long numeric, ConfigItem_link *aconf)
}
}
sendto_one(cptr, "%s %li %li %li 0 0 0 0 :%s",
sendto_one(cptr, "%s %li %li %li %X 0 0 0 :%s",
(IsToken(cptr) ? TOK_NETINFO : MSG_NETINFO),
IRCstats.global_max, TStime(), UnrealProtocol, ircnetwork);
IRCstats.global_max, TStime(), UnrealProtocol,
CLOAK_KEYCRC,
ircnetwork);
return 0;
}
@@ -1811,7 +1813,7 @@ int m_links(cptr, sptr, parc, parv)
** parv[1] = max global count
** parv[2] = time of end sync
** parv[3] = unreal protocol using (numeric)
** parv[4] = free(for unrealprotocol > 2100)
** parv[4] = cloak-crc (> u2302)
** parv[5] = free(**)
** parv[6] = free(**)
** parv[7] = free(**)
@@ -1823,9 +1825,10 @@ int m_netinfo(cptr, sptr, parc, parv)
int parc;
char *parv[];
{
long lmax;
time_t xx;
long endsync, protocol;
long lmax;
time_t xx;
long endsync, protocol;
char buf[512];
if (IsPerson(sptr))
return 0;
@@ -1913,7 +1916,13 @@ int m_netinfo(cptr, sptr, parc, parv)
me.name, cptr->name, protocol, me.name, UnrealProtocol);
}
ircsprintf(buf, "%X", CLOAK_KEYCRC);
if (strcmp(buf, parv[4]))
{
sendto_realops
("Link %s is having a different cloak key - %s != %s",
parv[4], buf);
}
SetNetInfo(cptr);
}
+3
View File
@@ -187,6 +187,9 @@ char *unrealcredits[] =
"[FBI] Corey Lang fbi@dal.net",
" - Being a good IRC friend and getting me started with",
" IRC through our old little wIRCd net :)",
"The +x 2.0 team: RaYmAn, NiQuiL, narf, Griever (great thinking)",
" eternal, bball, JK. Thanks for makin a",
" drop dead gorgeous algoritm.",
"",
" \2\37Also thanks to:\2\37",
"Enforcer, Andy Church, Mick, Sp^, ShadowMastr, Almaris",