From 4e5ea30db5337821cbf1ae91b5e6d576f603be47 Mon Sep 17 00:00:00 2001 From: locus313 Date: Sat, 14 Nov 2020 17:49:44 -0800 Subject: [PATCH 1/8] update readme --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8f1a08e..cf32f22 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# Anticheat Module +# ![logo](https://raw.githubusercontent.com/azerothcore/azerothcore.github.io/master/images/logo-github.png) AzerothCore +## Anticheat Module +- Latest build status with azerothcore: [![Build Status](https://github.com/azerothcore/mod-anticheat/workflows/core-build/badge.svg?branch=master&event=push)](https://github.com/azerothcore/mod-anticheat) This is a port of the PassiveAnticheat Script from lordpsyan's repo to [AzerothCore](http://www.azerothcore.org) From 706fa10f8b3123078b5ecf75830f87232cc2d0bb Mon Sep 17 00:00:00 2001 From: locus313 Date: Sat, 14 Nov 2020 17:53:58 -0800 Subject: [PATCH 2/8] add workflow for testing --- .github/workflows/core-build.yml | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/core-build.yml diff --git a/.github/workflows/core-build.yml b/.github/workflows/core-build.yml new file mode 100644 index 0000000..fd2b9b1 --- /dev/null +++ b/.github/workflows/core-build.yml @@ -0,0 +1,45 @@ +name: core-build +on: + push: + pull_request: + +jobs: + build: + strategy: + fail-fast: false + matrix: + compiler: [clang6, clang9, clang10] + runs-on: ubuntu-20.04 + name: ${{ matrix.compiler }} + env: + COMPILER: ${{ matrix.compiler }} + steps: + - uses: actions/checkout@v2 + with: + repository: 'azerothcore/azerothcore-wotlk' + ref: 'master' + submodules: 'recursive' + - uses: actions/checkout@v2 + with: + submodules: 'recursive' + path: 'modules/mod-anticheat' + - name: Cache + uses: actions/cache@v1.1.2 + with: + path: /home/runner/.ccache + key: ccache:${{ matrix.compiler }}:${{ github.ref }}:${{ github.sha }} + restore-keys: | + ccache:${{ matrix.compiler }}:${{ github.ref }} + ccache:${{ matrix.compiler }} + - name: Configure OS + run: source ./apps/ci/ci-install.sh + env: + CONTINUOUS_INTEGRATION: true + - name: Import db + run: source ./apps/ci/ci-import-db.sh + - name: Build + run: source ./apps/ci/ci-compile.sh + - name: Dry run + run: source ./apps/ci/ci-worldserver-dry-run.sh + - name: Check startup errors + run: source ./apps/ci/ci-error-check.sh \ No newline at end of file From d32068448a722de7d78ec38b34e162cf3b5cf017 Mon Sep 17 00:00:00 2001 From: locus313 Date: Sat, 14 Nov 2020 18:08:14 -0800 Subject: [PATCH 3/8] add include Chat.h and Player.h --- src/AnticheatScripts.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/AnticheatScripts.cpp b/src/AnticheatScripts.cpp index beeda5a..f54bb15 100644 --- a/src/AnticheatScripts.cpp +++ b/src/AnticheatScripts.cpp @@ -2,6 +2,8 @@ #include "AnticheatMgr.h" #include "Object.h" #include "AccountMgr.h" +#include "Chat.h" +#include "Player.h" int64 resetTime = 0; int64 lastIterationPlayer = sWorld->GetUptime() + 30;//TODO: change 30 secs static to a configurable option From ddec0783a813fee25e7dcc9921051b1d29921f5b Mon Sep 17 00:00:00 2001 From: locus313 Date: Sat, 14 Nov 2020 18:49:37 -0800 Subject: [PATCH 4/8] add brackets --- src/AnticheatMgr.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/AnticheatMgr.cpp b/src/AnticheatMgr.cpp index 1a25def..6c2d08a 100644 --- a/src/AnticheatMgr.cpp +++ b/src/AnticheatMgr.cpp @@ -88,23 +88,33 @@ void AnticheatMgr::WalkOnWaterHackDetection(Player* player, MovementInfo moveme void AnticheatMgr::FlyHackDetection(Player* player, MovementInfo movementInfo) { if (!sConfigMgr->GetBoolDefault("Anticheat.DetectFlyHack", true)) + { return; + } if (player->HasAuraType(SPELL_AURA_FLY) || player->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) || player->HasAuraType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED))//overkill but wth + { return; + } /*Thanks to @LilleCarl for info to check extra flag*/ bool stricterChecks = true; if (sConfigMgr->GetBoolDefault("Anticheat.StricterFlyHackCheck", false)) + { stricterChecks = !(movementInfo.HasMovementFlag(MOVEMENTFLAG_ASCENDING) && !player->IsInWater()); + } if (!movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY) && !movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING) && stricterChecks) + { return; + } if (sConfigMgr->GetBoolDefault("Anticheat.KickPlayerFlyHack", false)) { if (sConfigMgr->GetBoolDefault("Anticheat.WriteLog", false)) + { sLog->outString("AnticheatMgr:: Fly-Hack detected and counteracted by kicking player %s (%u)", player->GetName().c_str(), player->GetGUIDLow()); + } player->GetSession()->KickPlayer(true); if(sConfigMgr->GetBoolDefault("Anticheat.AnnounceKick", true)) @@ -118,7 +128,8 @@ void AnticheatMgr::FlyHackDetection(Player* player, MovementInfo movementInfo) " has been kicked.|r"; sWorld->SendServerMessage(SERVER_MSG_STRING, stream.str().c_str()); } - } else if (sConfigMgr->GetBoolDefault("Anticheat.WriteLog", false)) { + } else if (sConfigMgr->GetBoolDefault("Anticheat.WriteLog", false)) + { sLog->outString( "AnticheatMgr:: Fly-Hack detected player %s (%u)", player->GetName().c_str(), player->GetGUIDLow()); } From 71a5e4cf1e8bfc3bfe0e670f8cbf261a8a683e01 Mon Sep 17 00:00:00 2001 From: locus313 Date: Sat, 14 Nov 2020 18:51:28 -0800 Subject: [PATCH 5/8] add include Player.h --- src/cs_anticheat.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cs_anticheat.cpp b/src/cs_anticheat.cpp index f0cd5a6..52fd7c9 100644 --- a/src/cs_anticheat.cpp +++ b/src/cs_anticheat.cpp @@ -18,6 +18,7 @@ #include "Chat.h" #include "AnticheatMgr.h" #include "Configuration/Config.h" +#include "Player.h" class anticheat_commandscript : public CommandScript { From 0b1c94185cfeca228a1796ec86993dc3edbe86c6 Mon Sep 17 00:00:00 2001 From: locus313 Date: Sat, 14 Nov 2020 19:41:36 -0800 Subject: [PATCH 6/8] remove workflow --- .github/workflows/core-build.yml | 45 -------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 .github/workflows/core-build.yml diff --git a/.github/workflows/core-build.yml b/.github/workflows/core-build.yml deleted file mode 100644 index fd2b9b1..0000000 --- a/.github/workflows/core-build.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: core-build -on: - push: - pull_request: - -jobs: - build: - strategy: - fail-fast: false - matrix: - compiler: [clang6, clang9, clang10] - runs-on: ubuntu-20.04 - name: ${{ matrix.compiler }} - env: - COMPILER: ${{ matrix.compiler }} - steps: - - uses: actions/checkout@v2 - with: - repository: 'azerothcore/azerothcore-wotlk' - ref: 'master' - submodules: 'recursive' - - uses: actions/checkout@v2 - with: - submodules: 'recursive' - path: 'modules/mod-anticheat' - - name: Cache - uses: actions/cache@v1.1.2 - with: - path: /home/runner/.ccache - key: ccache:${{ matrix.compiler }}:${{ github.ref }}:${{ github.sha }} - restore-keys: | - ccache:${{ matrix.compiler }}:${{ github.ref }} - ccache:${{ matrix.compiler }} - - name: Configure OS - run: source ./apps/ci/ci-install.sh - env: - CONTINUOUS_INTEGRATION: true - - name: Import db - run: source ./apps/ci/ci-import-db.sh - - name: Build - run: source ./apps/ci/ci-compile.sh - - name: Dry run - run: source ./apps/ci/ci-worldserver-dry-run.sh - - name: Check startup errors - run: source ./apps/ci/ci-error-check.sh \ No newline at end of file From 4df798301342ad3372f3b73e486e6d77471f1b0b Mon Sep 17 00:00:00 2001 From: Patrick Lewis Date: Sat, 14 Nov 2020 19:50:29 -0800 Subject: [PATCH 7/8] indentation --- src/AnticheatMgr.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/AnticheatMgr.cpp b/src/AnticheatMgr.cpp index 6c2d08a..dd95528 100644 --- a/src/AnticheatMgr.cpp +++ b/src/AnticheatMgr.cpp @@ -100,21 +100,21 @@ void AnticheatMgr::FlyHackDetection(Player* player, MovementInfo movementInfo) /*Thanks to @LilleCarl for info to check extra flag*/ bool stricterChecks = true; if (sConfigMgr->GetBoolDefault("Anticheat.StricterFlyHackCheck", false)) - { + { stricterChecks = !(movementInfo.HasMovementFlag(MOVEMENTFLAG_ASCENDING) && !player->IsInWater()); - } + } if (!movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY) && !movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING) && stricterChecks) - { + { return; - } + } if (sConfigMgr->GetBoolDefault("Anticheat.KickPlayerFlyHack", false)) { if (sConfigMgr->GetBoolDefault("Anticheat.WriteLog", false)) - { + { sLog->outString("AnticheatMgr:: Fly-Hack detected and counteracted by kicking player %s (%u)", player->GetName().c_str(), player->GetGUIDLow()); - } + } player->GetSession()->KickPlayer(true); if(sConfigMgr->GetBoolDefault("Anticheat.AnnounceKick", true)) @@ -129,7 +129,7 @@ void AnticheatMgr::FlyHackDetection(Player* player, MovementInfo movementInfo) sWorld->SendServerMessage(SERVER_MSG_STRING, stream.str().c_str()); } } else if (sConfigMgr->GetBoolDefault("Anticheat.WriteLog", false)) - { + { sLog->outString( "AnticheatMgr:: Fly-Hack detected player %s (%u)", player->GetName().c_str(), player->GetGUIDLow()); } From bd186b98b87d6cb4c5857a4669c0d65855c20c7c Mon Sep 17 00:00:00 2001 From: locus313 Date: Sat, 14 Nov 2020 19:56:35 -0800 Subject: [PATCH 8/8] tabs to spaces --- src/AnticheatMgr.cpp | 60 ++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/AnticheatMgr.cpp b/src/AnticheatMgr.cpp index dd95528..27f2bcd 100644 --- a/src/AnticheatMgr.cpp +++ b/src/AnticheatMgr.cpp @@ -97,41 +97,41 @@ void AnticheatMgr::FlyHackDetection(Player* player, MovementInfo movementInfo) return; } - /*Thanks to @LilleCarl for info to check extra flag*/ - bool stricterChecks = true; - if (sConfigMgr->GetBoolDefault("Anticheat.StricterFlyHackCheck", false)) + /*Thanks to @LilleCarl for info to check extra flag*/ + bool stricterChecks = true; + if (sConfigMgr->GetBoolDefault("Anticheat.StricterFlyHackCheck", false)) + { + stricterChecks = !(movementInfo.HasMovementFlag(MOVEMENTFLAG_ASCENDING) && !player->IsInWater()); + } + + if (!movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY) && !movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING) && stricterChecks) + { + return; + } + + if (sConfigMgr->GetBoolDefault("Anticheat.KickPlayerFlyHack", false)) + { + if (sConfigMgr->GetBoolDefault("Anticheat.WriteLog", false)) { - stricterChecks = !(movementInfo.HasMovementFlag(MOVEMENTFLAG_ASCENDING) && !player->IsInWater()); + sLog->outString("AnticheatMgr:: Fly-Hack detected and counteracted by kicking player %s (%u)", player->GetName().c_str(), player->GetGUIDLow()); } - if (!movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY) && !movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING) && stricterChecks) + player->GetSession()->KickPlayer(true); + if(sConfigMgr->GetBoolDefault("Anticheat.AnnounceKick", true)) { - return; + std::string plr = player->GetName(); + std::string tag_colour = "7bbef7"; + std::string plr_colour = "ff0000"; + std::ostringstream stream; + stream << "|CFF" << plr_colour << "[AntiCheat]|r|CFF" << tag_colour << + " Player |r|cff" << plr_colour << plr << "|r|cff" << tag_colour << + " has been kicked.|r"; + sWorld->SendServerMessage(SERVER_MSG_STRING, stream.str().c_str()); } - - if (sConfigMgr->GetBoolDefault("Anticheat.KickPlayerFlyHack", false)) - { - if (sConfigMgr->GetBoolDefault("Anticheat.WriteLog", false)) - { - sLog->outString("AnticheatMgr:: Fly-Hack detected and counteracted by kicking player %s (%u)", player->GetName().c_str(), player->GetGUIDLow()); - } - - player->GetSession()->KickPlayer(true); - if(sConfigMgr->GetBoolDefault("Anticheat.AnnounceKick", true)) - { - std::string plr = player->GetName(); - std::string tag_colour = "7bbef7"; - std::string plr_colour = "ff0000"; - std::ostringstream stream; - stream << "|CFF" << plr_colour << "[AntiCheat]|r|CFF" << tag_colour << - " Player |r|cff" << plr_colour << plr << "|r|cff" << tag_colour << - " has been kicked.|r"; - sWorld->SendServerMessage(SERVER_MSG_STRING, stream.str().c_str()); - } - } else if (sConfigMgr->GetBoolDefault("Anticheat.WriteLog", false)) - { - sLog->outString( "AnticheatMgr:: Fly-Hack detected player %s (%u)", player->GetName().c_str(), player->GetGUIDLow()); - } + } else if (sConfigMgr->GetBoolDefault("Anticheat.WriteLog", false)) + { + sLog->outString( "AnticheatMgr:: Fly-Hack detected player %s (%u)", player->GetName().c_str(), player->GetGUIDLow()); + } BuildReport(player,FLY_HACK_REPORT); }