Mem_Free(cmd);
}
} else if(Cmd_Argc() == 3
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_CONTROVERSIAL
&& (cls.state != ca_connected || cls.demoplayback)
#endif
)
cmd_deferred_list = defcmd;*/
} else {
Con_Printf("usage: defer <seconds> <command>\n"
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_CONTROVERSIAL
" (only works while not connected)\n"
#endif
" defer clear\n");
void Cbuf_Frame(void)
{
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_CONTROVERSIAL
if(cls.state != ca_connected || cls.demoplayback)
#endif
Cbuf_Execute_Deferred();
Cmd_AddCommand ("pingplreport", Host_PingPLReport_f, "command sent by server containing client ping and packet loss values for scoreboard, triggered by pings command from client (not used by QW servers)");
Cmd_AddCommand ("fixtrans", Image_FixTransparentPixels_f, "change alpha-zero pixels in an image file to sensible values, and write out a new TGA (warning: SLOW)");
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_UNSAFE
Cmd_AddCommand ("checkmemory", Sys_AntiCheat_CheckMemory_f, "check memory for patterns");
#endif
qboolean have_usernames = false;
char vabuf[1024];
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_CONTROVERSIAL
if(cls.state != ca_dedicated)
return NULL;
#endif
#define DP_FUNC_NORETURN
#endif
+// Security features:
+// HARDENING: disable some nasty things evil servers may do via stuffcmd
+// ANTICHEAT_SAFE: some safe anti-cheating means
+// ANTICHEAT_CONTROVERSIAL: some controversial anti-cheating means
+// ANTICHEAT_UNSAFE: some more problematic anti-cheating means
+
#ifdef HARDENING
# define IS_HARDENED false
#else
# define IS_HARDENED true
#endif
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_UNSAFE
# ifdef __linux__
# define _GNU_SOURCE // for memmem
# endif
// call this from main(); if it returns false, exit using return
qboolean Sys_AntiCheat_Init(char **envp);
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_UNSAFE
typedef enum
{
CHECKMEMORY_N_A,
char *Sys_ConsoleInput(void)
{
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_CONTROVERSIAL
if (cls.state == ca_dedicated)
#endif
{
char *Sys_ConsoleInput(void)
{
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_CONTROVERSIAL
if (cls.state == ca_dedicated)
#endif
{
}
#endif
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_UNSAFE
# ifndef WIN32
# include <sys/ptrace.h>
# include <sys/wait.h>
# endif
#endif
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_UNSAFE
// whole function only exists if anticheat is enabled
Sys_AntiCheat_CheckMemory_Result_t Sys_AntiCheat_CheckMemory(const char *dllsubstring, qboolean dllsubstringmode, const void *pattern, size_t length)
{
qboolean Sys_AntiCheat_Init(char **envp)
{
-#ifdef ANTICHEAT
-# define FAIL return false
-
+#ifdef ANTICHEAT_CONTROVERSIAL
// anti LD_PRELOAD
// note that we're using envp here, so one doesn't simply hook into getenv()
static char *unsecure_envvars =
// UNSECURE_ENVVARS from glibc
"GCONV_PATH\0" // libraries are loaded from here
- //"GETCONF_DIR\0" // harmless, can only fake getconf() output
- //"HOSTALIASES\0" // harmless, just messes with DNS
+ // "GETCONF_DIR\0" // harmless, can only fake getconf() output
+ // "HOSTALIASES\0" // harmless, just messes with DNS
"LD_AUDIT\0" // loads libraries
// "LD_DEBUG\0" // harmless, just shows data
// "LD_DEBUG_OUTPUT\0" // harmless, just shows data
// "RES_OPTIONS\0" // harmless, just messes with DNS
// "TMPDIR\0" // harmless, we don't use temp files anyway
// "TZDIR\0" // harmless, just enables time travel
+
// EXTRA_UNSECURE_ENVVARS from glibc
"LD_AOUT_LIBRARY_PATH\0" // loads libraries
"LD_AOUT_PRELOAD\0" // loads libraries
++q;
}
if(*p == 0 && *q == '=')
- FAIL; // match!
+ return false; // match!
// next!
while(*p)
++p;
++envp;
}
}
+#endif
+#ifdef ANTICHEAT_UNSAFE
# ifndef WIN32
// anti ptrace; also, make a forked process copy to detach from debuggers
{
pid_t pid = fork();
if(pid < 0)
- FAIL;
+ return false;
if(pid == 0)
{
// nothing to do here
if(ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0)
{
kill(pid, SIGKILL);
- FAIL;
+ return false;
}
for(;;)
{
if(waitpid(pid, &status, 0) == (pid_t) -1)
{
if(errno == ECHILD) // process no longer exists
- FAIL;
+ return false;
}
if(WIFEXITED(status))
{
{
XNextEvent(vidx11_display, &event);
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_SAFE
if(event.xany.send_event && event.type != MotionNotify)
continue;
// note: synthetic MotionNotify already only change
drivername = "libGL.so.1";
#endif
-#ifndef ANTICHEAT
+#ifndef ANTICHEAT_CONTROVERSIAL
// COMMANDLINEOPTION: Linux GLX: -gl_driver <drivername> selects a GL driver library, default is libGL.so.1, useful only for using fxmesa or similar, if you don't know what this is for, you don't need it
// COMMANDLINEOPTION: BSD GLX: -gl_driver <drivername> selects a GL driver library, default is libGL.so.1, useful only for using fxmesa or similar, if you don't know what this is for, you don't need it
// LordHavoc: although this works on MacOSX, it's useless there (as there is only one system libGL)
// SDL usually knows best
drivername = NULL;
-#ifndef ANTICHEAT
+#ifndef ANTICHEAT_CONTROVERSIAL
// COMMANDLINEOPTION: SDL GL: -gl_driver <drivername> selects a GL driver library, default is whatever SDL recommends, useful only for 3dfxogl.dll/3dfxvgl.dll or fxmesa or similar, if you don't know what this is for, you don't need it
i = COM_CheckParm("-gl_driver");
if (i && i < com_argc - 1)
gldrivername = "opengl32.dll";
-#ifndef ANTICHEAT
+#ifndef ANTICHEAT_CONTROVERSIAL
// COMMANDLINEOPTION: Windows WGL: -gl_driver <drivername> selects a GL driver library, default is opengl32.dll, useful only for 3dfxogl.dll or 3dfxvgl.dll, if you don't know what this is for, you don't need it
i = COM_CheckParm("-gl_driver");
if (i && i < com_argc - 1)