JKA No "ingame crash" patch

Miscellaneous programs and scripts, opensource or not, and sometimes, random mathematical stuff.
Locked
Gamall
Hic sunt dracones
Posts: 4174
Joined: Fri May 26, 2006 11:09 pm
Contact:

JKA No "ingame crash" patch

Post by Gamall »

FILE OUTDATED: NEW VERSION OFFERS PROTECTION AGAINST FAKE PLAYER ATTACKS
New version -> viewtopic.php?t=120

Code: Select all

*********************************** 
Jedi Knight: Jedi Academy 
*********************************** 
TITLE: No "ingame crash" patch
AUTHOR: Gamall
E-MAIL: gamall.ida@gmail.com
WEBSITE: http://gamall-ida.com

FILENAME Windows : nocrash_Win.pk3
FILENAME Linux   : jampgamei386.so
FILESIZE: < 2 Mo
DATE RELEASED: 18 March 2007

CREDITS: 

Kudos to Trimbo for his linux-ready version of the vanillia SDK.

INSTALLATION INSTRUCTIONS: 

Just put it in your server's base folder.

DESCRIPTION: 

-> Removes the vulnerability to the say/tell "aaaaaaaaaaaaaaaaaaaaaaaaa... attack, also known as ingame buffer overflow attack, in unmodified baseJKA, by truncating too long say entries and blocking too long server commands.

Just remember to use a patched (linux)jampded[.exe] as well, and your server shall be impervious to malicious crashes.

-> Logs say/tell/server overflows into the server logs, with name and id of offending client.

-> Does not alter ANY aspect of basejka past that.

-> Damages MAY be slightly altered for Linux servers. This is a consequence of the fact that I compiled with GCC instead of ICC. Most people won't notice it though. I sure wouldn't :P


COMMENTS: This is not very original, and has probably been done to the death already, but I couldn't find a fix that works on Linux on the net when someone asked me about it... so here it is.

If someone has ICC and is willing to compile a so with it, please contact me :)

///////////////////////////////////////////////////////////////

MODIFIED CODE : (from jka-universalSource, linux-ready SDK.)

void trap_SendServerCommand( int clientNum, const char *text ) {
	/* Gamall : This bit should protect the clients... */
	if(strlen(text) > 1022) 
	{ 
		G_LogPrintf( "Gamall : Client %s sent too long a command...\n", clientNum ); 
		G_LogPrintf( "Sent command : [%s]\n", text ); 
		G_LogPrintf( "Total length : %d \n", strlen(text)) ;
        return; 
	} 
	/* Gamall : END OF FIX */
	syscall( G_SEND_SERVER_COMMAND, clientNum, text );
}


/*
==================
Cmd_Say_f
==================
*/
static void Cmd_Say_f( gentity_t *ent, int mode, qboolean arg0 ) {
	char		*p;

	if ( trap_Argc () < 2 && !arg0 ) {
		return;
	}

	if (arg0)
	{
		p = ConcatArgs( 0 );
	}
	else
	{
		p = ConcatArgs( 1 );
	}

	/* FIX Gamall : This bit should prevent crashes... */
	if ( strlen(p) > 150 )
	{
		p[149] = 0 ;
		G_LogPrintf("ANTI CRASH : Cmd_Say_f entry from client %s (%d) has been truncated\n", ent->client->pers.netname, ent->s.number);
	}
	/* END OF FIX */

	G_Say( ent, NULL, mode, p );
}

/*
==================
Cmd_Tell_f
==================
*/
static void Cmd_Tell_f( gentity_t *ent ) {
	int			targetNum;
	gentity_t	*target;
	char		*p;
	char		arg[MAX_TOKEN_CHARS];

	if ( trap_Argc () < 2 ) {
		return;
	}

	trap_Argv( 1, arg, sizeof( arg ) );
	targetNum = atoi( arg );
	if ( targetNum < 0 || targetNum >= level.maxclients ) {
		return;
	}

	target = &g_entities[targetNum];
	if ( !target || !target->inuse || !target->client ) {
		return;
	}

	p = ConcatArgs( 2 );

	/* FIX Gamall : This bit should prevent crashes... */
	if ( strlen(p) > 150 )
	{
		p[149] = 0 ;
		G_LogPrintf("ANTI CRASH : Cmd_Tell_f entry from client %s (%d) has been truncated\n", ent->client->pers.netname, ent->s.number);
	}
	/* END OF FIX */

	G_LogPrintf( "tell: %s to %s: %s\n", ent->client->pers.netname, target->client->pers.netname, p );

	G_Say( ent, target, SAY_TELL, p );
	// don't tell to the player self if it was already directed to this player
	// also don't send the chat back to a bot
	if ( ent != target && !(ent->r.svFlags & SVF_BOT)) {
		G_Say( ent, ent, SAY_TELL, p );
	}
}

I also removed the improbable powf function, which, apart from yielding a result different from what its name implies, prevents compilation under VC++ 8, for reasons that are quite beyond me since its syntactically correct... Its not used anywhere in the code anyway... I'm quite puzzled by this thing... Bha...

/* 
Gamall : Removed this so as to 
allow compilation with VC++ 8. 
*/

//float powf ( float x, int y )
//{
//	float r = x;
//	for ( y--; y>0; y-- )
//		r = r * r;
//	return r;
//}

THIS MODIFICATION IS NOT MADE, DISTRIBUTED, OR SUPPORTED BY ACTIVISION, RAVEN, OR 
LUCASARTS ENTERTAINMENT COMPANY LLC. ELEMENTS TM & © LUCASARTS 
ENTERTAINMENT COMPANY LLC AND/OR ITS LICENSORS.

Attachments
no crash.zip
(1.32 MiB) Downloaded 1241 times
Last edited by Gamall on Sat Mar 31, 2007 5:19 pm, edited 3 times in total.
{<§ Gamall Wednesday Ida §>}
{ Mods and Programs - Mods TES-IV Oblivion }
Gamall
Hic sunt dracones
Posts: 4174
Joined: Fri May 26, 2006 11:09 pm
Contact:

Post by Gamall »

-> On filefront : http://jediknight2.filefront.com/file/N ... atch;76835

The reviewer missed the point though, and is confused between that and another buffer overflow, which has never been a problem on JKA. :banghead

Hopefully he'll read my mail :livre

edit : corrected but still not that :fleur
{<§ Gamall Wednesday Ida §>}
{ Mods and Programs - Mods TES-IV Oblivion }
Gamall
Hic sunt dracones
Posts: 4174
Joined: Fri May 26, 2006 11:09 pm
Contact:

Post by Gamall »

Yop :)

Je me suis remise au boulot sur l'anti fake players, et je dois dire que je suis très contente de moi :archange

Le premier fix que j'avais écrit était archi nul (d'ailleurs je ne l'ai jamais mis en ligne pour cette raison)

Celui-là est super (en toute modestie):

Au lieu de détecter bêtement le nombres de clients partageant la même ip (façon japlus), il réagit au nombre de connexions d'affilée de la même IP dans une certaine période de temps.( Comme ça ça arrête les bots mais pas les groupes de vrais joueurs qui partagent une IP.)

Et il peut bannir automatiquement l'ip en cas d'alerte.

Mais en plus, il peut carrément détecter à coup sûr si une connexion est légitime ou si c'est un bot !

Avec, là encore, la possibilité de bannir automatiquement.

Ce qui signifie que, dans 99.999% des cas, AUCUN bot ne pourra se connecter au serveur :lol

Evidemment, l'attaquant a la possibilité de bidouiller pour contourner la vérification syntaxique, mais ça nécéssite quand même beaucoup d'acharnement et une connaissance très précise de la syntaxe de la connexion au serveur... ça devrait dissuader pas mal de monde :) Et même s'il y arrive, il reste la protection standard, incontournable sauf en spoofant l'ip (bonne chance :livre )

Oh, et évidemment tout ça est entièrement contrôlé par 4 cvars à mettre dans server.cfg. (elles peuvent être changées à chaud par rcon, bien sûr)

L'admin peut choisir le nombre critique de bots, le temps critique de connexion en masse, d'activer ou non l'autoban, et choisir le point de syntaxe à vérifier pour la connexion (par défaut, le fix vérifie la présence d'un skin... les bots n'ont pas de skin :P) . Tout peut être désactivé, bien sûr.



Je peaufinerai doucement au cours de la semaine, et je mettrai en ligne le week-end prochain :fleur


edit : on voit les deux types de protections sur le screen (sans l'autoban, parce que sinon je n'urais pu lancer qu'une seule attaque avant d'être bannie... c'est pas super pour faire un screen avec plusieurs attaques :lol) : la première réagit à une attaque q3fill modifiée pour être syntaxiquement correcte : elle a été stoppée au 5em bot parce que le paramètre est à 5 (premier message ; EDIT : en fait 4 parce que comme j'ai la même IP que les bot et que je venais de me connecter, j'ai compté pour 1), puis 5 attaques "par défaut", toute stoppées avant même que les bots rentrent dans le serveur (userinfo incorrect). :livre
Attachments
shot0019.jpg
shot0019.jpg (352.06 KiB) Viewed 29026 times
{<§ Gamall Wednesday Ida §>}
{ Mods and Programs - Mods TES-IV Oblivion }
Locked

Who is online

Users browsing this forum: Bing [Bot] and 181 guests