From aedc85f616b1f16291b05b514c5b3a0b83719c94 Mon Sep 17 00:00:00 2001 From: hubdom <26039831+hubdom@users.noreply.github.com> Date: Wed, 2 Jun 2021 18:04:02 +0200 Subject: [PATCH] exploit_listener: initial commit --- ExploitListener/scripting/exploit_listener.sp | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 ExploitListener/scripting/exploit_listener.sp diff --git a/ExploitListener/scripting/exploit_listener.sp b/ExploitListener/scripting/exploit_listener.sp new file mode 100644 index 00000000..9fb552f4 --- /dev/null +++ b/ExploitListener/scripting/exploit_listener.sp @@ -0,0 +1,135 @@ +#include + + +#pragma newdecls required +#pragma semicolon 1 + +char g_sLogFile[PLATFORM_MAX_PATH]; +char g_sLogFileRecording[PLATFORM_MAX_PATH]; +bool g_bEvil[MAXPLAYERS + 1]; + +bool g_bRecording; + + + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnPluginStart() +{ + BuildPath(Path_SM, g_sLogFile, sizeof(g_sLogFile), "logs/exploiter.txt"); + BuildPath(Path_SM, g_sLogFileRecording, sizeof(g_sLogFileRecording), "logs/lag_recording.txt"); + + for(int client = 1; client <= MaxClients; client++) + { + if(IsValidClient(client) && IsClientAuthorized(client)) + { + char sAuthID[32]; + GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID)); + + OnClientAuthorized(client, sAuthID); + } + + } + AddCommandListener(Command_CommandListener); + + RegAdminCmd("sm_lag", Command_Record, ADMFLAG_KICK); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Action Command_CommandListener(int client, const char[] command,int argc) +{ + if (g_bRecording) + { + char sBuffer[1024]; + GetCmdArgString(sBuffer, sizeof(sBuffer)); + LogToFile(g_sLogFileRecording, "%L: [%s] [%s]", client, command, sBuffer); + } + else + { + if (!g_bEvil[client]) + return Plugin_Continue; + + if (!IsValidClient(client)) + return Plugin_Continue; + + if (!IsClientAuthorized(client)) + return Plugin_Continue; + + char sBuffer[1024]; + GetCmdArgString(sBuffer, sizeof(sBuffer)); + + LogToFile(g_sLogFile, "%L: [%s] [%s]", client, command, sBuffer); + } + return Plugin_Continue; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Action Command_Record(int client, int args) +{ + if (g_bRecording) + { + ReplyToCommand(client, "[SM] Lag is already being recorded."); + return Plugin_Handled; + } + + g_bRecording = true; + CreateTimer(30.0, StopRecording); + + LogAction(client, -1, "\"%L\" initiated a Lag Recording", client); + for(int i = 1; i <= MaxClients; i++) + { + if(IsClientInGame(i) && !IsFakeClient(i) && CheckCommandAccess(i, "sm_lag", ADMFLAG_GENERIC)) + PrintToChat(i, "[SM] Lag Recording has been started. Recording all client commands for the next 30s."); + } + + return Plugin_Handled; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Action StopRecording(Handle timer) +{ + g_bRecording = false; + + for(int i = 1; i <= MaxClients; i++) + { + if(IsClientInGame(i) && !IsFakeClient(i) && CheckCommandAccess(i, "sm_lag", ADMFLAG_GENERIC)) + PrintToChat(i, "[SM] Lag Recording has been stopped."); + } +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnClientAuthorized(int client, const char[] sAuthID) +{ + if (IsValidClient(client) && StrEqual(sAuthID, "STEAM_0:1:439160990")) + g_bEvil[client] = true; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnClientDisconnect(int client) +{ + g_bEvil[client] = false; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +stock int IsValidClient(int client, bool nobots = true) +{ + if (client <= 0 || client > MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client))) + return false; + + return IsClientInGame(client); +} + +