Пример #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;
}
Пример #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;
}
Пример #3
0
bool BanRequest::sys_cmd_fn ( const SourceSdk::CCommand &args )
{
	if( stricmp ( "CanKick", args.Arg ( 2 ) ) == 0 )
	{
		if(Helpers::IsArgTrue(args.Arg(3)))
		{
			m_can_kick = true;
			g_Logger.Msg<MSG_CMD_REPLY> ( Helpers::format ( "NoCheatZ is: Able to kick (%s), Able to ban (%s)", Helpers::boolToString ( m_can_kick ), Helpers::boolToString ( m_can_ban ) ) );
		}
		else if (Helpers::IsArgFalse(args.Arg(3)))
		{
			m_can_kick = false;
			m_can_ban = false;
			g_Logger.Msg<MSG_CMD_REPLY> ( Helpers::format ( "NoCheatZ is: Able to kick (%s), Able to ban (%s)", Helpers::boolToString ( m_can_kick ), Helpers::boolToString ( m_can_ban ) ) );
		}
		else
		{
			g_Logger.Msg<MSG_CMD_REPLY> ( Helpers::format ( "Available arguments for \"ncz BanRequest CanKick\" : Yes - No" ) );
		}

		g_Logger.Msg<MSG_CMD_REPLY>(Helpers::format("NoCheatZ is: Able to kick (%s), Able to ban (%s)", Helpers::boolToString(m_can_kick), Helpers::boolToString(m_can_ban)));
		return true;
	}
	else if( stricmp ( "CanBan", args.Arg ( 2 ) ) == 0 )
	{
		if(Helpers::IsArgTrue(args.Arg(3)))
		{
			m_can_kick = true;
			m_can_ban = true;
			g_Logger.Msg<MSG_CMD_REPLY> ( Helpers::format ( "NoCheatZ is: Able to kick (%s), Able to ban (%s)", Helpers::boolToString ( m_can_kick ), Helpers::boolToString ( m_can_ban ) ) );
		}
		else if(Helpers::IsArgFalse(args.Arg(3)))
		{
			m_can_ban = false;
			g_Logger.Msg<MSG_CMD_REPLY> ( Helpers::format ( "NoCheatZ is: Able to kick (%s), Able to ban (%s)", Helpers::boolToString ( m_can_kick ), Helpers::boolToString ( m_can_ban ) ) );
		}
		else
		{
			g_Logger.Msg<MSG_CMD_REPLY> ( "Available arguments for \"ncz BanRequest CanBan\" : Yes - No" );
		}
		g_Logger.Msg<MSG_CMD_REPLY>(Helpers::format("NoCheatZ is: Able to kick (%s), Able to ban (%s)", Helpers::boolToString(m_can_kick), Helpers::boolToString(m_can_ban)));
		return true;
	}
	else if (stricmp("SetBanTime", args.Arg(2)) == 0)
	{
		if (args.ArgC() >= 4)
		{
			m_ban_time = atoi(args.Arg(3));
		}
		else
		{
			g_Logger.Msg<MSG_CMD_REPLY>("SetBanTime expected int argument (ban time minutes - 0 = permanent)");
		}
		return true;
	}
	else if (stricmp("AllowWriteBans", args.Arg(2)) == 0)
	{
		if (args.ArgC() >= 4)
		{
			if (Helpers::IsArgTrue(args.Arg(3)))
			{
				m_can_write_ids = true;
				g_Logger.Msg<MSG_CMD_REPLY>("AllowWriteBans is Yes");
				return true;
			}
			else if (Helpers::IsArgFalse(args.Arg(3)))
			{
				m_can_write_ids = false;
				g_Logger.Msg<MSG_CMD_REPLY>("AllowWriteBans is No");
				return true;
			}
		}
		g_Logger.Msg<MSG_CMD_REPLY>("AllowWriteBans expected Yes or No");
		return true;
	}
	else
	{
		return false;
	}
}
Пример #4
0
void BaseSystem::ncz_cmd_fn ( const SourceSdk::CCommand &args )
{
	if( args.ArgC () > 1 )
	{
		BaseSystem* it = GetFirst ();
		while( it != nullptr )
		{
			if( stricmp ( it->GetName (), args.Arg ( 1 ) ) == 0 )
			{
				if( stricmp ( "enable", args.Arg ( 2 ) ) == 0 )
				{
					it->SetConfig ( true );
					it->SetActive ( true );
				}
				else if( stricmp ( "disable", args.Arg ( 2 ) ) == 0 )
				{
					it->SetConfig ( false );
					it->SetActive ( false );
				}
				else if( stricmp ( "verbose", args.Arg ( 2 ) ) == 0 )
				{
					if( args.ArgC () > 2 )
					{
						it->m_verbose = atoi ( args.Arg ( 3 ) );
					}
					return;
				}
#ifdef NCZ_USE_METRICS
				else if( Helpers::bStriEq ( "printmetrics", args.Arg ( 2 ) ) )
				{
					( *it )->GetMetrics ().PrintAll ();
				}
				else if( Helpers::bStriEq ( "resetmetrics", args.Arg ( 2 ) ) )
				{
					( *it )->GetMetrics ().ResetAll ();
				}
#endif
				else if( !it->sys_cmd_fn ( args ) )
				{
					printf ( "action %s not found.\nTry : %s\n", args.Arg ( 2 ), it->cmd_list () );
				}

				return;
			}
			GetNext ( it );
		}
		printf ( "System %s not found.\n", args.Arg ( 1 ) );
	}
	else
	{
		printf ( "Usage: ncz system arg1 arg2 ...\n" );
		printf ( "Systems list :\n" );
		BaseSystem* it ( GetFirst () );
		while( it != nullptr )
		{
			printf ( "%s", it->GetName () );
			if( it->IsActive () )
			{
				printf ( " (Running)\n" );
			}
			else if( !it->IsEnabledByConfig () )
			{
				printf ( " (Disabled manually)\n" );
			}
			else if( it->GetDisabledByConfigIni () )
			{
				printf ( " (Disabled by config.ini)\n" );
			}
			else
			{
				printf ( " (Sleeping - Waiting for players)\n" );
			}
			printf ( "\tCommands : %s\n", it->cmd_list () );
			GetNext ( it );
		}
	}
}
Пример #5
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;
}
Пример #6
0
void BaseSystem::ncz_cmd_fn ( const SourceSdk::CCommand &args )
{
	if( args.ArgC () > 1 )
	{
		BaseSystem* it = GetFirst ();
		while( it != nullptr )
		{
			if( stricmp ( it->GetName (), args.Arg ( 1 ) ) == 0 )
			{
				if( stricmp ( "enable", args.Arg ( 2 ) ) == 0 )
				{
					if( it->IsStatic () )
					{
						Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "System %s is static and cannot be loaded or unloaded", it->GetName () ) );
					}
					else
					{
						it->SetConfig ( true );
						it->SetActive ( true );
					}
				}
				else if( stricmp ( "disable", args.Arg ( 2 ) ) == 0 )
				{
					if( it->IsStatic () )
					{
						Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "System %s is static and cannot be loaded or unloaded", it->GetName () ) );
					}
					else
					{
						it->SetConfig ( false );
						it->SetActive ( false );
					}
				}
				else if( stricmp ( "on", args.Arg ( 2 ) ) == 0 )
				{
					if( it->IsStatic () )
					{
						Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "System %s is static and cannot be loaded or unloaded", it->GetName () ) );
					}
					else
					{
						it->SetConfig ( true );
						it->SetActive ( true );
					}
				}
				else if( stricmp ( "off", args.Arg ( 2 ) ) == 0 )
				{
					if( it->IsStatic () )
					{
						Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "System %s is static and cannot be loaded or unloaded", it->GetName () ) );
					}
					else
					{
						it->SetConfig ( false );
						it->SetActive ( false );
					}
				}
				else if( stricmp ( "verbose", args.Arg ( 2 ) ) == 0 )
				{
					if( args.ArgC () > 2 )
					{
						it->m_verbose = atoi ( args.Arg ( 3 ) );
						Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "System %s verbose level is now %d", it->GetName (), it->m_verbose ) );
					}
					return;
				}
#ifdef NCZ_USE_METRICS
				else if( Helpers::bStriEq ( "printmetrics", args.Arg ( 2 ) ) )
				{
					( *it )->GetMetrics ().PrintAll ();
				}
				else if( Helpers::bStriEq ( "resetmetrics", args.Arg ( 2 ) ) )
				{
					( *it )->GetMetrics ().ResetAll ();
				}
#endif
				else if( !it->sys_cmd_fn ( args ) )
				{
					Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "action %s not found.\nTry : %s", args.Arg ( 2 ), it->cmd_list () ) );
				}

				return;
			}
			GetNext ( it );
		}
		Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "System %s not found.", args.Arg ( 1 ) ) );
	}
	else
	{
		Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( "Usage: ncz system arg1 arg2 ...\nSystems list :\n");

		BaseSystem* it ( GetFirst () );
		while( it != nullptr )
		{
			basic_string prepared_message ( it->GetName () );
			if( it->IsStatic () )
			{
				prepared_message.append ( " (Static)\n" );
			}
			else if( it->IsActive () )
			{
				prepared_message.append ( " (Running)\n" );
			}
			else if( !it->IsEnabledByConfig () )
			{
				prepared_message.append ( " (Disabled manually)\n" );
			}
			else if( it->GetDisabledByConfigIni () )
			{
				prepared_message.append ( " (Disabled by config.ini)\n" );
			}
			else
			{
				prepared_message.append ( " (Sleeping - Waiting for players)\n" );
			}
			prepared_message.append ( Helpers::format( "\tCommands : %s\n", it->cmd_list () ) );
			Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( prepared_message.c_str () );
			GetNext ( it );
		}		
	}
}