Exemplo n.º 1
0
bool ConCommandTester::RT_HookSayCallback ( PlayerHandler::iterator ph, const void* const command, const SourceSdk::CCommand & args )
{
	char cmd_str[ 256 ];
	strcpy_s ( cmd_str, 256 * sizeof ( char ), args.GetCommandString () );
	cmd_str[ 255 ] = '\0';
	const size_t cmd_len ( strlen ( cmd_str ) );
	char const * command_name ( SourceSdk::InterfacesProxy::ConCommand_GetName ( command ) );

	if( cmd_len > 250 )
	{
		g_ConCommandTester.RT_AddPlayerCommand ( ph, command_name );
		ProcessDetectionAndTakeAction<Detection_CmdViolation::data_type>(Detection_CmdViolation(), g_ConCommandTester.GetPlayerDataStructByIndex(ph.GetIndex()), ph, &g_ConCommandTester);
		return true;
	}

	size_t spacenum ( 0 );
	for( size_t x ( 0 ); x < 251; ++x )
	{
		const char k ( cmd_str[ x ] );
		if( k == '\0' ) break;

		if( k == ' ' )
		{
			if( ++spacenum > 64 )
			{
				g_ConCommandTester.RT_AddPlayerCommand ( ph, command_name );
				ProcessDetectionAndTakeAction<Detection_CmdViolation::data_type>(Detection_CmdViolation(), g_ConCommandTester.GetPlayerDataStructByIndex(ph.GetIndex()), ph, &g_ConCommandTester);
				return true;
			}
		}
		if( k < 0x20 && !( Helpers::GetUTF8Bytes ( &k ) > 1 ) )
		{
			g_ConCommandTester.RT_AddPlayerCommand ( ph, command_name );
			ProcessDetectionAndTakeAction<Detection_CmdViolation::data_type>(Detection_CmdViolation(), g_ConCommandTester.GetPlayerDataStructByIndex(ph.GetIndex()), ph, &g_ConCommandTester);
			return true;
		}
	}

	g_ConCommandTester.RT_AddPlayerCommand ( ph, cmd_str );
	return false;
}
Exemplo n.º 2
0
//---------------------------------------------------------------------------------
// Purpose: called when a client types in a command (only a subset of commands however, not CON_COMMAND's)
//---------------------------------------------------------------------------------
SourceSdk::PLUGIN_RESULT CNoCheatZPlugin::RT_ClientCommand ( SourceSdk::edict_t *pEntity, const SourceSdk::CCommand &args )
{
	DebugMessage ( Helpers::format ( "CNoCheatZPlugin::ClientCommand(%X -> %s, %s)", pEntity, pEntity->GetClassName (), args.GetCommandString () ) );

	if( !pEntity || pEntity->IsFree () )
	{
		return SourceSdk::PLUGIN_CONTINUE;
	}

	PlayerHandler::const_iterator ph ( NczPlayerManager::GetInstance ()->GetPlayerHandlerByEdict ( pEntity ) );
	if( ph >= SlotStatus::PLAYER_CONNECTED )
	{
		if( ConCommandTester::GetInstance ()->RT_TestPlayerCommand ( ph, args.GetCommandString () ) )
			return SourceSdk::PLUGIN_STOP;
		if( stricmp ( args[ 0 ], "joingame" ) == 0 || stricmp ( args[ 0 ], "jointeam" ) == 0 || stricmp ( args[ 0 ], "joinclass" ) == 0 )
		{
			if( ValidationTester::GetInstance ()->JoinCallback ( ph ) )
				return SourceSdk::PLUGIN_STOP;
		}
	}
	return SourceSdk::PLUGIN_CONTINUE;
}
Exemplo n.º 3
0
bool ConCommandTester::RT_HookEntCallback ( PlayerHandler::iterator ph, const void* const command, const SourceSdk::CCommand & args )
{
	char cmd_str[ 512 ];
	strcpy_s ( cmd_str, 512 * sizeof ( char ), args.GetCommandString () );
	cmd_str[ 511 ] = '\0';
	const size_t cmd_len ( strlen ( cmd_str ) );
	char const * command_name ( SourceSdk::InterfacesProxy::ConCommand_GetName ( command ) );

	if( cmd_len > 500 )
	{
		g_ConCommandTester.RT_AddPlayerCommand ( ph, command_name );
		ProcessDetectionAndTakeAction<Detection_CmdViolation::data_type>(Detection_CmdViolation(), g_ConCommandTester.GetPlayerDataStructByIndex(ph.GetIndex()), ph, &g_ConCommandTester);
		return true;
	}

	for( size_t x ( 0 ); x < cmd_len - 3; ++x )
	{
		if( StriCmpOffset ( cmd_str, "point_", x ) )
		{
			g_ConCommandTester.RT_AddPlayerCommand ( ph, command_name );
			ProcessDetectionAndTakeAction<Detection_CmdViolation::data_type>(Detection_CmdViolation(), g_ConCommandTester.GetPlayerDataStructByIndex(ph.GetIndex()), ph, &g_ConCommandTester);
			return true;
		}
		if( StriCmpOffset ( cmd_str, "quit", x ) )
		{
			g_ConCommandTester.RT_AddPlayerCommand ( ph, command_name );
			ProcessDetectionAndTakeAction<Detection_CmdViolation::data_type>(Detection_CmdViolation(), g_ConCommandTester.GetPlayerDataStructByIndex(ph.GetIndex()), ph, &g_ConCommandTester);
			return true;
		}
		if( StriCmpOffset ( cmd_str, "exit", x ) )
		{
			g_ConCommandTester.RT_AddPlayerCommand ( ph, command_name );
			ProcessDetectionAndTakeAction<Detection_CmdViolation::data_type>(Detection_CmdViolation(), g_ConCommandTester.GetPlayerDataStructByIndex(ph.GetIndex()), ph, &g_ConCommandTester);
			return true;
		}
		if( StriCmpOffset ( cmd_str, "restart", x ) )
		{
			g_ConCommandTester.RT_AddPlayerCommand ( ph, command_name );
			ProcessDetectionAndTakeAction<Detection_CmdViolation::data_type>(Detection_CmdViolation(), g_ConCommandTester.GetPlayerDataStructByIndex(ph.GetIndex()), ph, &g_ConCommandTester);
			return true;
		}
		if( StriCmpOffset ( cmd_str, "rcon", x ) )
		{
			g_ConCommandTester.RT_AddPlayerCommand ( ph, command_name );
			ProcessDetectionAndTakeAction<Detection_CmdViolation::data_type>(Detection_CmdViolation(), g_ConCommandTester.GetPlayerDataStructByIndex(ph.GetIndex()), ph, &g_ConCommandTester);
			return true;
		}
		if( StriCmpOffset ( cmd_str, "mp_", x ) )
		{
			g_ConCommandTester.RT_AddPlayerCommand ( ph, command_name );
			ProcessDetectionAndTakeAction<Detection_CmdViolation::data_type>(Detection_CmdViolation(), g_ConCommandTester.GetPlayerDataStructByIndex(ph.GetIndex()), ph, &g_ConCommandTester);
			return true;
		}
		if( StriCmpOffset ( cmd_str, "taketimer", x ) )
		{
			g_ConCommandTester.RT_AddPlayerCommand ( ph, command_name );
			ProcessDetectionAndTakeAction<Detection_CmdViolation::data_type>(Detection_CmdViolation(), g_ConCommandTester.GetPlayerDataStructByIndex(ph.GetIndex()), ph, &g_ConCommandTester);
			return true;
		}
		if( StriCmpOffset ( cmd_str, "logic_", x ) )
		{
			g_ConCommandTester.RT_AddPlayerCommand ( ph, command_name );
			ProcessDetectionAndTakeAction<Detection_CmdViolation::data_type>(Detection_CmdViolation(), g_ConCommandTester.GetPlayerDataStructByIndex(ph.GetIndex()), ph, &g_ConCommandTester);
			return true;
		}
		if( StriCmpOffset ( cmd_str, "sv_", x ) )
		{
			g_ConCommandTester.RT_AddPlayerCommand ( ph, command_name );
			ProcessDetectionAndTakeAction<Detection_CmdViolation::data_type>(Detection_CmdViolation(), g_ConCommandTester.GetPlayerDataStructByIndex(ph.GetIndex()), ph, &g_ConCommandTester);
			return true;
		}
	}

	g_ConCommandTester.RT_AddPlayerCommand ( ph, cmd_str );
	return false;
}