From 16e0f502bd2a1ceb762e1c8f92c824e4514fd8ac Mon Sep 17 00:00:00 2001 From: rlevet <36737524+rlevet@users.noreply.github.com> Date: Sun, 31 Jan 2021 02:36:30 +0100 Subject: [PATCH 1/3] Crash exploit when warden fix --- .../MyJailbreak/Modules/Warden/handcuffs.sp | 18 ++++++++++++------ .../sourcemod/scripting/MyJailbreak/warden.sp | 3 ++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/addons/sourcemod/scripting/MyJailbreak/Modules/Warden/handcuffs.sp b/addons/sourcemod/scripting/MyJailbreak/Modules/Warden/handcuffs.sp index 47e6c763..d19f1764 100644 --- a/addons/sourcemod/scripting/MyJailbreak/Modules/Warden/handcuffs.sp +++ b/addons/sourcemod/scripting/MyJailbreak/Modules/Warden/handcuffs.sp @@ -69,6 +69,7 @@ ConVar gc_iCuffedColorBlue; // Booleans bool g_bCuffed[MAXPLAYERS+1] = false; +bool g_bClientIsDisconnecting[MAXPLAYERS+1]; // fixes StripZeus crash // Integers int g_iPlayerHandCuffs[MAXPLAYERS+1]; @@ -136,8 +137,8 @@ public void HandCuffs_OnSettingChanged(Handle convar, const char[] oldValue, con { strcopy(g_sSoundCuffsPath, sizeof(g_sSoundCuffsPath), newValue); - if (gc_bSounds.BoolValue) - { + if (gc_bSounds.BoolValue) + { PrecacheSoundAnyDownload(g_sSoundCuffsPath); } } @@ -145,8 +146,8 @@ public void HandCuffs_OnSettingChanged(Handle convar, const char[] oldValue, con { strcopy(g_sSoundBreakCuffsPath, sizeof(g_sSoundBreakCuffsPath), newValue); - if (gc_bSounds.BoolValue) - { + if (gc_bSounds.BoolValue) + { PrecacheSoundAnyDownload(g_sSoundBreakCuffsPath); } } @@ -154,8 +155,8 @@ public void HandCuffs_OnSettingChanged(Handle convar, const char[] oldValue, con { strcopy(g_sSoundUnLockCuffsPath, sizeof(g_sSoundUnLockCuffsPath), newValue); - if (gc_bSounds.BoolValue) - { + if (gc_bSounds.BoolValue) + { PrecacheSoundAnyDownload(g_sSoundUnLockCuffsPath); } } @@ -443,6 +444,7 @@ public void HandCuffs_OnClientDisconnect(int client) g_iCuffed--; g_iLastButtons[client] = 0; + g_bClientIsDisconnecting[client] = true; if (BreakTimer[client] != null) { @@ -484,6 +486,7 @@ public void HandCuffs_OnMapEnd() public void HandCuffs_OnClientPutInServer(int client) { g_iPlayerPaperClips[client] = 0; + g_bClientIsDisconnecting[client] = false; SDKHook(client, SDKHook_OnTakeDamage, HandCuffs_OnTakedamage); } @@ -744,6 +747,9 @@ void StripZeus(int client) if (!IsValidClient(client, true, false)) return; + if (g_bClientIsDisconnecting) // OnClientDisconnect is called BEFORE client fully disconnects, so he still passes IsValidClient check + return; // prevents infinite loops with #GameUI_Disconnect_TooManyCommands since FakeClientCommand is used + if ((!IsClientWarden(client) && (!IsClientDeputy(client) && gc_bHandCuffDeputy.BoolValue))) return; diff --git a/addons/sourcemod/scripting/MyJailbreak/warden.sp b/addons/sourcemod/scripting/MyJailbreak/warden.sp index 564ec677..e7e5966b 100644 --- a/addons/sourcemod/scripting/MyJailbreak/warden.sp +++ b/addons/sourcemod/scripting/MyJailbreak/warden.sp @@ -1249,6 +1249,8 @@ public void OnClientDisconnect(int client) PrintCenterTextAll("%t", "warden_disconnected_nc", client); } + HandCuffs_OnClientDisconnect(client); // this is prioritised to fix a crash with the StripZeus function + Forward_OnWardenRemoved(client); Forward_OnWardenDisconnected(client); @@ -1272,7 +1274,6 @@ public void OnClientDisconnect(int client) Deputy_OnClientDisconnect(client); Painter_OnClientDisconnect(client); - HandCuffs_OnClientDisconnect(client); Freedays_OnClientDisconnect(client); } From 546d69be73e9483aa0824dadc9b03a9fadfaefa0 Mon Sep 17 00:00:00 2001 From: rlevet <36737524+rlevet@users.noreply.github.com> Date: Mon, 1 Feb 2021 00:20:42 +0100 Subject: [PATCH 2/3] Fixed a check --- .../sourcemod/scripting/MyJailbreak/Modules/Warden/handcuffs.sp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sourcemod/scripting/MyJailbreak/Modules/Warden/handcuffs.sp b/addons/sourcemod/scripting/MyJailbreak/Modules/Warden/handcuffs.sp index d19f1764..95dc4599 100644 --- a/addons/sourcemod/scripting/MyJailbreak/Modules/Warden/handcuffs.sp +++ b/addons/sourcemod/scripting/MyJailbreak/Modules/Warden/handcuffs.sp @@ -747,7 +747,7 @@ void StripZeus(int client) if (!IsValidClient(client, true, false)) return; - if (g_bClientIsDisconnecting) // OnClientDisconnect is called BEFORE client fully disconnects, so he still passes IsValidClient check + if (g_bClientIsDisconnecting[client]) // OnClientDisconnect is called BEFORE client fully disconnects, so he still passes IsValidClient check return; // prevents infinite loops with #GameUI_Disconnect_TooManyCommands since FakeClientCommand is used if ((!IsClientWarden(client) && (!IsClientDeputy(client) && gc_bHandCuffDeputy.BoolValue))) From 95aea8dcc50c02c598ce3705a282d46126952ced Mon Sep 17 00:00:00 2001 From: rlevet <36737524+rlevet@users.noreply.github.com> Date: Mon, 1 Feb 2021 19:08:39 +0100 Subject: [PATCH 3/3] Fixes HandCuffs_OnClientDisconnect --- addons/sourcemod/scripting/MyJailbreak/warden.sp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/sourcemod/scripting/MyJailbreak/warden.sp b/addons/sourcemod/scripting/MyJailbreak/warden.sp index e7e5966b..e6484c30 100644 --- a/addons/sourcemod/scripting/MyJailbreak/warden.sp +++ b/addons/sourcemod/scripting/MyJailbreak/warden.sp @@ -1241,6 +1241,8 @@ public void OnClientPutInServer(int client) // Warden disconnect public void OnClientDisconnect(int client) { + HandCuffs_OnClientDisconnect(client); // this is prioritised to fix a crash with the StripZeus function + if (IsClientWarden(client)) { CPrintToChatAll("%s %t", g_sPrefix, "warden_disconnected", client); @@ -1249,8 +1251,6 @@ public void OnClientDisconnect(int client) PrintCenterTextAll("%t", "warden_disconnected_nc", client); } - HandCuffs_OnClientDisconnect(client); // this is prioritised to fix a crash with the StripZeus function - Forward_OnWardenRemoved(client); Forward_OnWardenDisconnected(client);