mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-20 01:46:19 +00:00
Detect RPC Spam
This commit is contained in:
1 parent
6d41c09ad9
commit
7d4ca88fab
6 files changed
+55
-34
No files matched your search
@@ -1,5 +1,7 @@
|
||||
using AmongUs.GameOptions;
|
||||
using BetterAmongUs.Items;
|
||||
using BetterAmongUs.Managers;
|
||||
using BetterAmongUs.Modules;
|
||||
using HarmonyLib;
|
||||
using InnerNet;
|
||||
using UnityEngine;
|
||||
@@ -18,9 +20,33 @@ public class ExtendedPlayerInfo : MonoBehaviour
|
||||
hasSet = true;
|
||||
}
|
||||
|
||||
private float timeAccumulator = 0f;
|
||||
public void Update()
|
||||
{
|
||||
AntiCheatInfo.TimeSinceLastTask += Time.deltaTime;
|
||||
var time = Time.deltaTime;
|
||||
|
||||
AntiCheatInfo.TimeSinceLastTask += time;
|
||||
|
||||
if (AntiCheatInfo.RPCSentPS > 0)
|
||||
{
|
||||
bool flag = _Data.Object.IsCheater();
|
||||
|
||||
if (AntiCheatInfo.RPCSentPS >= ExtendedAntiCheatInfo.MaxRPCSent && !flag)
|
||||
{
|
||||
BetterNotificationManager.NotifyCheat(_Data.Object,
|
||||
Translator.GetString("AntiCheat.Reason.RPCSentPS"),
|
||||
Translator.GetString("AntiCheat.UnauthorizedAction")
|
||||
);
|
||||
Logger.LogCheat($"{_Data.Object.BetterData().RealName} {AntiCheatInfo.RPCSentPS} Sent.");
|
||||
}
|
||||
|
||||
timeAccumulator += time;
|
||||
if (timeAccumulator >= 0.25f - (0.005 * AntiCheatInfo.RPCSentPS))
|
||||
{
|
||||
AntiCheatInfo.RPCSentPS -= 1;
|
||||
timeAccumulator = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void LateUpdate()
|
||||
@@ -52,6 +78,8 @@ public class ExtendedAntiCheatInfo
|
||||
{
|
||||
public bool BannedByAntiCheat { get; set; } = false;
|
||||
public List<string> AUMChats { get; set; } = [];
|
||||
public static int MaxRPCSent => 35;
|
||||
public int RPCSentPS { get; set; } = 0;
|
||||
public int TimesAttemptedKilled { get; set; } = 0;
|
||||
public int OpenSabotageNum { get; set; } = 0;
|
||||
public bool IsFixingPanelSabotage => OpenSabotageNum != 0;
|
||||
|
||||
@@ -13,7 +13,7 @@ class BAUAntiCheat
|
||||
public static Dictionary<string, string> SickoData = []; // HashPuid, FriendCode
|
||||
public static Dictionary<string, string> AUMData = []; // HashPuid, FriendCode
|
||||
public static Dictionary<string, string> KNData = []; // HashPuid, FriendCode
|
||||
public static bool IsEnabled { get; private set; } = true;
|
||||
public static bool IsEnabled => PlayerControl.LocalPlayer?.Data?.IsIncomplete == false;
|
||||
|
||||
public static string[] GatherAllData()
|
||||
{
|
||||
@@ -65,21 +65,6 @@ class BAUAntiCheat
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void PauseAntiCheat()
|
||||
{
|
||||
float time = 2.5f;
|
||||
if (IsEnabled)
|
||||
{
|
||||
IsEnabled = false;
|
||||
|
||||
_ = new LateTask(() =>
|
||||
{
|
||||
IsEnabled = true;
|
||||
}, time, "PauseAntiCheat");
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(PlatformSpecificData))]
|
||||
class PlatformSpecificDataPatch
|
||||
{
|
||||
|
||||
+24
-4
@@ -36,7 +36,13 @@ enum HandleGameDataTags : byte
|
||||
internal class PlayerControlRPCHandlerPatch
|
||||
{
|
||||
public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] byte callId, [HarmonyArgument(1)] MessageReader reader)
|
||||
{
|
||||
{
|
||||
__instance.BetterData().AntiCheatInfo.RPCSentPS++;
|
||||
if (__instance.BetterData().AntiCheatInfo.RPCSentPS >= ExtendedAntiCheatInfo.MaxRPCSent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
BAUAntiCheat.HandleCheatRPCBeforeCheck(__instance, callId, reader);
|
||||
|
||||
if (BAUAntiCheat.CheckCancelRPC(__instance, callId, reader) != true)
|
||||
@@ -59,15 +65,23 @@ internal class PlayerControlRPCHandlerPatch
|
||||
[HarmonyPatch(typeof(PlayerPhysics), nameof(PlayerPhysics.HandleRpc))]
|
||||
internal class PlayerPhysicsRPCHandlerPatch
|
||||
{
|
||||
public static void Prefix(PlayerPhysics __instance, [HarmonyArgument(0)] byte callId, [HarmonyArgument(1)] MessageReader reader)
|
||||
public static bool Prefix(PlayerPhysics __instance, [HarmonyArgument(0)] byte callId, [HarmonyArgument(1)] MessageReader reader)
|
||||
{
|
||||
__instance.myPlayer.BetterData().AntiCheatInfo.RPCSentPS++;
|
||||
if (__instance.myPlayer.BetterData().AntiCheatInfo.RPCSentPS >= ExtendedAntiCheatInfo.MaxRPCSent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (BAUAntiCheat.CheckCancelRPC(__instance.myPlayer, callId, reader) != true)
|
||||
{
|
||||
Logger.LogCheat($"RPC canceled by Anti-Cheat: {Enum.GetName((RpcCalls)callId)}{Enum.GetName((CustomRPC)callId)} - {callId}");
|
||||
}
|
||||
|
||||
BAUAntiCheat.CheckRPC(__instance.myPlayer, callId, reader);
|
||||
RPC.HandleRPC(__instance.myPlayer, callId, reader);
|
||||
RPC.HandleRPC(__instance.myPlayer, callId, reader);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +89,13 @@ internal class PlayerPhysicsRPCHandlerPatch
|
||||
public static class MessageReaderUpdateSystemPatch
|
||||
{
|
||||
public static bool Prefix(/*ShipStatus __instance,*/ [HarmonyArgument(0)] SystemTypes systemType, [HarmonyArgument(1)] PlayerControl player, [HarmonyArgument(2)] MessageReader reader)
|
||||
{
|
||||
{
|
||||
player.BetterData().AntiCheatInfo.RPCSentPS++;
|
||||
if (player.BetterData().AntiCheatInfo.RPCSentPS >= ExtendedAntiCheatInfo.MaxRPCSent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (BAUAntiCheat.RpcUpdateSystemCheck(player, systemType, reader) != true)
|
||||
{
|
||||
Logger.LogCheat($"RPC canceled by Anti-Cheat: {Enum.GetName(typeof(SystemTypes), (int)systemType)} - {MessageReader.Get(reader).ReadByte()}");
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using BetterAmongUs.Helpers;
|
||||
using BetterAmongUs.Modules;
|
||||
using BetterAmongUs.Modules.AntiCheat;
|
||||
using HarmonyLib;
|
||||
using System.Text;
|
||||
using TMPro;
|
||||
@@ -13,15 +12,6 @@ class GamePlayManager
|
||||
[HarmonyPatch(typeof(LobbyBehaviour))]
|
||||
public class LobbyBehaviourPatch
|
||||
{
|
||||
[HarmonyPatch(nameof(LobbyBehaviour.OnDestroy))]
|
||||
[HarmonyPrefix]
|
||||
private static void OnDestroy_Prefix(/*LobbyBehaviour __instance*/)
|
||||
{
|
||||
if (GameState.IsInGame)
|
||||
{
|
||||
BAUAntiCheat.PauseAntiCheat();
|
||||
}
|
||||
}
|
||||
[HarmonyPatch(nameof(LobbyBehaviour.Start))]
|
||||
[HarmonyPostfix]
|
||||
private static void Start_Postfix(/*LobbyBehaviour __instance*/)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using BetterAmongUs.Helpers;
|
||||
using BetterAmongUs.Managers;
|
||||
using BetterAmongUs.Modules;
|
||||
using BetterAmongUs.Modules.AntiCheat;
|
||||
using BetterAmongUs.Patches;
|
||||
using HarmonyLib;
|
||||
using InnerNet;
|
||||
@@ -15,8 +14,6 @@ class OnGameJoinedPatch
|
||||
{
|
||||
try
|
||||
{
|
||||
BAUAntiCheat.PauseAntiCheat();
|
||||
|
||||
// Fix host icon in lobby on modded servers
|
||||
if (!GameState.IsVanillaServer)
|
||||
{
|
||||
|
||||
@@ -119,6 +119,7 @@
|
||||
"AntiCheat.Cheat.KNC": "KN Chat",
|
||||
"AntiCheat.Reason.InvalidFriendCode": "Invalid Friend Code",
|
||||
"AntiCheat.Reason.PlatformSpoofer": "Platform Spoofer",
|
||||
"AntiCheat.Reason.RPCSentPS": "RPC Spam",
|
||||
"AntiCheat.Reason.SickoMenuUser": "Known Sicko User",
|
||||
"AntiCheat.Reason.AUMUser": "Known AUM User",
|
||||
"AntiCheat.Reason.KNUser": "Known KN User",
|
||||
|
||||
Reference in new issue
Block a user