Skip to content

Commit

Permalink
Fixed aimbot detection (need to fix webhooks & add more checkers)
Browse files Browse the repository at this point in the history
Not finished
  • Loading branch information
TH3AL3X committed Jul 16, 2024
1 parent dc373ad commit 6b5f8fe
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 44 deletions.
6 changes: 3 additions & 3 deletions DAC/commands/command_report.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public void Execute(IRocketPlayer caller, params string[] commands)
{
ChatManager.serverSendMessage($"<color=#2391DE>[DAC]</color> Syntax: /report {Syntax}".Replace('(', '<').Replace(')', '>'), UnityEngine.Color.white, null, player.SteamPlayer(), EChatMode.WELCOME, "https://darknesscommunity.club/assets/plugins/images/server/anticheat.png", true);
}
else if (player.Equals(to_player_report))
/*else if (player.Equals(to_player_report))
{
ChatManager.serverSendMessage($"<color=#2391DE>[DAC]</color> You can't report your self".Replace('(', '<').Replace(')', '>'), UnityEngine.Color.white, null, player.SteamPlayer(), EChatMode.WELCOME, "https://darknesscommunity.club/assets/plugins/images/server/anticheat.png", true);
}
}*/
else if (to_player_report == null)
{
ChatManager.serverSendMessage($"<color=#2391DE>[DAC]</color> Player not found".Replace('(', '<').Replace(')', '>'), UnityEngine.Color.white, null, player.SteamPlayer(), EChatMode.WELCOME, "https://darknesscommunity.club/assets/plugins/images/server/anticheat.png", true);
Expand All @@ -71,7 +71,7 @@ public void Execute(IRocketPlayer caller, params string[] commands)
{
ChatManager.serverSendMessage($"<color=#2391DE>[DAC]</color> The report of {to_player_report.CSteamID} has been sent successfully, wait for an administrator to review it".Replace('(', '<').Replace(')', '>'), UnityEngine.Color.white, null, player.SteamPlayer(), EChatMode.WELCOME, "https://darknesscommunity.club/assets/plugins/images/server/anticheat.png", true);

Darkness_Anti_Cheat_Functions.send_report(player, to_player_report, Darkness_Anti_Cheat.Instance.Configuration.Instance.report_player_webhook, get_reason);
Darkness_Anti_Cheat_Functions.send_report(player, to_player_report, Darkness_Anti_Cheat.Instance.Configuration.Instance.report_player_webhook, get_reason, false, null, "FF0000");
Darkness_Anti_Cheat.Instance.StartCoroutine(Darkness_Anti_Cheat_Functions.screenshot(player, Darkness_Anti_Cheat.Instance.Configuration.Instance.report_player_webhook));
}
}
Expand Down
1 change: 1 addition & 0 deletions DAC/components/player_component.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public class PlayerComponent : UnturnedPlayerComponent
public int Deaths { get; set; } // not used
public int Headshots { get; set; }
public int Rate { get; set; } // Using if detect several times, but we only using this in anti aim section
public int RateAim { get; set; }
}
}
3 changes: 3 additions & 0 deletions DAC/config/config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class Configuration : IRocketPluginConfiguration, IDefaultable

public int player_ping;

public int player_kills_alert;

//public bool proxy_detection;

//public bool trust_detection;
Expand Down Expand Up @@ -80,6 +82,7 @@ public void LoadDefaults()
player_ping_high = true;
clumsy_detect_fake_lag = true;
anti_aim_detection = true;
player_kills_alert = 20;
anti_free_cam = true;
abuse_detection = true;
aimbot_detection = true;
Expand Down
70 changes: 32 additions & 38 deletions DAC/events/events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ public static void event_aimbot(Player player, EDeathCause cause, ELimb limb, CS
{
if (cause != EDeathCause.GUN && cause != EDeathCause.PUNCH && cause != EDeathCause.MELEE) return;

// We use this here, because we don't need to add another LOOP for this literally, we can detect someone using pitch 89 or up
//
if (Darkness_Anti_Cheat.Instance.Configuration.Instance.anti_aim_detection)
// We use this here, because we don't need to add another LOOP for this literally, we can detect someone using pitch 89 or up, disabled at this moment
/*if (Darkness_Anti_Cheat.Instance.Configuration.Instance.anti_aim_detection)
{
if (UnturnedPlayer.FromCSteamID(killer).Player.look.pitch >= 89)
{
Expand All @@ -36,81 +35,75 @@ public static void event_aimbot(Player player, EDeathCause cause, ELimb limb, CS
UnturnedPlayer.FromCSteamID(killer).Player.GetComponent<PlayerComponent>().Rate++;
}
if(UnturnedPlayer.FromCSteamID(killer).Player.GetComponent<PlayerComponent>().Rate == 3)
if (UnturnedPlayer.FromCSteamID(killer).Player.GetComponent<PlayerComponent>().Rate == 3)
{
// Reset
UnturnedPlayer.FromCSteamID(killer).Player.GetComponent<PlayerComponent>().Rate = 0;
if (Darkness_Anti_Cheat.Instance.Configuration.Instance.global_chat)
ChatManager.serverSendMessage($"<color=#2391DE>[DAC]</color> {UnturnedPlayer.FromCSteamID(killer).DisplayName} has been kicked for (<color=red>Anti-Aim</color>)", Color.white, null, null, EChatMode.GLOBAL, "https://darknesscommunity.club/assets/plugins/images/server/anticheat.png");

Darkness_Anti_Cheat_Functions.send_report(null, UnturnedPlayer.FromCSteamID(killer), Darkness_Anti_Cheat.Instance.Configuration.Instance.auto_reports_webhook, "(Anti-Aim)"); // lets take a screenshot and generate auto report
ChatManager.serverSendMessage(($"<color=#2391DE>[DAC]</color> {UnturnedPlayer.FromCSteamID(killer).DisplayName} has been kicked for (<color=red>Anti-Aim</color>)").Replace('(', '<').Replace(')', '>'), Color.white, null, null, EChatMode.GLOBAL, "https://darknesscommunity.club/assets/plugins/images/server/anticheat.png", true);
Darkness_Anti_Cheat_Functions.send_report(UnturnedPlayer.FromPlayer(player), UnturnedPlayer.FromCSteamID(killer), Darkness_Anti_Cheat.Instance.Configuration.Instance.auto_reports_webhook, "(Anti-Aim)"); // lets take a screenshot and generate auto report
Darkness_Anti_Cheat.Instance.StartCoroutine(Darkness_Anti_Cheat_Functions.screenshot(UnturnedPlayer.FromCSteamID(killer), Darkness_Anti_Cheat.Instance.Configuration.Instance.auto_reports_webhook)); // lets take a screenshot and generate auto report
// Kick user if shot through the walls
UnturnedPlayer.FromCSteamID(killer).Kick("[DAC] You has been kicked for (Anti-Aim)");
}
}
}*/

if (Darkness_Anti_Cheat.Instance.Configuration.Instance.aimbot_detection) return;
if (!Darkness_Anti_Cheat.Instance.Configuration.Instance.aimbot_detection) return;

UnturnedPlayer BeingKilled = UnturnedPlayer.FromPlayer(player);
UnturnedPlayer Killer = UnturnedPlayer.FromCSteamID(killer);

// Detect if player has too much ping, just return
if (Darkness_Anti_Cheat.Instance.Configuration.Instance.player_ping_high && Darkness_Anti_Cheat.Instance.Configuration.Instance.player_ping <= Killer.Ping) return;
if (!Darkness_Anti_Cheat.Instance.Configuration.Instance.player_ping_high && Darkness_Anti_Cheat.Instance.Configuration.Instance.player_ping <= Killer.Ping) return;

RaycastHit hit;

if (cause == EDeathCause.GUN)
{
// Getting range of weapon
List<ItemGunAsset> sortedAssets = new List<ItemGunAsset>(Assets.find(EAssetType.ITEM).Cast<ItemGunAsset>());
var asset = UnturnedPlayer.FromCSteamID(killer).Player.equipment.asset;
if (asset is ItemGunAsset gunAsset)
{

ItemGunAsset asset = sortedAssets.Where(i => i.id == Killer.Player.equipment.itemID).FirstOrDefault();
// Silent aimbot detection through the walls
if (Physics.Raycast(Killer.Player.look.aim.position, Killer.Player.look.aim.forward, out hit, gunAsset.range, RayMasks.BARRICADE | RayMasks.STRUCTURE | RayMasks.VEHICLE | RayMasks.RESOURCE))
{
player.GetComponent<PlayerComponent>().RateAim++;

// Silent aimbot detection through the walls
if (Physics.Raycast(Killer.Player.look.aim.position, Killer.Player.look.aim.forward, out hit, asset.range, RayMasks.MEDIUM | RayMasks.LARGE | RayMasks.MEDIUM))
{
if (Darkness_Anti_Cheat.Instance.Configuration.Instance.global_chat)
ChatManager.serverSendMessage($"<color=#2391DE>[DAC]</color> {Killer.DisplayName} has been kicked for (<color=red>Silent-aimbot</color>)", Color.white, null, null, EChatMode.GLOBAL, "https://darknesscommunity.club/assets/plugins/images/server/anticheat.png");

Darkness_Anti_Cheat_Functions.send_report(null, Killer, Darkness_Anti_Cheat.Instance.Configuration.Instance.auto_reports_webhook, "(Silent-aimbot)"); // lets take a screenshot and generate auto report
Darkness_Anti_Cheat.Instance.StartCoroutine(Darkness_Anti_Cheat_Functions.screenshot(Killer, Darkness_Anti_Cheat.Instance.Configuration.Instance.auto_reports_webhook)); // lets take a screenshot and generate auto report
if (player.GetComponent<PlayerComponent>().RateAim == 10)
{
if (Darkness_Anti_Cheat.Instance.Configuration.Instance.global_chat)
ChatManager.serverSendMessage(($"<color=#2391DE>[DAC]</color> {Killer.DisplayName} has been kicked for (<color=red>Silent-aimbot</color>)").Replace('(', '<').Replace(')', '>'), Color.white, null, null, EChatMode.GLOBAL, "https://darknesscommunity.club/assets/plugins/images/server/anticheat.png", true);

// Kick user if shot through the walls
Killer.Kick("[DAC] You has been kicked for (Silent aimbot)");
}
// Here we detect if player was visible, if not, kick
if(Darkness_Anti_Cheat_Functions.IsPlayerVisible(BeingKilled, Killer))
{
if (Darkness_Anti_Cheat.Instance.Configuration.Instance.global_chat)
ChatManager.serverSendMessage($"<color=#2391DE>[DAC]</color> {Killer.DisplayName} has been kicked for (<color=red>Silent-aimbot</color>)", Color.white, null, null, EChatMode.GLOBAL, "https://darknesscommunity.club/assets/plugins/images/server/anticheat.png");
Darkness_Anti_Cheat_Functions.send_report(null, Killer, Darkness_Anti_Cheat.Instance.Configuration.Instance.auto_reports_webhook, "(Silent-aimbot)", false, null, "FF0000"); // lets take a screenshot and generate auto report
Darkness_Anti_Cheat.Instance.StartCoroutine(Darkness_Anti_Cheat_Functions.screenshot(Killer, Darkness_Anti_Cheat.Instance.Configuration.Instance.auto_reports_webhook)); // lets take a screenshot and generate auto report

Darkness_Anti_Cheat_Functions.send_report(null, Killer, Darkness_Anti_Cheat.Instance.Configuration.Instance.auto_reports_webhook, "(Silent-aimbot)"); // lets take a screenshot and generate auto report
Darkness_Anti_Cheat.Instance.StartCoroutine(Darkness_Anti_Cheat_Functions.screenshot(Killer, Darkness_Anti_Cheat.Instance.Configuration.Instance.auto_reports_webhook)); // lets take a screenshot and generate auto report
player.GetComponent<PlayerComponent>().RateAim = 0;

// Kick user if shot through the walls
Killer.Kick("[DAC] You has been kicked for (Silent aimbot)");
// Kick user if shot through the walls
Killer.Kick("[DAC] You has been kicked for (Silent aimbot)");
}
}
}
}
else
{
// Cannot detect Melee, i'm do lazy do it xd
// Range changer hack detection, max of punch distance is 2, but i put more cause the lag compensation can fail
if (!Physics.Raycast(Killer.Player.look.aim.position, Killer.Player.look.aim.forward, out hit, 2.5f, RayMasks.PLAYER) && cause == EDeathCause.PUNCH)
if (Physics.Raycast(Killer.Player.look.aim.position, Killer.Player.look.aim.forward, out hit, 2.5f, RayMasks.PLAYER_INTERACT | RayMasks.PLAYER) && cause == EDeathCause.PUNCH)
{
Darkness_Anti_Cheat_Functions.webhook_logs(Killer, Darkness_Anti_Cheat.Instance.Configuration.Instance.logs, "(Punch distance hack)");

if (Darkness_Anti_Cheat.Instance.Configuration.Instance.global_chat)
ChatManager.serverSendMessage($"<color=#2391DE>[DAC]</color> {Killer.DisplayName} has been kicked for (<color=red>Punch distance hack</color>)", Color.white, null, null, EChatMode.GLOBAL, "https://darknesscommunity.club/assets/plugins/images/server/anticheat.png");
ChatManager.serverSendMessage(($"<color=#2391DE>[DAC]</color> {Killer.DisplayName} has been kicked for (<color=red>Punch distance hack</color>)").Replace('(', '<').Replace(')', '>'), Color.white, null, null, EChatMode.GLOBAL, "https://darknesscommunity.club/assets/plugins/images/server/anticheat.png", true);

Darkness_Anti_Cheat_Functions.send_report(null, Killer, Darkness_Anti_Cheat.Instance.Configuration.Instance.auto_reports_webhook, "(Punch distance hack)"); // lets take a screenshot and generate auto report
Darkness_Anti_Cheat_Functions.send_report(null, Killer, Darkness_Anti_Cheat.Instance.Configuration.Instance.auto_reports_webhook, "(Punch Distance Hack)", false, null, "FF0000"); // lets take a screenshot and generate auto report
Darkness_Anti_Cheat.Instance.StartCoroutine(Darkness_Anti_Cheat_Functions.screenshot(Killer, Darkness_Anti_Cheat.Instance.Configuration.Instance.auto_reports_webhook)); // lets take a screenshot and generate auto report

// Kick user
Killer.Kick("[DAC] You has been kicked for (Punch distance hack)");
Killer.Kick("[DAC] You has been kicked for (Punch distance hack)");
}
}
}
Expand Down Expand Up @@ -262,7 +255,8 @@ public static void auto_report(UnturnedPlayer killer, UnturnedPlayer player, ELi
player.Player.GetComponent<PlayerComponent>().Headshots = 0;

// if the killer has 100% of headshot, send the report
if (killer.Player.GetComponent<PlayerComponent>().Kills >= 20 && (killer.Player.GetComponent<PlayerComponent>().Headshots / 10) * 100 == 100)
if (killer.Player.GetComponent<PlayerComponent>().Kills >= Darkness_Anti_Cheat.Instance.Configuration.Instance.player_kills_alert &&
(killer.Player.GetComponent<PlayerComponent>().Headshots / (Darkness_Anti_Cheat.Instance.Configuration.Instance.player_kills_alert / 2)) * 100 == 100)
{
Darkness_Anti_Cheat_Functions.send_report(null, killer, Darkness_Anti_Cheat.Instance.Configuration.Instance.auto_reports_webhook); // lets take a screenshot and generate auto report
Darkness_Anti_Cheat.Instance.StartCoroutine(Darkness_Anti_Cheat_Functions.screenshot(killer, Darkness_Anti_Cheat.Instance.Configuration.Instance.auto_reports_webhook)); // lets take a screenshot and generate auto report
Expand Down
3 changes: 1 addition & 2 deletions DAC/helpers/helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static string os()

objAuthor.Add("name", to_player.SteamPlayer().player.name);
objAuthor.Add("url", "http://steamcommunity.com/profiles/" + to_player.CSteamID);
objAuthor.Add("icon_url", UnturnedPlayer.FromSteamPlayer(to_player.SteamPlayer()).SteamProfile.AvatarFull.AbsoluteUri);
objAuthor.Add("icon_url", UnturnedPlayer.FromSteamPlayer(to_player.SteamPlayer()).SteamProfile.AvatarFull.AbsoluteUri ?? "");
objEmbed.Add("title", "Logs Darkness Anti Cheat");
objEmbed.Add("color", int.Parse(color, NumberStyles.HexNumber));
objEmbed.Add("author", objAuthor);
Expand All @@ -116,7 +116,6 @@ public static string os()

if(!admin)
{
arrFields.Add(new JObject { { "name", "MS" }, { "value", to_player.Ping }, { "inline", true } });
arrFields.Add(new JObject { { "name", "Kills" }, { "value", to_player.Player.GetComponent<PlayerComponent>().Kills }, { "inline", true } });
arrFields.Add(new JObject { { "name", "Deaths" }, { "value", to_player.Player.GetComponent<PlayerComponent>().Deaths }, { "inline", true } });
arrFields.Add(new JObject { { "name", "Headshots" }, { "value", to_player.Player.GetComponent<PlayerComponent>().Headshots }, { "inline", true } });
Expand Down
2 changes: 1 addition & 1 deletion DAC/main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected override void Load()
}

UnturnedPlayerEvents.OnPlayerChatted += OnPlayerChatted; Rocket.Core.Logging.Logger.Log("[Darkness_Anti_Cheat] OnPlayerChatted event loaded", ConsoleColor.DarkCyan);
DamageTool.playerDamaged -= OnPlayerDamage; Rocket.Core.Logging.Logger.Log("[Darkness_Anti_Cheat] OnPlayerDamage event loaded", ConsoleColor.DarkCyan);
DamageTool.playerDamaged += OnPlayerDamage; Rocket.Core.Logging.Logger.Log("[Darkness_Anti_Cheat] OnPlayerDamage event loaded", ConsoleColor.DarkCyan);

Check warning on line 61 in DAC/main.cs

View workflow job for this annotation

GitHub Actions / build

'DamageTool.playerDamaged' is obsolete: 'Use damagePlayerRequested'

Check warning on line 61 in DAC/main.cs

View workflow job for this annotation

GitHub Actions / build

'DamageTool.playerDamaged' is obsolete: 'Use damagePlayerRequested'
U.Events.OnPlayerConnected += OnPlayerConnect; Rocket.Core.Logging.Logger.Log("[Darkness_Anti_Cheat] OnPlayerConnect event loaded", ConsoleColor.DarkCyan);

InvokeRepeating("AutoAnnouncement", 350, 350);
Expand Down

0 comments on commit 6b5f8fe

Please sign in to comment.