public static void Log(BasePlayer ply, AntiHackType type, string message) { if (ConVar.AntiHack.debuglevel > 1) { AntiHack.LogToConsole(ply, type, message); } AntiHack.LogToEAC(ply, type, message); }
public static void Ban(BasePlayer ply, string reason) { if (EACServer.eacScout != null) { EACServer.eacScout.SendKickReport(ply.userID.ToString(), reason, KickReasonCategory.KickReasonCheating); } AntiHack.AddRecord(ply, AntiHack.bans); ConsoleSystem.Run(ConsoleSystem.Option.Server, "ban", new object[] { ply.userID, reason }); }
private void ServerFractionalReloadInsert(RPCMessage msg) { BasePlayer player = msg.player; if (!VerifyClientRPC(player)) { SendNetworkUpdate(); reloadStarted = false; reloadFinished = false; return; } if (!fractionalReload) { AntiHack.Log(player, AntiHackType.ReloadHack, "Fractional reload not allowed (" + base.ShortPrefabName + ")"); player.stats.combat.Log(this, "reload_type"); return; } if (!reloadStarted) { AntiHack.Log(player, AntiHackType.ReloadHack, "Fractional reload request skipped (" + base.ShortPrefabName + ")"); player.stats.combat.Log(this, "reload_skip"); reloadStarted = false; reloadFinished = false; return; } if (GetReloadIdle() > 3f) { AntiHack.Log(player, AntiHackType.ReloadHack, "T+" + GetReloadIdle() + "s (" + base.ShortPrefabName + ")"); player.stats.combat.Log(this, "reload_time"); reloadStarted = false; reloadFinished = false; return; } if (UnityEngine.Time.time < startReloadTime + reloadStartDuration) { AntiHack.Log(player, AntiHackType.ReloadHack, "Fractional reload too early (" + base.ShortPrefabName + ")"); player.stats.combat.Log(this, "reload_fraction_too_early"); reloadStarted = false; reloadFinished = false; } if (UnityEngine.Time.time < startReloadTime + reloadStartDuration + (float)fractionalInsertCounter * reloadFractionDuration) { AntiHack.Log(player, AntiHackType.ReloadHack, "Fractional reload rate too high (" + base.ShortPrefabName + ")"); player.stats.combat.Log(this, "reload_fraction_rate"); reloadStarted = false; reloadFinished = false; } else { fractionalInsertCounter++; if (primaryMagazine.contents < primaryMagazine.capacity) { ReloadMagazine(1); } } }
// Use this for initialization void Start() { currentState = PlayerState.walk; animator = GetComponent <Animator>(); myRigidbody = GetComponent <Rigidbody2D>(); StartCoroutine(showStarttext()); animator.SetFloat("moveX", 0); AntiHack.RestartTimer(true); animator.SetFloat("moveY", -1); }
protected bool ValidateEyePos(BasePlayer player, Vector3 eyePos) { bool flag = true; if (Vector3Ex.IsNaNOrInfinity(eyePos)) { string shortPrefabName = this.ShortPrefabName; AntiHack.Log(player, AntiHackType.EyeHack, "Contains NaN (" + shortPrefabName + ")"); player.stats.combat.Log(this, "eye_nan"); flag = false; } if (ConVar.AntiHack.eye_protection > 0) { float num1 = 1f + ConVar.AntiHack.eye_forgiveness; double eyeClientframes = (double)ConVar.AntiHack.eye_clientframes; float eyeServerframes = ConVar.AntiHack.eye_serverframes; float num2 = (float)(eyeClientframes / 60.0); float num3 = eyeServerframes * Mathx.Max(Time.get_deltaTime(), Time.get_smoothDeltaTime(), Time.get_fixedDeltaTime()); float num4 = (player.desyncTime + num2 + num3) * num1; if (ConVar.AntiHack.eye_protection >= 1) { double num5 = (double)player.MaxVelocity(); Vector3 parentVelocity = player.GetParentVelocity(); double magnitude = (double)((Vector3) ref parentVelocity).get_magnitude(); float num6 = (float)(num5 + magnitude); float num7 = player.BoundsPadding() + num4 * num6; float num8 = Vector3.Distance(player.eyes.position, eyePos); if ((double)num8 > (double)num7) { string shortPrefabName = this.ShortPrefabName; AntiHack.Log(player, AntiHackType.EyeHack, "Distance (" + shortPrefabName + " on attack with " + (object)num8 + "m > " + (object)num7 + "m)"); player.stats.combat.Log(this, "eye_distance"); flag = false; } } if (ConVar.AntiHack.eye_protection >= 2) { Vector3 center = player.eyes.center; Vector3 position = player.eyes.position; Vector3 p2 = eyePos; if (!GamePhysics.LineOfSight(center, position, p2, 2162688, 0.0f)) { string shortPrefabName = this.ShortPrefabName; AntiHack.Log(player, AntiHackType.EyeHack, "Line of sight (" + shortPrefabName + " on attack) " + (object)center + " " + (object)position + " " + (object)p2); player.stats.combat.Log(this, "eye_los"); flag = false; } } if (!flag) { AntiHack.AddViolation(player, AntiHackType.EyeHack, ConVar.AntiHack.eye_penalty); } } return(flag); }
private void Disappear(BasePlayer player) { if (Interface.CallHook("OnVanishDisappear", player) != null) { return; } if (config.AntiFlyHack) { player.PauseFlyHackDetection(); } //Mute Player Effects player.fallDamageEffect = new GameObjectRef(); player.drownEffect = new GameObjectRef(); AntiHack.ShouldIgnore(player); if (_hiddenPlayers.Count == 0) { SubscribeToHooks(); } player._limitedNetworking = true; //player.UpdatePlayerCollider(false); var connections = Net.sv.connections.Where(con => con.connected && con.isAuthenticated && con.player is BasePlayer && con.player != player).ToList(); player.OnNetworkSubscribersLeave(connections); player.gameObject.AddComponent <GroupSwitchTimer>(); _hiddenPlayers.Add(player); if (config.EnableSound) { if (config.PublicSound) { Effect.server.Run(config.VanishSoundEffect, player.transform.position); } else { SendEffect(player, config.VanishSoundEffect); } } if (config.NoClipOnVanish && !player.IsFlying) { player.SendConsoleCommand("noclip"); } if (config.EnableGUI) { VanishGui(player); } if (config.EnableNotifications) { Message(player.IPlayer, "Vanished"); } }
protected bool ValidateEyePos(BasePlayer player, Vector3 eyePos) { bool flag = true; if (eyePos.IsNaNOrInfinity()) { string shortPrefabName = base.ShortPrefabName; AntiHack.Log(player, AntiHackType.EyeHack, string.Concat("Contains NaN (", shortPrefabName, ")")); player.stats.combat.Log(this, "eye_nan"); flag = false; } if (ConVar.AntiHack.eye_protection > 0) { float eyeForgiveness = 1f + ConVar.AntiHack.eye_forgiveness; float eyeClientframes = ConVar.AntiHack.eye_clientframes; float eyeServerframes = ConVar.AntiHack.eye_serverframes; float single = eyeClientframes / 60f; float single1 = eyeServerframes * Mathx.Max(UnityEngine.Time.deltaTime, UnityEngine.Time.smoothDeltaTime, UnityEngine.Time.fixedDeltaTime); float single2 = (player.desyncTime + single + single1) * eyeForgiveness; if (ConVar.AntiHack.eye_protection >= 1) { float single3 = player.MaxVelocity() + player.GetParentVelocity().magnitude; float single4 = player.BoundsPadding() + single2 * single3; float single5 = Vector3.Distance(player.eyes.position, eyePos); if (single5 > single4) { string str = base.ShortPrefabName; AntiHack.Log(player, AntiHackType.EyeHack, string.Concat(new object[] { "Distance (", str, " on attack with ", single5, "m > ", single4, "m)" })); player.stats.combat.Log(this, "eye_distance"); flag = false; } } if (ConVar.AntiHack.eye_protection >= 2) { Vector3 vector3 = player.eyes.center; Vector3 vector31 = player.eyes.position; Vector3 vector32 = eyePos; if (!GamePhysics.LineOfSight(vector3, vector31, vector32, 2162688, 0f)) { string shortPrefabName1 = base.ShortPrefabName; AntiHack.Log(player, AntiHackType.EyeHack, string.Concat(new object[] { "Line of sight (", shortPrefabName1, " on attack) ", vector3, " ", vector31, " ", vector32 })); player.stats.combat.Log(this, "eye_los"); flag = false; } } if (!flag) { AntiHack.AddViolation(player, AntiHackType.EyeHack, ConVar.AntiHack.eye_penalty); } } return(flag); }
protected bool ValidateEyePos(BasePlayer player, Vector3 eyePos) { bool flag = true; if (eyePos.IsNaNOrInfinity()) { string shortPrefabName = base.ShortPrefabName; AntiHack.Log(player, AntiHackType.EyeHack, "Contains NaN (" + shortPrefabName + ")"); player.stats.combat.Log(this, "eye_nan"); flag = false; } if (ConVar.AntiHack.eye_protection > 0) { float num = 1f + ConVar.AntiHack.eye_forgiveness; float eye_clientframes = ConVar.AntiHack.eye_clientframes; float eye_serverframes = ConVar.AntiHack.eye_serverframes; float num2 = eye_clientframes / 60f; float num3 = eye_serverframes * Mathx.Max(UnityEngine.Time.deltaTime, UnityEngine.Time.smoothDeltaTime, UnityEngine.Time.fixedDeltaTime); float num4 = (player.desyncTimeClamped + num2 + num3) * num; int layerMask = (ConVar.AntiHack.eye_terraincheck ? 10551296 : 2162688); if (ConVar.AntiHack.eye_protection >= 1) { float num5 = player.MaxVelocity() + player.GetParentVelocity().magnitude; float num6 = player.BoundsPadding() + num4 * num5; float num7 = Vector3.Distance(player.eyes.position, eyePos); if (num7 > num6) { string shortPrefabName2 = base.ShortPrefabName; AntiHack.Log(player, AntiHackType.EyeHack, "Distance (" + shortPrefabName2 + " on attack with " + num7 + "m > " + num6 + "m)"); player.stats.combat.Log(this, "eye_distance"); flag = false; } } if (ConVar.AntiHack.eye_protection >= 2) { Vector3 center = player.eyes.center; Vector3 position = player.eyes.position; if (!GamePhysics.LineOfSight(center, position, eyePos, layerMask)) { string shortPrefabName3 = base.ShortPrefabName; AntiHack.Log(player, AntiHackType.EyeHack, string.Concat("Line of sight (", shortPrefabName3, " on attack) ", center, " ", position, " ", eyePos)); player.stats.combat.Log(this, "eye_los"); flag = false; } } if (!flag) { AntiHack.AddViolation(player, AntiHackType.EyeHack, ConVar.AntiHack.eye_penalty); } } return(flag); }
public static void Kick(BasePlayer ply, string reason) { if (EACServer.eacScout != null) { EACServer.eacScout.SendKickReport(ply.userID.ToString(), reason, (KickReasonCategory)4); } AntiHack.AddRecord(ply, AntiHack.kicks); ConsoleSystem.Run(ConsoleSystem.Option.get_Server(), "kick", new object[2] { (object)ply.userID, (object)reason }); }
protected virtual bool VerifyClientAttack(BasePlayer player) { if (!this.VerifyClientRPC(player)) { return(false); } if (!this.HasAttackCooldown()) { return(true); } AntiHack.Log(player, AntiHackType.CooldownHack, string.Concat(new object[] { "T-", this.GetAttackCooldown(), "s (", base.ShortPrefabName, ")" })); player.stats.combat.Log(this, "attack_cooldown"); return(false); }
protected virtual bool VerifyClientAttack(BasePlayer player) { if (!this.VerifyClientRPC(player)) { return(false); } if (!this.HasAttackCooldown()) { return(true); } AntiHack.Log(player, AntiHackType.CooldownHack, "T-" + (object)this.GetAttackCooldown() + "s (" + this.ShortPrefabName + ")"); player.stats.combat.Log(this, "attack_cooldown"); return(false); }
public static bool IsFlying(BasePlayer ply, TickInterpolator ticks, float deltaTime) { ply.flyhackPauseTime = Mathf.Max(0f, ply.flyhackPauseTime - deltaTime); if (ply.flyhackPauseTime > 0f) { return(false); } if (ConVar.AntiHack.flyhack_protection <= 0) { return(false); } ticks.Reset(); if (!ticks.HasNext()) { return(false); } bool flag = ply.transform.parent == null; Matrix4x4 matrix4x4 = (flag ? Matrix4x4.identity : ply.transform.parent.localToWorldMatrix); Vector3 vector3 = (flag ? ticks.StartPoint : matrix4x4.MultiplyPoint3x4(ticks.StartPoint)); Vector3 vector31 = (flag ? ticks.EndPoint : matrix4x4.MultiplyPoint3x4(ticks.EndPoint)); if (ConVar.AntiHack.flyhack_protection >= 3) { float single = Mathf.Max(ConVar.AntiHack.flyhack_stepsize, 0.1f); int num = Mathf.Max(ConVar.AntiHack.flyhack_maxsteps, 1); single = Mathf.Max(ticks.Length / (float)num, single); while (ticks.MoveNext(single)) { vector31 = (flag ? ticks.CurrentPoint : matrix4x4.MultiplyPoint3x4(ticks.CurrentPoint)); if (AntiHack.TestFlying(ply, vector3, vector31, true)) { return(true); } vector3 = vector31; } } else if (ConVar.AntiHack.flyhack_protection >= 2) { if (AntiHack.TestFlying(ply, vector3, vector31, true)) { return(true); } } else if (AntiHack.TestFlying(ply, vector3, vector31, false)) { return(true); } return(false); }
private void Reload(RPCMessage msg) { BasePlayer player = msg.player; if (!VerifyClientRPC(player)) { SendNetworkUpdate(); reloadStarted = false; reloadFinished = false; return; } if (!reloadStarted) { AntiHack.Log(player, AntiHackType.ReloadHack, "Request skipped (" + base.ShortPrefabName + ")"); player.stats.combat.Log(this, "reload_skip"); reloadStarted = false; reloadFinished = false; return; } if (!fractionalReload) { if (GetReloadCooldown() > 1f) { AntiHack.Log(player, AntiHackType.ReloadHack, "T-" + GetReloadCooldown() + "s (" + base.ShortPrefabName + ")"); player.stats.combat.Log(this, "reload_time"); reloadStarted = false; reloadFinished = false; return; } if (GetReloadIdle() > 1.5f) { AntiHack.Log(player, AntiHackType.ReloadHack, "T+" + GetReloadIdle() + "s (" + base.ShortPrefabName + ")"); player.stats.combat.Log(this, "reload_time"); reloadStarted = false; reloadFinished = false; return; } } if (fractionalReload) { ResetReloadCooldown(); } reloadStarted = false; reloadFinished = true; if (!fractionalReload) { ReloadMagazine(); } }
public static void AddViolation(BasePlayer ply, AntiHackType type, float amount) { if (Interface.CallHook("OnPlayerViolation", ply, type, amount) != null) { return; } ply.lastViolationType = type; ply.lastViolationTime = UnityEngine.Time.realtimeSinceStartup; ply.violationLevel += amount; if (ConVar.AntiHack.debuglevel >= 2 && amount > 0f || ConVar.AntiHack.debuglevel >= 3) { AntiHack.LogToConsole(ply, type, string.Concat(new object[] { "Added violation of ", amount, " in frame ", UnityEngine.Time.frameCount, " (now has ", ply.violationLevel, ")" })); } AntiHack.EnforceViolations(ply); }
public static void AddViolation(BasePlayer ply, AntiHackType type, float amount) { if (Interface.CallHook("OnPlayerViolation", (object)ply, (object)type, (object)amount) != null) { return; } ply.lastViolationType = type; ply.lastViolationTime = Time.get_realtimeSinceStartup(); ply.violationLevel += amount; if (ConVar.AntiHack.debuglevel >= 2 && (double)amount > 0.0 || ConVar.AntiHack.debuglevel >= 3) { AntiHack.LogToConsole(ply, type, "Added violation of " + (object)amount + " in frame " + (object)Time.get_frameCount() + " (now has " + (object)ply.violationLevel + ")"); } AntiHack.EnforceViolations(ply); }
void PlayerControllerSpawn() { if (player == null) { Vector3 spawnloc = new Vector3(searchlight.transform.position.x, searchlight.transform.position.y - 1.8f, searchlight.transform.position.z); player = GameManager.server.CreateEntity("assets/prefabs/player/player.prefab", spawnloc, new Quaternion()).ToPlayer(); player.Spawn(); player.displayName = "SearchLight Driver"; AntiHack.ShouldIgnore(player); player._limitedNetworking = true; player.EnablePlayerCollider(); var connections = Net.sv.connections.Where(con => con.connected && con.isAuthenticated && con.player is BasePlayer && con.player != player).ToList(); player.OnNetworkSubscribersLeave(connections); } searchlight.PlayerEnter(player); }
private void BypassCommand(IPlayer IPlayer, string command, string[] args) { BasePlayer player = (BasePlayer)IPlayer; if (!bypassing.Contains(IPlayer)) { AntiHack.ShouldIgnore(player); bypassing.Add(IPlayer); IPlayer.Message("You are now bypassing anticheat!"); } else { bypassing.Remove(IPlayer); //Add reset anti hack here. TODO IPlayer.Message("You are no longer bypassing anticheat!"); } }
public static bool IsFlying(BasePlayer ply, TickInterpolator ticks, float deltaTime) { ply.flyhackPauseTime = Mathf.Max(0.0f, ply.flyhackPauseTime - deltaTime); if ((double)ply.flyhackPauseTime > 0.0 || ConVar.AntiHack.flyhack_protection <= 0) { return(false); } ticks.Reset(); if (!ticks.HasNext()) { return(false); } bool flag = Object.op_Equality((Object)((Component)ply).get_transform().get_parent(), (Object)null); Matrix4x4 matrix4x4 = flag ? Matrix4x4.get_identity() : ((Component)ply).get_transform().get_parent().get_localToWorldMatrix(); Vector3 oldPos = flag ? ticks.StartPoint : ((Matrix4x4) ref matrix4x4).MultiplyPoint3x4(ticks.StartPoint); Vector3 newPos1 = flag ? ticks.EndPoint : ((Matrix4x4) ref matrix4x4).MultiplyPoint3x4(ticks.EndPoint); if (ConVar.AntiHack.flyhack_protection >= 3) { float num1 = Mathf.Max(ConVar.AntiHack.flyhack_stepsize, 0.1f); int num2 = Mathf.Max(ConVar.AntiHack.flyhack_maxsteps, 1); float distance = Mathf.Max(ticks.Length / (float)num2, num1); while (ticks.MoveNext(distance)) { Vector3 newPos2 = flag ? ticks.CurrentPoint : ((Matrix4x4) ref matrix4x4).MultiplyPoint3x4(ticks.CurrentPoint); if (AntiHack.TestFlying(ply, oldPos, newPos2, true)) { return(true); } oldPos = newPos2; } } else if (ConVar.AntiHack.flyhack_protection >= 2) { if (AntiHack.TestFlying(ply, oldPos, newPos1, true)) { return(true); } } else if (AntiHack.TestFlying(ply, oldPos, newPos1, false)) { return(true); } return(false); }
public static void EnforceViolations(BasePlayer ply) { if (ConVar.AntiHack.enforcementlevel <= 0 || (double)ply.violationLevel <= (double)ConVar.AntiHack.maxviolation) { return; } if (ConVar.AntiHack.debuglevel >= 1) { AntiHack.LogToConsole(ply, ply.lastViolationType, "Enforcing (violation of " + (object)ply.violationLevel + ")"); } string reason = ((int)ply.lastViolationType).ToString() + " Violation Level " + (object)ply.violationLevel; if (ConVar.AntiHack.enforcementlevel > 1) { AntiHack.Kick(ply, reason); } else { AntiHack.Kick(ply, reason); } }
public static void EnforceViolations(BasePlayer ply) { if (ConVar.AntiHack.enforcementlevel <= 0) { return; } if (ply.violationLevel > ConVar.AntiHack.maxviolation) { if (ConVar.AntiHack.debuglevel >= 1) { AntiHack.LogToConsole(ply, ply.lastViolationType, string.Concat("Enforcing (violation of ", ply.violationLevel, ")")); } string str = string.Concat(ply.lastViolationType, " Violation Level ", ply.violationLevel); if (ConVar.AntiHack.enforcementlevel > 1) { AntiHack.Kick(ply, str); return; } AntiHack.Kick(ply, str); } }
private void Disappear(BasePlayer player) { if (Interface.CallHook("OnVanishDisappear", player) != null) { return; } if (config.AntiFlyHack) { player.PauseFlyHackDetection(); } //Mute Player Effects player.fallDamageEffect = new GameObjectRef(); player.drownEffect = new GameObjectRef(); AntiHack.ShouldIgnore(player); if (_hiddenPlayers.Count == 0) { SubscribeToHooks(); } //player._limitedNetworking = true; player.UpdatePlayerCollider(false); var connections = Net.sv.connections.Where(con => con.connected && con.isAuthenticated && con.player is BasePlayer && con.player != player).ToList(); player.OnNetworkSubscribersLeave(connections); //HeldEntity heldEntity = player.GetHeldEntity(); //if (heldEntity != null) //{ // heldEntity.SetHeld(false); // heldEntity.UpdateVisiblity_Invis(); // heldEntity.SendNetworkUpdate(); //} //if (Net.sv.write.Start()) //{ // Net.sv.write.PacketID(Network.Message.Type.EntityDestroy); // Net.sv.write.EntityID(player.net.ID); // Net.sv.write.UInt8((byte)BaseNetworkable.DestroyMode.None); // Net.sv.write.Send(new SendInfo(connections)); //} _hiddenPlayers.Add(player); if (config.EnableSound) { if (config.PublicSound) { Effect.server.Run(config.VanishSoundEffect, player.transform.position); } else { SendEffect(player, config.VanishSoundEffect); } } if (config.EnableGUI) { VanishGui(player); } if (config.EnableNotifications) { Message(player.IPlayer, "Vanished"); } }
private void CLProject(BaseEntity.RPCMessage msg) { BasePlayer basePlayer = msg.player; if (!this.VerifyClientAttack(basePlayer)) { base.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); return; } if (this.reloadFinished && this.HasReloadCooldown()) { AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Reloading (", base.ShortPrefabName, ")")); basePlayer.stats.combat.Log(this, "reload_cooldown"); return; } this.reloadStarted = false; this.reloadFinished = false; if (this.primaryMagazine.contents <= 0 && !this.UsingInfiniteAmmoCheat) { AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Magazine empty (", base.ShortPrefabName, ")")); basePlayer.stats.combat.Log(this, "ammo_missing"); return; } ItemDefinition itemDefinition = this.primaryMagazine.ammoType; ProjectileShoot projectileShoot = ProjectileShoot.Deserialize(msg.read); if (itemDefinition.itemid != projectileShoot.ammoType) { AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Ammo mismatch (", base.ShortPrefabName, ")")); basePlayer.stats.combat.Log(this, "ammo_mismatch"); return; } if (!this.UsingInfiniteAmmoCheat) { this.primaryMagazine.contents--; } ItemModProjectile component = itemDefinition.GetComponent <ItemModProjectile>(); if (component == null) { AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Item mod not found (", base.ShortPrefabName, ")")); basePlayer.stats.combat.Log(this, "mod_missing"); return; } if (projectileShoot.projectiles.Count > component.numProjectiles) { AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Count mismatch (", base.ShortPrefabName, ")")); basePlayer.stats.combat.Log(this, "count_mismatch"); return; } Interface.CallHook("OnWeaponFired", this, msg.player, component, projectileShoot); base.SignalBroadcast(BaseEntity.Signal.Attack, string.Empty, msg.connection); basePlayer.CleanupExpiredProjectiles(); foreach (ProjectileShoot.Projectile projectile in projectileShoot.projectiles) { if (!basePlayer.HasFiredProjectile(projectile.projectileID)) { if (!base.ValidateEyePos(basePlayer, projectile.startPos)) { continue; } basePlayer.NoteFiredProjectile(projectile.projectileID, projectile.startPos, projectile.startVel, this, itemDefinition, null); this.CreateProjectileEffectClientside(component.projectileObject.resourcePath, projectile.startPos, projectile.startVel, projectile.seed, msg.connection, this.IsSilenced(), false); } else { AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Duplicate ID (", projectile.projectileID, ")")); basePlayer.stats.combat.Log(this, "duplicate_id"); } } basePlayer.stats.Add(string.Concat(component.category, "_fired"), projectileShoot.projectiles.Count <ProjectileShoot.Projectile>(), Stats.Steam); base.StartAttackCooldown(this.ScaleRepeatDelay(this.repeatDelay) + this.animationDelay); basePlayer.MarkHostileFor(60f); this.UpdateItemCondition(); this.DidAttackServerside(); float single = 0f; if (component.projectileObject != null) { GameObject gameObject = component.projectileObject.Get(); if (gameObject != null) { Projectile component1 = gameObject.GetComponent <Projectile>(); if (component1 != null) { foreach (DamageTypeEntry damageType in component1.damageTypes) { single += damageType.amount; } } } } float noiseRadius = this.NoiseRadius; if (this.IsSilenced()) { noiseRadius *= AI.npc_gun_noise_silencer_modifier; } Sensation sensation = new Sensation() { Type = SensationType.Gunshot, Position = basePlayer.transform.position, Radius = noiseRadius, DamagePotential = single, InitiatorPlayer = basePlayer, Initiator = basePlayer }; Sense.Stimulate(sensation); if (EACServer.playerTracker != null) { using (TimeWarning timeWarning = TimeWarning.New("LogPlayerShooting", 0.1f)) { UnityEngine.Vector3 networkPosition = basePlayer.GetNetworkPosition(); UnityEngine.Quaternion networkRotation = basePlayer.GetNetworkRotation(); Item item = this.GetItem(); int num = (item != null ? item.info.itemid : 0); EasyAntiCheat.Server.Hydra.Client client = EACServer.GetClient(basePlayer.net.connection); PlayerUseWeapon playerUseWeapon = new PlayerUseWeapon() { Position = new EasyAntiCheat.Server.Cerberus.Vector3(networkPosition.x, networkPosition.y, networkPosition.z), ViewRotation = new EasyAntiCheat.Server.Cerberus.Quaternion(networkRotation.x, networkRotation.y, networkRotation.z, networkRotation.w), WeaponID = num }; EACServer.playerTracker.LogPlayerUseWeapon(client, playerUseWeapon); } } }
private void SV_Launch(BaseEntity.RPCMessage msg) { BasePlayer player = msg.player; if (!this.VerifyClientAttack(player)) { this.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); } else if (this.reloadFinished && this.HasReloadCooldown()) { AntiHack.Log(player, AntiHackType.ProjectileHack, "Reloading (" + this.ShortPrefabName + ")"); player.stats.combat.Log((AttackEntity)this, "reload_cooldown"); } else { this.reloadStarted = false; this.reloadFinished = false; if (this.primaryMagazine.contents <= 0) { AntiHack.Log(player, AntiHackType.ProjectileHack, "Magazine empty (" + this.ShortPrefabName + ")"); player.stats.combat.Log((AttackEntity)this, "magazine_empty"); } else { --this.primaryMagazine.contents; this.SignalBroadcast(BaseEntity.Signal.Attack, string.Empty, player.net.get_connection()); Vector3 eyePos = msg.read.Vector3(); Vector3 vector3 = msg.read.Vector3(); Vector3 inputVec = ((Vector3) ref vector3).get_normalized(); int num1 = msg.read.Bit() ? 1 : 0; BaseEntity baseEntity = player.GetParentEntity(); if (Object.op_Equality((Object)baseEntity, (Object)null)) { baseEntity = (BaseEntity)player.GetMounted(); } if (num1 != 0) { if (Object.op_Inequality((Object)baseEntity, (Object)null)) { eyePos = ((Component)baseEntity).get_transform().TransformPoint(eyePos); inputVec = ((Component)baseEntity).get_transform().TransformDirection(inputVec); } else { eyePos = player.eyes.position; inputVec = player.eyes.BodyForward(); } } if (!this.ValidateEyePos(player, eyePos)) { return; } ItemModProjectile component1 = (ItemModProjectile)((Component)this.primaryMagazine.ammoType).GetComponent <ItemModProjectile>(); if (!Object.op_Implicit((Object)component1)) { AntiHack.Log(player, AntiHackType.ProjectileHack, "Item mod not found (" + this.ShortPrefabName + ")"); player.stats.combat.Log((AttackEntity)this, "mod_missing"); } else { float aimCone = this.GetAimCone() + component1.projectileSpread; if ((double)aimCone > 0.0) { inputVec = AimConeUtil.GetModifiedAimConeDirection(aimCone, inputVec, true); } float num2 = 1f; RaycastHit raycastHit; if (Physics.Raycast(eyePos, inputVec, ref raycastHit, num2, 1236478737)) { num2 = ((RaycastHit) ref raycastHit).get_distance() - 0.1f; } BaseEntity entity = GameManager.server.CreateEntity(component1.projectileObject.resourcePath, Vector3.op_Addition(eyePos, Vector3.op_Multiply(inputVec, num2)), (Quaternion)null, true); if (Object.op_Equality((Object)entity, (Object)null)) { return; } entity.creatorEntity = (BaseEntity)player; ServerProjectile component2 = (ServerProjectile)((Component)entity).GetComponent <ServerProjectile>(); if (Object.op_Implicit((Object)component2)) { component2.InitializeVelocity(Vector3.op_Addition(player.GetInheritedProjectileVelocity(), Vector3.op_Multiply(inputVec, component2.speed))); } entity.Spawn(); this.StartAttackCooldown(this.ScaleRepeatDelay(this.repeatDelay)); Interface.CallHook("OnRocketLaunched", (object)player, (object)entity); this.GetOwnerItem()?.LoseCondition(Random.Range(1f, 2f)); } } } }
private void SV_Launch(BaseEntity.RPCMessage msg) { RaycastHit raycastHit; BasePlayer basePlayer = msg.player; if (!this.VerifyClientAttack(basePlayer)) { base.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); return; } if (this.reloadFinished && base.HasReloadCooldown()) { AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Reloading (", base.ShortPrefabName, ")")); basePlayer.stats.combat.Log(this, "reload_cooldown"); return; } this.reloadStarted = false; this.reloadFinished = false; if (this.primaryMagazine.contents <= 0) { AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Magazine empty (", base.ShortPrefabName, ")")); basePlayer.stats.combat.Log(this, "magazine_empty"); return; } this.primaryMagazine.contents--; base.SignalBroadcast(BaseEntity.Signal.Attack, string.Empty, basePlayer.net.connection); Vector3 vector3 = msg.read.Vector3(); Vector3 modifiedAimConeDirection = msg.read.Vector3().normalized; bool flag = msg.read.Bit(); BaseEntity parentEntity = basePlayer.GetParentEntity(); if (parentEntity == null) { parentEntity = basePlayer.GetMounted(); } if (flag) { if (parentEntity == null) { vector3 = basePlayer.eyes.position; modifiedAimConeDirection = basePlayer.eyes.BodyForward(); } else { vector3 = parentEntity.transform.TransformPoint(vector3); modifiedAimConeDirection = parentEntity.transform.TransformDirection(modifiedAimConeDirection); } } if (!base.ValidateEyePos(basePlayer, vector3)) { return; } ItemModProjectile component = this.primaryMagazine.ammoType.GetComponent <ItemModProjectile>(); if (!component) { AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Item mod not found (", base.ShortPrefabName, ")")); basePlayer.stats.combat.Log(this, "mod_missing"); return; } float aimCone = this.GetAimCone() + component.projectileSpread; if (aimCone > 0f) { modifiedAimConeDirection = AimConeUtil.GetModifiedAimConeDirection(aimCone, modifiedAimConeDirection, true); } float single = 1f; if (UnityEngine.Physics.Raycast(vector3, modifiedAimConeDirection, out raycastHit, single, 1236478737)) { single = raycastHit.distance - 0.1f; } GameManager gameManager = GameManager.server; string str = component.projectileObject.resourcePath; Vector3 vector31 = vector3 + (modifiedAimConeDirection * single); Quaternion quaternion = new Quaternion(); BaseEntity baseEntity = gameManager.CreateEntity(str, vector31, quaternion, true); if (baseEntity == null) { return; } baseEntity.creatorEntity = basePlayer; ServerProjectile serverProjectile = baseEntity.GetComponent <ServerProjectile>(); if (serverProjectile) { serverProjectile.InitializeVelocity(basePlayer.GetInheritedProjectileVelocity() + (modifiedAimConeDirection * serverProjectile.speed)); } baseEntity.Spawn(); base.StartAttackCooldown(base.ScaleRepeatDelay(this.repeatDelay)); Interface.CallHook("OnRocketLaunched", basePlayer, baseEntity); Item ownerItem = base.GetOwnerItem(); if (ownerItem == null) { return; } ownerItem.LoseCondition(UnityEngine.Random.Range(1f, 2f)); }
protected bool VerifyClientRPC(BasePlayer player) { if (Object.op_Equality((Object)player, (Object)null)) { Debug.LogWarning((object)"Received RPC from null player"); return(false); } BasePlayer ownerPlayer = this.GetOwnerPlayer(); if (Object.op_Equality((Object)ownerPlayer, (Object)null)) { AntiHack.Log(player, AntiHackType.AttackHack, "Owner not found (" + this.ShortPrefabName + ")"); player.stats.combat.Log(this, "owner_missing"); return(false); } if (Object.op_Inequality((Object)ownerPlayer, (Object)player)) { AntiHack.Log(player, AntiHackType.AttackHack, "Player mismatch (" + this.ShortPrefabName + ")"); player.stats.combat.Log(this, "player_mismatch"); return(false); } if (player.IsDead()) { AntiHack.Log(player, AntiHackType.AttackHack, "Player dead (" + this.ShortPrefabName + ")"); player.stats.combat.Log(this, "player_dead"); return(false); } if (player.IsWounded()) { AntiHack.Log(player, AntiHackType.AttackHack, "Player down (" + this.ShortPrefabName + ")"); player.stats.combat.Log(this, "player_down"); return(false); } if (player.IsSleeping()) { AntiHack.Log(player, AntiHackType.AttackHack, "Player sleeping (" + this.ShortPrefabName + ")"); player.stats.combat.Log(this, "player_sleeping"); return(false); } if ((double)player.desyncTime > (double)ConVar.AntiHack.maxdesync) { AntiHack.Log(player, AntiHackType.AttackHack, "Player stalled (" + this.ShortPrefabName + " with " + (object)player.desyncTime + "s)"); player.stats.combat.Log(this, "player_stalled"); return(false); } Item ownerItem = this.GetOwnerItem(); if (ownerItem == null) { AntiHack.Log(player, AntiHackType.AttackHack, "Item not found (" + this.ShortPrefabName + ")"); player.stats.combat.Log(this, "item_missing"); return(false); } if (!ownerItem.isBroken) { return(true); } AntiHack.Log(player, AntiHackType.AttackHack, "Item broken (" + this.ShortPrefabName + ")"); player.stats.combat.Log(this, "item_broken"); return(false); }
private void CLProject(BaseEntity.RPCMessage msg) { BasePlayer basePlayer = msg.player; if (!this.VerifyClientAttack(basePlayer)) { base.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); return; } if (basePlayer == null) { return; } if (basePlayer.IsHeadUnderwater()) { return; } if (!this.canThrowAsProjectile) { AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Not throwable (", base.ShortPrefabName, ")")); basePlayer.stats.combat.Log(this, "not_throwable"); return; } Item item = this.GetItem(); if (item == null) { AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Item not found (", base.ShortPrefabName, ")")); basePlayer.stats.combat.Log(this, "item_missing"); return; } ItemModProjectile component = item.info.GetComponent <ItemModProjectile>(); if (component == null) { AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Item mod not found (", base.ShortPrefabName, ")")); basePlayer.stats.combat.Log(this, "mod_missing"); return; } ProjectileShoot projectileShoot = ProjectileShoot.Deserialize(msg.read); if (projectileShoot.projectiles.Count != 1) { AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Projectile count mismatch (", base.ShortPrefabName, ")")); basePlayer.stats.combat.Log(this, "count_mismatch"); return; } basePlayer.CleanupExpiredProjectiles(); foreach (ProjectileShoot.Projectile projectile in projectileShoot.projectiles) { if (!basePlayer.HasFiredProjectile(projectile.projectileID)) { if (!base.ValidateEyePos(basePlayer, projectile.startPos)) { continue; } basePlayer.NoteFiredProjectile(projectile.projectileID, projectile.startPos, projectile.startVel, this, item.info, item); Effect effect = new Effect(); effect.Init(Effect.Type.Projectile, projectile.startPos, projectile.startVel, msg.connection); effect.scale = 1f; effect.pooledString = component.projectileObject.resourcePath; effect.number = projectile.seed; EffectNetwork.Send(effect); } else { AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Duplicate ID (", projectile.projectileID, ")")); basePlayer.stats.combat.Log(this, "duplicate_id"); } } item.SetParent(null); Interface.CallHook("OnMeleeThrown", basePlayer, item); if (this.canAiHearIt) { float single = 0f; if (component.projectileObject != null) { GameObject gameObject = component.projectileObject.Get(); if (gameObject != null) { Projectile component1 = gameObject.GetComponent <Projectile>(); if (component1 != null) { foreach (DamageTypeEntry damageType in component1.damageTypes) { single += damageType.amount; } } } } if (basePlayer != null) { Sensation sensation = new Sensation() { Type = SensationType.ThrownWeapon, Position = basePlayer.transform.position, Radius = 50f, DamagePotential = single, InitiatorPlayer = basePlayer, Initiator = basePlayer }; Sense.Stimulate(sensation); } } }
public void PlayerAttack(BaseEntity.RPCMessage msg) { Vector3 parentVelocity; BasePlayer basePlayer = msg.player; if (!this.VerifyClientAttack(basePlayer)) { base.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); return; } using (TimeWarning timeWarning = TimeWarning.New("PlayerAttack", (long)50)) { using (PlayerAttack playerAttack = PlayerAttack.Deserialize(msg.read)) { if (playerAttack != null) { HitInfo hitInfo = Facepunch.Pool.Get <HitInfo>(); hitInfo.LoadFromAttack(playerAttack.attack, true); hitInfo.Initiator = basePlayer; hitInfo.Weapon = this; hitInfo.WeaponPrefab = this; hitInfo.Predicted = msg.connection; hitInfo.damageProperties = this.damageProperties; if (Interface.CallHook("OnMeleeAttack", basePlayer, hitInfo) != null) { return; } if (!hitInfo.IsNaNOrInfinity()) { if (ConVar.AntiHack.melee_protection > 0 && hitInfo.HitEntity) { bool flag = true; float meleeForgiveness = 1f + ConVar.AntiHack.melee_forgiveness; float meleeClientframes = ConVar.AntiHack.melee_clientframes; float meleeServerframes = ConVar.AntiHack.melee_serverframes; float single = meleeClientframes / 60f; float single1 = meleeServerframes * Mathx.Max(UnityEngine.Time.deltaTime, UnityEngine.Time.smoothDeltaTime, UnityEngine.Time.fixedDeltaTime); float single2 = (basePlayer.desyncTime + single + single1) * meleeForgiveness; if (ConVar.AntiHack.projectile_protection >= 2) { float single3 = hitInfo.HitEntity.MaxVelocity(); parentVelocity = hitInfo.HitEntity.GetParentVelocity(); float single4 = single3 + parentVelocity.magnitude; float single5 = hitInfo.HitEntity.BoundsPadding() + single2 * single4; float single6 = hitInfo.HitEntity.Distance(hitInfo.HitPositionWorld); if (single6 > single5) { string shortPrefabName = base.ShortPrefabName; string str = hitInfo.HitEntity.ShortPrefabName; AntiHack.Log(basePlayer, AntiHackType.MeleeHack, string.Concat(new object[] { "Entity too far away (", shortPrefabName, " on ", str, " with ", single6, "m > ", single5, "m in ", single2, "s)" })); basePlayer.stats.combat.Log(hitInfo, "melee_distance"); flag = false; } } if (ConVar.AntiHack.melee_protection >= 1) { float single7 = hitInfo.Initiator.MaxVelocity(); parentVelocity = hitInfo.Initiator.GetParentVelocity(); float single8 = single7 + parentVelocity.magnitude; float single9 = hitInfo.Initiator.BoundsPadding() + single2 * single8 + meleeForgiveness * this.maxDistance; float single10 = hitInfo.Initiator.Distance(hitInfo.HitPositionWorld); if (single10 > single9) { string shortPrefabName1 = base.ShortPrefabName; string str1 = hitInfo.HitEntity.ShortPrefabName; AntiHack.Log(basePlayer, AntiHackType.MeleeHack, string.Concat(new object[] { "Initiator too far away (", shortPrefabName1, " on ", str1, " with ", single10, "m > ", single9, "m in ", single2, "s)" })); basePlayer.stats.combat.Log(hitInfo, "melee_distance"); flag = false; } } if (ConVar.AntiHack.melee_protection >= 3) { Vector3 pointStart = hitInfo.PointStart; Vector3 hitPositionWorld = hitInfo.HitPositionWorld + (hitInfo.HitNormalWorld.normalized * 0.001f); Vector3 vector3 = basePlayer.eyes.center; Vector3 vector31 = basePlayer.eyes.position; Vector3 vector32 = pointStart; Vector3 vector33 = hitInfo.PositionOnRay(hitPositionWorld); Vector3 vector34 = hitPositionWorld; bool flag1 = GamePhysics.LineOfSight(vector3, vector31, vector32, vector33, vector34, 2162688, 0f); if (flag1) { basePlayer.stats.Add(string.Concat("hit_", hitInfo.HitEntity.Categorize(), "_direct_los"), 1, Stats.Server); } else { basePlayer.stats.Add(string.Concat("hit_", hitInfo.HitEntity.Categorize(), "_indirect_los"), 1, Stats.Server); } if (!flag1) { string shortPrefabName2 = base.ShortPrefabName; string str2 = hitInfo.HitEntity.ShortPrefabName; AntiHack.Log(basePlayer, AntiHackType.MeleeHack, string.Concat(new object[] { "Line of sight (", shortPrefabName2, " on ", str2, ") ", vector3, " ", vector31, " ", vector32, " ", vector33, " ", vector34 })); basePlayer.stats.combat.Log(hitInfo, "melee_los"); flag = false; } } if (!flag) { AntiHack.AddViolation(basePlayer, AntiHackType.MeleeHack, ConVar.AntiHack.melee_penalty); return; } } basePlayer.metabolism.UseHeart(this.heartStress * 0.2f); using (TimeWarning timeWarning1 = TimeWarning.New("DoAttackShared", (long)50)) { this.DoAttackShared(hitInfo); } } else { string shortPrefabName3 = base.ShortPrefabName; AntiHack.Log(basePlayer, AntiHackType.MeleeHack, string.Concat("Contains NaN (", shortPrefabName3, ")")); basePlayer.stats.combat.Log(hitInfo, "melee_nan"); } } } } }
public static bool ValidateMove(BasePlayer ply, TickInterpolator ticks, float deltaTime) { bool flag; using (TimeWarning timeWarning = TimeWarning.New("AntiHack.ValidateMove", 0.1f)) { if (ply.IsFlying) { ply.lastAdminCheatTime = UnityEngine.Time.realtimeSinceStartup; } if (ply.IsAdmin) { if (ConVar.AntiHack.userlevel < 1) { flag = true; return(flag); } else if (ConVar.AntiHack.admincheat && ply.UsedAdminCheat(1f)) { flag = true; return(flag); } } if (ply.IsDeveloper) { if (ConVar.AntiHack.userlevel < 2) { flag = true; return(flag); } else if (ConVar.AntiHack.admincheat && ply.UsedAdminCheat(1f)) { flag = true; return(flag); } } if (ply.IsSleeping()) { flag = true; } else if (ply.IsWounded()) { flag = true; } else if (ply.IsSpectating()) { flag = true; } else if (!ply.IsDead()) { bool flag1 = deltaTime > ConVar.AntiHack.maxdeltatime; using (TimeWarning timeWarning1 = TimeWarning.New("IsNoClipping", 0.1f)) { if (AntiHack.IsNoClipping(ply, ticks, deltaTime)) { if (!flag1) { AntiHack.AddViolation(ply, AntiHackType.NoClip, ConVar.AntiHack.noclip_penalty * ticks.Length); if (ConVar.AntiHack.noclip_reject) { flag = false; return(flag); } } else { flag = false; return(flag); } } } using (timeWarning1 = TimeWarning.New("IsSpeeding", 0.1f)) { if (AntiHack.IsSpeeding(ply, ticks, deltaTime)) { if (!flag1) { AntiHack.AddViolation(ply, AntiHackType.SpeedHack, ConVar.AntiHack.speedhack_penalty * ticks.Length); if (ConVar.AntiHack.speedhack_reject) { flag = false; return(flag); } } else { flag = false; return(flag); } } } using (timeWarning1 = TimeWarning.New("IsFlying", 0.1f)) { if (AntiHack.IsFlying(ply, ticks, deltaTime)) { if (!flag1) { AntiHack.AddViolation(ply, AntiHackType.FlyHack, ConVar.AntiHack.flyhack_penalty * ticks.Length); if (ConVar.AntiHack.flyhack_reject) { flag = false; return(flag); } } else { flag = false; return(flag); } } } flag = true; } else { flag = true; } } return(flag); }
protected bool VerifyClientRPC(BasePlayer player) { if (player == null) { Debug.LogWarning("Received RPC from null player"); return(false); } BasePlayer ownerPlayer = GetOwnerPlayer(); if (ownerPlayer == null) { AntiHack.Log(player, AntiHackType.AttackHack, "Owner not found (" + base.ShortPrefabName + ")"); player.stats.combat.Log(this, "owner_missing"); return(false); } if (ownerPlayer != player) { AntiHack.Log(player, AntiHackType.AttackHack, "Player mismatch (" + base.ShortPrefabName + ")"); player.stats.combat.Log(this, "player_mismatch"); return(false); } if (player.IsDead()) { AntiHack.Log(player, AntiHackType.AttackHack, "Player dead (" + base.ShortPrefabName + ")"); player.stats.combat.Log(this, "player_dead"); return(false); } if (player.IsWounded()) { AntiHack.Log(player, AntiHackType.AttackHack, "Player down (" + base.ShortPrefabName + ")"); player.stats.combat.Log(this, "player_down"); return(false); } if (player.IsSleeping()) { AntiHack.Log(player, AntiHackType.AttackHack, "Player sleeping (" + base.ShortPrefabName + ")"); player.stats.combat.Log(this, "player_sleeping"); return(false); } if (player.desyncTimeRaw > ConVar.AntiHack.maxdesync) { AntiHack.Log(player, AntiHackType.AttackHack, "Player stalled (" + base.ShortPrefabName + " with " + player.desyncTimeRaw + "s)"); player.stats.combat.Log(this, "player_stalled"); return(false); } Item ownerItem = GetOwnerItem(); if (ownerItem == null) { AntiHack.Log(player, AntiHackType.AttackHack, "Item not found (" + base.ShortPrefabName + ")"); player.stats.combat.Log(this, "item_missing"); return(false); } if (ownerItem.isBroken) { AntiHack.Log(player, AntiHackType.AttackHack, "Item broken (" + base.ShortPrefabName + ")"); player.stats.combat.Log(this, "item_broken"); return(false); } return(true); }
public static int GetBanRecord(BasePlayer ply) { return(AntiHack.GetRecord(ply, AntiHack.bans)); }