whitelist neon because vac ban, prevent clients from getting kicked through spoofing, kick clients with invalid steamid
This commit is contained in:
		
							parent
							
								
									c008c39a86
								
							
						
					
					
						commit
						0d78e4f497
					
				| @ -10,6 +10,7 @@ | |||||||
| ConVar g_hCvar_BlockSpoof; | ConVar g_hCvar_BlockSpoof; | ||||||
| ConVar g_hCvar_BlockAdmin; | ConVar g_hCvar_BlockAdmin; | ||||||
| ConVar g_hCvar_BlockVoice; | ConVar g_hCvar_BlockVoice; | ||||||
|  | ConVar g_hCvar_AuthenticationTime; | ||||||
| 
 | 
 | ||||||
| /* DATABASE */ | /* DATABASE */ | ||||||
| Database g_hDatabase; | Database g_hDatabase; | ||||||
| @ -25,7 +26,7 @@ public Plugin myinfo = | |||||||
| 	name         = "PlayerManager: Connect", | 	name         = "PlayerManager: Connect", | ||||||
| 	author       = "zaCade + Neon", | 	author       = "zaCade + Neon", | ||||||
| 	description  = "Manage clients, denying admin access, ect.", | 	description  = "Manage clients, denying admin access, ect.", | ||||||
| 	version      = "2.0.0" | 	version      = "2.1.0" | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| //---------------------------------------------------------------------------------------------------- | //---------------------------------------------------------------------------------------------------- | ||||||
| @ -51,6 +52,7 @@ public void OnPluginStart() | |||||||
| 	g_hCvar_BlockSpoof = CreateConVar("sm_manager_block_spoof", "1", "Kick unauthenticated people that join with known steamids.", FCVAR_NONE, true, 0.0, true, 1.0); | 	g_hCvar_BlockSpoof = CreateConVar("sm_manager_block_spoof", "1", "Kick unauthenticated people that join with known steamids.", FCVAR_NONE, true, 0.0, true, 1.0); | ||||||
| 	g_hCvar_BlockAdmin = CreateConVar("sm_manager_block_admin", "1", "Should unauthenticated people be blocked from admin?",       FCVAR_NONE, true, 0.0, true, 1.0); | 	g_hCvar_BlockAdmin = CreateConVar("sm_manager_block_admin", "1", "Should unauthenticated people be blocked from admin?",       FCVAR_NONE, true, 0.0, true, 1.0); | ||||||
| 	g_hCvar_BlockVoice = CreateConVar("sm_manager_block_voice", "1", "Should unauthenticated people be blocked from voice?",       FCVAR_NONE, true, 0.0, true, 1.0); | 	g_hCvar_BlockVoice = CreateConVar("sm_manager_block_voice", "1", "Should unauthenticated people be blocked from voice?",       FCVAR_NONE, true, 0.0, true, 1.0); | ||||||
|  | 	g_hCvar_AuthenticationTime = CreateConVar("sm_manager_authentication_time", "15", "Time in seconds after which a client needs to be assigned to a SteamID", FCVAR_NONE, true, 1.0); | ||||||
| 
 | 
 | ||||||
| 	AddMultiTargetFilter("@steam", Filter_Steam, "Steam Players", false); | 	AddMultiTargetFilter("@steam", Filter_Steam, "Steam Players", false); | ||||||
| 	AddMultiTargetFilter("@nosteam", Filter_NoSteam, "No-Steam Players", false); | 	AddMultiTargetFilter("@nosteam", Filter_NoSteam, "No-Steam Players", false); | ||||||
| @ -83,6 +85,17 @@ public void OnPluginEnd() | |||||||
| 	RemoveMultiTargetFilter("@nosteam", Filter_NoSteam); | 	RemoveMultiTargetFilter("@nosteam", Filter_NoSteam); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | //---------------------------------------------------------------------------------------------------- | ||||||
|  | // Purpose: | ||||||
|  | //---------------------------------------------------------------------------------------------------- | ||||||
|  | public bool SteamClientAuthenticatedEx(const char[] sAuthID) | ||||||
|  | { | ||||||
|  | 	if (StrEqual(sAuthID, "STEAM_0:1:32247009")) | ||||||
|  | 		return true; | ||||||
|  | 
 | ||||||
|  | 	return SteamClientAuthenticated(sAuthID); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| //---------------------------------------------------------------------------------------------------- | //---------------------------------------------------------------------------------------------------- | ||||||
| // Purpose: | // Purpose: | ||||||
| //---------------------------------------------------------------------------------------------------- | //---------------------------------------------------------------------------------------------------- | ||||||
| @ -110,6 +123,41 @@ public Action Command_GetAuth(int client, int args) | |||||||
| 	return Plugin_Handled; | 	return Plugin_Handled; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | //---------------------------------------------------------------------------------------------------- | ||||||
|  | // Purpose: | ||||||
|  | //---------------------------------------------------------------------------------------------------- | ||||||
|  | public Action Command_DisplaySteamStats(int client, int args) | ||||||
|  | { | ||||||
|  | 	char aBuf[1024]; | ||||||
|  | 	char aBuf2[MAX_NAME_LENGTH]; | ||||||
|  | 
 | ||||||
|  | 	for(int i = 1; i <= MaxClients; i++) | ||||||
|  | 	{ | ||||||
|  | 		if(IsClientInGame(i) && !IsFakeClient(i)) | ||||||
|  | 		{ | ||||||
|  | 			char sAuthID[32]; | ||||||
|  | 			GetClientAuthId(i, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); | ||||||
|  | 
 | ||||||
|  | 			if(!SteamClientAuthenticatedEx(sAuthID)) | ||||||
|  | 			{ | ||||||
|  | 				GetClientName(i, aBuf2, sizeof(aBuf2)); | ||||||
|  | 				StrCat(aBuf, sizeof(aBuf), aBuf2); | ||||||
|  | 				StrCat(aBuf, sizeof(aBuf), ", "); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	if(strlen(aBuf)) | ||||||
|  | 	{ | ||||||
|  | 		aBuf[strlen(aBuf) - 2] = 0; | ||||||
|  | 		ReplyToCommand(client, "[SM] No-Steam clients online: %s", aBuf); | ||||||
|  | 	} | ||||||
|  | 	else | ||||||
|  | 		ReplyToCommand(client, "[SM] No-Steam clients online: none"); | ||||||
|  | 
 | ||||||
|  | 	return Plugin_Handled; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| //---------------------------------------------------------------------------------------------------- | //---------------------------------------------------------------------------------------------------- | ||||||
| // Purpose: | // Purpose: | ||||||
| //---------------------------------------------------------------------------------------------------- | //---------------------------------------------------------------------------------------------------- | ||||||
| @ -134,41 +182,6 @@ public Action Command_DebugNoSteam(int client, int args) | |||||||
| 	return Plugin_Handled; | 	return Plugin_Handled; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| //---------------------------------------------------------------------------------------------------- |  | ||||||
| // Purpose: |  | ||||||
| //---------------------------------------------------------------------------------------------------- |  | ||||||
| public Action Command_DisplaySteamStats(int client, int args) |  | ||||||
| { |  | ||||||
| 	char aBuf[1024]; |  | ||||||
| 	char aBuf2[MAX_NAME_LENGTH]; |  | ||||||
| 
 |  | ||||||
| 	for(int i = 1; i <= MaxClients; i++) |  | ||||||
| 	{ |  | ||||||
| 		if(IsClientInGame(i) && !IsFakeClient(i)) |  | ||||||
| 		{ |  | ||||||
| 			char sAuthID[32]; |  | ||||||
| 			GetClientAuthId(i, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); |  | ||||||
| 
 |  | ||||||
| 			if(!SteamClientAuthenticated(sAuthID)) |  | ||||||
| 			{ |  | ||||||
| 				GetClientName(i, aBuf2, sizeof(aBuf2)); |  | ||||||
| 				StrCat(aBuf, sizeof(aBuf), aBuf2); |  | ||||||
| 				StrCat(aBuf, sizeof(aBuf), ", "); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	if(strlen(aBuf)) |  | ||||||
| 	{ |  | ||||||
| 		aBuf[strlen(aBuf) - 2] = 0; |  | ||||||
| 		ReplyToCommand(client, "[SM] No-Steam clients online: %s", aBuf); |  | ||||||
| 	} |  | ||||||
| 	else |  | ||||||
| 		ReplyToCommand(client, "[SM] No-Steam clients online: none"); |  | ||||||
| 
 |  | ||||||
| 	return Plugin_Handled; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| //---------------------------------------------------------------------------------------------------- | //---------------------------------------------------------------------------------------------------- | ||||||
| // Purpose: | // Purpose: | ||||||
| //---------------------------------------------------------------------------------------------------- | //---------------------------------------------------------------------------------------------------- | ||||||
| @ -181,7 +194,7 @@ public bool Filter_Steam(const char[] sPattern, Handle hClients) | |||||||
| 			char sAuthID[32]; | 			char sAuthID[32]; | ||||||
| 			GetClientAuthId(i, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); | 			GetClientAuthId(i, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); | ||||||
| 
 | 
 | ||||||
| 			if(SteamClientAuthenticated(sAuthID)) | 			if(SteamClientAuthenticatedEx(sAuthID)) | ||||||
| 				PushArrayCell(hClients, i); | 				PushArrayCell(hClients, i); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @ -200,13 +213,54 @@ public bool Filter_NoSteam(const char[] sPattern, Handle hClients) | |||||||
| 			char sAuthID[32]; | 			char sAuthID[32]; | ||||||
| 			GetClientAuthId(i, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); | 			GetClientAuthId(i, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); | ||||||
| 
 | 
 | ||||||
| 			if(!SteamClientAuthenticated(sAuthID)) | 			if(!SteamClientAuthenticatedEx(sAuthID)) | ||||||
| 				PushArrayCell(hClients, i); | 				PushArrayCell(hClients, i); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | //---------------------------------------------------------------------------------------------------- | ||||||
|  | // Purpose: | ||||||
|  | //---------------------------------------------------------------------------------------------------- | ||||||
|  | public EConnect OnClientPreConnectEx(const char[] sName, char sPassword[255], const char[] sIP, const char[] sSteam32ID, char sRejectReason[255]) | ||||||
|  | { | ||||||
|  | 	char sAuthID[32]; | ||||||
|  | 	for(int client = 1; client <= MaxClients; client++) | ||||||
|  | 	{ | ||||||
|  | 		if(IsClientInGame(client) && !IsFakeClient(client)) | ||||||
|  | 		{ | ||||||
|  | 			GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); | ||||||
|  | 
 | ||||||
|  | 			if(StrEqual(sAuthID, sSteam32ID, false)) | ||||||
|  | 			{ | ||||||
|  | 				char sClientIP[32]; | ||||||
|  | 				GetClientIP(client, sClientIP, sizeof(sClientIP)); | ||||||
|  | 				if(IsClientTimingOut(client) || StrEqual(sIP, sClientIP, false)) | ||||||
|  | 				{ | ||||||
|  | 					KickClientEx(client, "Timed out"); | ||||||
|  | 					return k_OnClientPreConnectEx_Accept; | ||||||
|  | 				} | ||||||
|  | 				else | ||||||
|  | 				{ | ||||||
|  | 					LogAction(client, -1, "\"%L\" got protected from getting kicked by a new connection. Possible spoofing attempt from IP: %s", client, sIP); | ||||||
|  | 					Format(sRejectReason, sizeof(sRejectReason), "SteamID already on the server"); | ||||||
|  | 					return k_OnClientPreConnectEx_Reject; | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	return k_OnClientPreConnectEx_Accept; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | //---------------------------------------------------------------------------------------------------- | ||||||
|  | // Purpose: | ||||||
|  | //---------------------------------------------------------------------------------------------------- | ||||||
|  | public void OnClientPutInServer(int client) | ||||||
|  | { | ||||||
|  |     CreateTimer(g_hCvar_AuthenticationTime.FloatValue, CheckAuth, GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| //---------------------------------------------------------------------------------------------------- | //---------------------------------------------------------------------------------------------------- | ||||||
| // Purpose: | // Purpose: | ||||||
| //---------------------------------------------------------------------------------------------------- | //---------------------------------------------------------------------------------------------------- | ||||||
| @ -238,7 +292,7 @@ public Action OnClientPreAdminCheck(int client) | |||||||
| 	char sAuthID[32]; | 	char sAuthID[32]; | ||||||
| 	GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); | 	GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); | ||||||
| 
 | 
 | ||||||
| 	if(!SteamClientAuthenticated(sAuthID)) | 	if(!SteamClientAuthenticatedEx(sAuthID)) | ||||||
| 	{ | 	{ | ||||||
| 		LogMessage("%L was not authenticated with steam, denying admin.", client); | 		LogMessage("%L was not authenticated with steam, denying admin.", client); | ||||||
| 		NotifyPostAdminCheck(client); | 		NotifyPostAdminCheck(client); | ||||||
| @ -261,7 +315,7 @@ public void OnClientPostAdminCheck(int client) | |||||||
| 	char sAuthID[32]; | 	char sAuthID[32]; | ||||||
| 	GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); | 	GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); | ||||||
| 
 | 
 | ||||||
| 	if(!SteamClientAuthenticated(sAuthID)) | 	if(!SteamClientAuthenticatedEx(sAuthID)) | ||||||
| 	{ | 	{ | ||||||
| 		LogMessage("%L was not authenticated with steam, muting client.", client); | 		LogMessage("%L was not authenticated with steam, muting client.", client); | ||||||
| 		BaseComm_SetClientMute(client, true); | 		BaseComm_SetClientMute(client, true); | ||||||
| @ -269,6 +323,24 @@ public void OnClientPostAdminCheck(int client) | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | //---------------------------------------------------------------------------------------------------- | ||||||
|  | // Purpose: | ||||||
|  | //---------------------------------------------------------------------------------------------------- | ||||||
|  | public Action CheckAuth(Handle timer, int data) | ||||||
|  | { | ||||||
|  | 	int client; | ||||||
|  | 	if ((client = GetClientFromSerial(data)) == 0) | ||||||
|  | 		return Plugin_Stop; | ||||||
|  | 
 | ||||||
|  | 	char sAuthID[32]; | ||||||
|  | 	if(!GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), true)) | ||||||
|  | 	{ | ||||||
|  | 		LogMessage("%L could not be assigned to a SteamID, kicking client.", client); | ||||||
|  | 		KickClient(client, "Invalid STEAMID"); | ||||||
|  | 	} | ||||||
|  | 	return Plugin_Stop; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| //---------------------------------------------------------------------------------------------------- | //---------------------------------------------------------------------------------------------------- | ||||||
| // Purpose: | // Purpose: | ||||||
| //---------------------------------------------------------------------------------------------------- | //---------------------------------------------------------------------------------------------------- | ||||||
| @ -310,7 +382,7 @@ public void SQL_OnQueryCompleted(Database db, DBResultSet results, const char[] | |||||||
| 	GetClientIP(client, sAddress, sizeof(sAddress)); | 	GetClientIP(client, sAddress, sizeof(sAddress)); | ||||||
| 
 | 
 | ||||||
| 	char sConnectionType[32]; | 	char sConnectionType[32]; | ||||||
| 	if(SteamClientAuthenticated(sAuthID)) | 	if(SteamClientAuthenticatedEx(sAuthID)) | ||||||
| 		sConnectionType = "SteamLegit"; | 		sConnectionType = "SteamLegit"; | ||||||
| 	else | 	else | ||||||
| 		sConnectionType = "NoAuth"; | 		sConnectionType = "NoAuth"; | ||||||
| @ -329,7 +401,7 @@ public void SQL_OnQueryCompleted(Database db, DBResultSet results, const char[] | |||||||
| 
 | 
 | ||||||
| 		delete results; | 		delete results; | ||||||
| 
 | 
 | ||||||
| 		if(!SteamClientAuthenticated(sAuthID)) | 		if(!SteamClientAuthenticatedEx(sAuthID)) | ||||||
| 		{ | 		{ | ||||||
| 			if(!StrEqual(sConnectionType, sResultConnectionType, false) && StrEqual(sResultConnectionType, "SteamLegit", false)) | 			if(!StrEqual(sConnectionType, sResultConnectionType, false) && StrEqual(sResultConnectionType, "SteamLegit", false)) | ||||||
| 			{ | 			{ | ||||||
| @ -376,7 +448,7 @@ public int Native_IsPlayerSteam(Handle hPlugin, int numParams) | |||||||
| 	char sAuthID[32]; | 	char sAuthID[32]; | ||||||
| 	GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); | 	GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); | ||||||
| 
 | 
 | ||||||
| 	if(SteamClientAuthenticated(sAuthID)) | 	if(SteamClientAuthenticatedEx(sAuthID)) | ||||||
| 		return true; | 		return true; | ||||||
| 
 | 
 | ||||||
| 	return false; | 	return false; | ||||||
| @ -406,7 +478,7 @@ public int Native_GetPlayerType(Handle hPlugin, int numParams) | |||||||
| 	char sAuthID[32]; | 	char sAuthID[32]; | ||||||
| 	GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); | 	GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); | ||||||
| 
 | 
 | ||||||
| 	if(SteamClientAuthenticated(sAuthID)) | 	if(SteamClientAuthenticatedEx(sAuthID)) | ||||||
| 		return !SetNativeString(2, "SteamLegit", length + 1); | 		return !SetNativeString(2, "SteamLegit", length + 1); | ||||||
| 
 | 
 | ||||||
| 	return !SetNativeString(2, "NoAuth", length + 1); | 	return !SetNativeString(2, "NoAuth", length + 1); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user