Skip to content

Commit 74feef8

Browse files
authored
feat: bump to 2.20 (#3)
2.20 (20-Jan-2023) - Now logs if a Steam ID is unverified. - Now prevents log spamming duplicate entries. - Fixed checking bots for sprays. - Thanks to ".Rushaway" for reporting and help testing. 2.19 (07-Jan-2023) - Fixed processing getting stuck. Thanks to "SuperConker" for reporting and help testing. - Fixed invalid handle errors. Thanks to "nikooo777" for reporting.
1 parent 21b381a commit 74feef8

File tree

1 file changed

+118
-31
lines changed

1 file changed

+118
-31
lines changed

addons/sourcemod/scripting/FixSprayExploit.sp

Lines changed: 118 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Spray Exploit Fixer
3-
* Copyright (C) 2022 Silvers
3+
* Copyright (C) 2023 Silvers
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
1818

1919

2020

21-
#define PLUGIN_VERSION "2.18"
21+
#define PLUGIN_VERSION "2.20"
2222

2323
/*=======================================================================================
2424
Plugin Info:
@@ -32,8 +32,18 @@
3232
========================================================================================
3333
Change Log:
3434
35+
2.20 (20-Jan-2023)
36+
- Now logs if a Steam ID is unverified.
37+
- Now prevents log spamming duplicate entries.
38+
- Fixed checking bots for sprays.
39+
- Thanks to ".Rushaway" for reporting and help testing.
40+
41+
2.19 (07-Jan-2023)
42+
- Fixed processing getting stuck. Thanks to "SuperConker" for reporting and help testing.
43+
- Fixed invalid handle errors. Thanks to "nikooo777" for reporting.
44+
3545
2.18 (24-Dec-2022)
36-
- Fixed moving sprays causing a script execution timed out error. Thanks to ".Rushaway" for reporting.
46+
- Changed moving sprays to use an asynchronous method to prevent a script execution timed out error. Thanks to ".Rushaway" for reporting.
3747
3848
2.17 (08-Oct-2022)
3949
- Fixed command "sm_spray_test" getting stuck processing under certain conditions.
@@ -166,9 +176,11 @@ char g_sPath2[MAXPLAYERS+1][PLATFORM_MAX_PATH];
166176
ConVar g_hCvarBan, g_hCvarKick, g_hCvarLog, g_hCvarMsg, g_hCvarPath;
167177
EngineVersion g_iEngine;
168178
StringMap g_smChecked;
169-
ArrayList g_alFiles;
179+
StringMap g_smReceive;
180+
StringMap g_smWaiting;
170181
int g_iTotal;
171182
float g_fTime;
183+
bool g_bLate;
172184
bool g_bProc;
173185
bool g_bDecal;
174186
bool g_bSourceBans;
@@ -202,6 +214,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
202214
MarkNativeAsOptional("MABanPlayer");
203215

204216
g_iEngine = GetEngineVersion();
217+
g_bLate = late;
205218

206219
return APLRes_Success;
207220
}
@@ -251,6 +264,8 @@ public void OnPluginStart()
251264
g_hCvarPath.AddChangeHook(ConVarChanged_Cvars);
252265

253266
g_smChecked = new StringMap();
267+
g_smReceive = new StringMap();
268+
g_smWaiting = new StringMap();
254269

255270
AddTempEntHook("Player Decal", PlayerDecal);
256271

@@ -260,7 +275,8 @@ public void OnPluginStart()
260275
StrCat(sPath, sizeof(sPath), PATH_BACKUP);
261276
CreateDirectory(sPath, 511, true);
262277

263-
MoveSprays();
278+
if( !g_bLate )
279+
MoveSprays();
264280
}
265281

266282
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3])
@@ -296,6 +312,19 @@ public void OnClientDisconnect(int client)
296312
{
297313
if( IsFakeClient(client) ) return;
298314

315+
if( IsClientConnected(client) )
316+
{
317+
static char auth[32];
318+
GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth), false);
319+
g_smWaiting.Remove(auth);
320+
}
321+
322+
g_smChecked.Remove(g_sPath1[client]);
323+
g_smReceive.Remove(g_sPath1[client]);
324+
g_smChecked.Remove(g_sPath2[client]);
325+
g_smReceive.Remove(g_sPath2[client]);
326+
327+
/*
299328
static char sPath[PLATFORM_MAX_PATH];
300329
static char sOld[PLATFORM_MAX_PATH];
301330
static char sNew[PLATFORM_MAX_PATH];
@@ -325,9 +354,15 @@ public void OnClientDisconnect(int client)
325354
if( sPath[0] )
326355
{
327356
if( i == 0 )
357+
{
328358
g_smChecked.Remove(g_sPath1[client]);
359+
g_smReceive.Remove(g_sPath1[client]);
360+
}
329361
else
362+
{
330363
g_smChecked.Remove(g_sPath2[client]);
364+
g_smReceive.Remove(g_sPath2[client]);
365+
}
331366
332367
Format(sOld, sizeof(sOld), "%s%s.dat", g_sDownloads, sPath);
333368
Format(sNew, sizeof(sNew), "%s%s/%s.dat", g_sDownloads, PATH_BACKUP, sPath);
@@ -348,11 +383,14 @@ public void OnClientDisconnect(int client)
348383
}
349384
}
350385
}
386+
*/
351387
}
352388

353389
public void OnMapEnd()
354390
{
355391
MoveSprays();
392+
g_smReceive.Clear();
393+
g_smWaiting.Clear();
356394
}
357395

358396
void ConVarChanged_Cvars(Handle convar, const char[] oldValue, const char[] newValue)
@@ -374,20 +412,18 @@ Action CmdSprays(int client, int args)
374412
g_bProc = true;
375413
g_fTime = GetEngineTime();
376414

377-
delete g_alFiles;
378-
g_alFiles = new ArrayList(ByteCountToCells(PLATFORM_MAX_PATH));
415+
ArrayList aList = new ArrayList(ByteCountToCells(PLATFORM_MAX_PATH));
379416

380417
int pos = StrContains(g_sDownloads, "/");
381418
if( pos != -1 ) g_sDownloads[pos] = 0;
382419

383-
RecursiveFiles(g_alFiles, false, g_sDownloads);
420+
RecursiveFiles(aList, false, g_sDownloads);
384421

385422
if( pos != -1 ) g_sDownloads[pos] = '/';
386423

387424
int count, counts;
388-
RecursiveSearchDirs(client, g_alFiles, count, counts, false);
425+
RecursiveSearchDirs(client, aList, count, counts, false);
389426

390-
delete g_alFiles;
391427
return Plugin_Handled;
392428
}
393429

@@ -486,16 +522,15 @@ void MoveSprays()
486522
{
487523
int count, counts;
488524

489-
delete g_alFiles;
490-
g_alFiles = new ArrayList(ByteCountToCells(PLATFORM_MAX_PATH));
525+
ArrayList aList = new ArrayList(ByteCountToCells(PLATFORM_MAX_PATH));
491526

492527
strcopy(g_sMoveFiles, sizeof(g_sMoveFiles), g_sDownloads);
493528

494529
int pos = StrContains(g_sMoveFiles, "/");
495530
if( pos != -1 ) g_sMoveFiles[pos] = 0;
496531

497-
RecursiveFiles(g_alFiles, true, g_sMoveFiles);
498-
RecursiveSearchDirs(0, g_alFiles, count, counts, true);
532+
RecursiveFiles(aList, true, g_sMoveFiles);
533+
RecursiveSearchDirs(0, aList, count, counts, true);
499534
}
500535

501536
void RecursiveSearchDirs(int client, ArrayList aList, int &count, int &counts, bool move = false)
@@ -571,12 +606,14 @@ void RecursiveSearchDirs(int client, ArrayList aList, int &count, int &counts, b
571606
g_bProc = false;
572607

573608
ReplyToCommand(client, "[Sprays] downloads checked. Found %d of %d invalid. Took %0.2f seconds.", count, counts, GetEngineTime() - g_fTime);
609+
610+
delete aList;
574611
}
575612
else
576613
{
577614
DeleteEmptyDirs(g_sMoveFiles);
578615

579-
delete g_alFiles;
616+
delete aList;
580617
}
581618
}
582619
}
@@ -653,6 +690,12 @@ Action PlayerDecal(const char[] te_name, const int[] Players, int numClients, fl
653690
return Plugin_Handled;
654691
}
655692

693+
if( IsFakeClient(client) )
694+
{
695+
return Plugin_Continue;
696+
}
697+
698+
g_sFilename[0] = 0;
656699
GetPlayerDecalFile(client, g_sFilename, sizeof(g_sFilename));
657700

658701
bool val;
@@ -676,8 +719,13 @@ Action PlayerDecal(const char[] te_name, const int[] Players, int numClients, fl
676719

677720
if( !val )
678721
{
679-
char auth[20];
722+
static char auth[32];
680723
GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth));
724+
if( strncmp(auth[6], "ID_", 3) == 0 )
725+
{
726+
GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth), false);
727+
Format(auth, sizeof(auth), "Unverified: %s", auth);
728+
}
681729

682730
if( FileExists(g_sFilename) )
683731
{
@@ -688,8 +736,12 @@ Action PlayerDecal(const char[] te_name, const int[] Players, int numClients, fl
688736
}
689737
else
690738
{
691-
if( g_hCvarLog.IntValue ) LogCustom("Blocked unchecked spray - missing file: %s from (%N) [%s]", g_sFilename, client, auth);
692-
if( g_hCvarMsg.IntValue == 1 ) PrintToServer("[Spray Exploit] Blocked unchecked spray - missing file: %s from (%N) [%s]", g_sFilename, client, auth);
739+
if( !g_smWaiting.GetValue(auth, val) )
740+
{
741+
g_smWaiting.SetValue(auth, true);
742+
if( g_hCvarLog.IntValue ) LogCustom("Blocked unchecked spray - missing file: %s from (%N) [%s]", g_sFilename, client, auth);
743+
if( g_hCvarMsg.IntValue == 1 ) PrintToServer("[Spray Exploit] Blocked unchecked spray - missing file: %s from (%N) [%s]", g_sFilename, client, auth);
744+
}
693745
}
694746

695747
float vPos[3];
@@ -801,27 +853,56 @@ public Action OnFileReceive(int client, const char[] sFile)
801853
client = GetClientFromSpray();
802854
if( !client ) client = GetClientFromJingle();
803855

804-
if( g_hCvarLog.IntValue == 1 )
856+
bool log;
857+
858+
if( client )
805859
{
806-
if( client )
860+
static char sPath[PLATFORM_MAX_PATH];
861+
862+
GetPlayerDecalFile(client, sPath, sizeof(sPath));
863+
if( strcmp(sPath, g_sPath1[client]) )
807864
{
808-
static char auth[20];
809-
GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth));
810-
LogCustom("File received: %s from (%N) [%s]", sFile, client, auth);
865+
ReplaceString(sPath, sizeof(sPath), g_sDownloads, "");
866+
strcopy(g_sPath1[client], sizeof(g_sPath1[]), sPath);
867+
log = true;
811868
}
812-
else
869+
870+
GetPlayerJingleFile(client, sPath, sizeof(sPath));
871+
if( strcmp(sPath, g_sPath2[client]) )
813872
{
814-
LogCustom("File received: %s", sFile);
873+
ReplaceString(sPath, sizeof(sPath), g_sDownloads, "");
874+
strcopy(g_sPath2[client], sizeof(g_sPath2[]), sPath);
875+
log = true;
815876
}
816877
}
878+
else
879+
{
880+
log = true;
881+
}
817882

818-
if( client )
883+
if( log && g_hCvarLog.IntValue == 1 )
819884
{
820-
GetPlayerDecalFile(client, g_sPath1[client], sizeof(g_sPath1[]));
821-
ReplaceString(g_sPath1[client], sizeof(g_sPath1[]), g_sDownloads, "");
885+
if( client )
886+
{
887+
static char auth[32];
888+
GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth));
889+
if( strncmp(auth[6], "ID_", 3) == 0 )
890+
{
891+
GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth), false);
892+
Format(auth, sizeof(auth), "Unverified: %s", auth);
893+
}
822894

823-
GetPlayerJingleFile(client, g_sPath2[client], sizeof(g_sPath2[]));
824-
ReplaceString(g_sPath2[client], sizeof(g_sPath2[]), g_sDownloads, "");
895+
LogCustom("File received: %s from (%N) [%s]", sFile, client, auth);
896+
}
897+
else
898+
{
899+
int val;
900+
if( !g_smReceive.GetValue(sFile, val) )
901+
{
902+
g_smReceive.SetValue(sFile, true);
903+
LogCustom("File received: %s", sFile);
904+
}
905+
}
825906
}
826907

827908
return Plugin_Continue;
@@ -869,8 +950,14 @@ void FileCheck()
869950
if( !client ) client = GetClientFromJingle();
870951
if( client )
871952
{
872-
char auth[20];
953+
char auth[32];
873954
GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth));
955+
if( strncmp(auth[6], "ID_", 3) == 0 )
956+
{
957+
GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth), false);
958+
Format(auth, sizeof(auth), "Unverified: %s", auth);
959+
}
960+
874961
if( g_hCvarLog.IntValue ) LogCustom("Invalid spray: %s from (%N) [%s]", g_sFilename, client, auth);
875962
if( g_hCvarMsg.IntValue ) PrintToServer("[Spray Exploit] Invalid spray: %s: %02d (%02X <> %02X) from (%N) [%s]", g_sFilename, i, iRead[i], g_iVal[i], client, auth);
876963
} else {

0 commit comments

Comments
 (0)