From 0c8697438b8a20cdcd1bbf9d9ead9498b1303f75 Mon Sep 17 00:00:00 2001 From: zaCade Date: Sun, 15 Jul 2018 23:38:20 +0200 Subject: [PATCH] NoSteamManager: Potentially block steamid spoofs. Block no-steamers from joining whenever the 'owner' of the steamid is connected, or kick them whenever the 'owner' is connecting. --- NoSteamManager/scripting/NoSteamManager.sp | 56 ++++++++++++++++++++-- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/NoSteamManager/scripting/NoSteamManager.sp b/NoSteamManager/scripting/NoSteamManager.sp index 6986c629..e571ea69 100644 --- a/NoSteamManager/scripting/NoSteamManager.sp +++ b/NoSteamManager/scripting/NoSteamManager.sp @@ -9,6 +9,7 @@ /* CONVARS */ ConVar g_hCvar_BlockAdmin; ConVar g_hCvar_BlockVoice; +ConVar g_hCvar_BlockSpoof; //---------------------------------------------------------------------------------------------------- // Purpose: @@ -28,6 +29,7 @@ public void OnPluginStart() { g_hCvar_BlockAdmin = CreateConVar("sm_nosteam_block_admin", "1", "Should people marked as nosteam be blocked from admin?", FCVAR_NONE, true, 0.0, true, 1.0); g_hCvar_BlockVoice = CreateConVar("sm_nosteam_block_voice", "1", "Should people marked as nosteam be blocked from voice?", FCVAR_NONE, true, 0.0, true, 1.0); + g_hCvar_BlockSpoof = CreateConVar("sm_nosteam_block_spoof", "1", "Block nosteam people being able to spoof steamids.", FCVAR_NONE, true, 0.0, true, 1.0); AddMultiTargetFilter("@steam", Filter_Steam, "Steam Players", false); AddMultiTargetFilter("@nosteam", Filter_NoSteam, "No-Steam Players", false); @@ -125,10 +127,10 @@ public bool Filter_NoSteam(const char[] sPattern, Handle hClients) //---------------------------------------------------------------------------------------------------- public Action OnClientPreAdminCheck(int client) { - if (!g_hCvar_BlockAdmin.BoolValue) + if(!g_hCvar_BlockAdmin.BoolValue) return Plugin_Continue; - if (IsFakeClient(client) || IsClientSourceTV(client)) + if(IsFakeClient(client) || IsClientSourceTV(client)) return Plugin_Continue; char sSteamID[32]; @@ -150,10 +152,10 @@ public Action OnClientPreAdminCheck(int client) //---------------------------------------------------------------------------------------------------- public void OnClientPostAdminCheck(int client) { - if (!g_hCvar_BlockVoice.BoolValue) + if(!g_hCvar_BlockVoice.BoolValue) return; - if (IsFakeClient(client) || IsClientSourceTV(client)) + if(IsFakeClient(client) || IsClientSourceTV(client)) return; char sSteamID[32]; @@ -167,3 +169,49 @@ public void OnClientPostAdminCheck(int client) return; } } + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnClientPutInServer(int client) +{ + if(!g_hCvar_BlockSpoof.BoolValue) + return; + + if(IsFakeClient(client) || IsClientSourceTV(client)) + return; + + char sSteamID[32]; + GetClientAuthId(client, AuthId_Steam2, sSteamID, sizeof(sSteamID)); + + for(int player = 1; player <= MaxClients; player++) + { + if(IsFakeClient(player) || IsClientSourceTV(player)) + continue; + + if(client == player || !IsClientConnected(player)) + continue; + + char sPlayerSteamID[32]; + GetClientAuthId(player, AuthId_Steam2, sPlayerSteamID, sizeof(sPlayerSteamID)); + + if(StrEqual(sSteamID, sPlayerSteamID, false)) + { + if(!SteamClientAuthenticated(sSteamID)) + { + LogMessage("%L was not authenticated with steam, steamid already connected. Kicking connector.", client); + KickClient(client, "Please come back later."); + return; + } + + if(!SteamClientAuthenticated(sPlayerSteamID)) + { + LogMessage("%L was not authenticated with steam, steamid already connected. Kicking connected.", player); + KickClient(player, "Please come back later."); + return; + } + + break; + } + } +}