Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
update (anticheat): Remove Lua Blocker
Browse files Browse the repository at this point in the history
  • Loading branch information
acidmanifesto committed Nov 24, 2023
1 parent 82492a4 commit 251059b
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 153 deletions.
7 changes: 0 additions & 7 deletions sql/updates/characters/2023_11_12_00_characters.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
CREATE TABLE IF NOT EXISTS `lua_cheaters` (
`guid` int unsigned NOT NULL DEFAULT 0,
`account` int unsigned NOT NULL DEFAULT 0,
`macro` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`guid`,`account`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

DROP TABLE `daily_players_reports`;
CREATE TABLE IF NOT EXISTS `daily_players_reports` (
`guid` int unsigned NOT NULL DEFAULT 0,
Expand Down
10 changes: 0 additions & 10 deletions sql/updates/world/2023_11_22_world.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
DROP TABLE IF EXISTS `lua_private_functions`;
CREATE TABLE IF NOT EXISTS `lua_private_functions` (
`function_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`enabled` tinyint(4) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DELETE FROM `lua_private_functions`;
INSERT INTO `lua_private_functions` (`function_name`, `enabled`) VALUES
('CastSpellByName', 1),
('RunMacroText', 1);

DELETE FROM `skyfire_string` WHERE `entry`=11002;
INSERT INTO `skyfire_string` (`entry`, `content_default`, `content_loc1`, `content_loc2`, `content_loc3`, `content_loc4`, `content_loc5`, `content_loc6`, `content_loc7`, `content_loc8`, `content_loc9`, `content_loc10`, `content_loc11`)VALUES
(11002, '|cFFFFBF00[%s]:|cFFFFFFFF|Hplayer:%s|h[%s]|h|cFF00FFFF potential |r|cFFFFFF00%s|r%s x %u|r', null, null, null, null, null, null, null, null, null, null, null);
99 changes: 0 additions & 99 deletions src/server/game/Anticheat/AnticheatMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,105 +120,6 @@ AnticheatMgr::~AnticheatMgr()
{
}

void AnticheatMgr::LoadBlockedLuaFunctions()
{
if (!sWorld->GetBoolConfig(WorldBoolConfigs::CONFIG_LUABLOCKER_ENABLE))
{
SF_LOG_INFO("server.loading", ">> Anticheat.LUAblocker conf is set to 0");
return;
}
uint32 oldmsTime = getMSTime();
auto pstmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_ANTICHEAT_FUNCTIONS);
auto result = WorldDatabase.Query(pstmt);
if (!result)
{
SF_LOG_INFO("server.loading", ">> Anticheat loaded 0 LUA blocked private functions");
return;
}
uint32 count = 0;
do
{
auto fields = result->Fetch();
_luaBlockedFunctions[fields[0].GetString()] = fields[1].GetBool();
++count;
} while (result->NextRow());

SF_LOG_INFO("server.loading", ">> Anticheat loaded %u LUA blocked private functions in %u ms", count, GetMSTimeDiffToNow(oldmsTime));
}

void AnticheatMgr::SaveLuaCheater(uint32 guid, uint32 accountId, std::string macro)
{
auto pstmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ANTICHEAT_LUA_CHEATERS);
pstmt->setUInt32(0, guid);
pstmt->setUInt32(1, accountId);
pstmt->setString(2, macro);
CharacterDatabase.Execute(pstmt);
}

bool AnticheatMgr::CheckIsLuaCheater(uint32 accountId)
{
auto pstmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ANTICHEAT_LUA_CHEATERS);
pstmt->setUInt32(0, accountId);
auto result = CharacterDatabase.Query(pstmt);
if (result)
return true;

return false;
}

bool AnticheatMgr::CheckBlockedLuaFunctions(AccountData accountData[uint8(AccountDataType::NUM_ACCOUNT_DATA_TYPES)], Player* player)
{
for (auto& kv : _luaBlockedFunctions)
{
for (uint8 i = 0; i < uint8(AccountDataType::NUM_ACCOUNT_DATA_TYPES); ++i)
{
std::string currentData = accountData[i].Data;
std::size_t pos = currentData.find(kv.first);
if (pos != std::string::npos)
{
// Code inside this if statement block will only execute if the variable 'pos' is not equal to std::string::npos.
// std::string::npos is a special value indicating the absence of a valid position.
// The following below is all done to capture the macro used and stored it in the SaveLuaCheater

const static std::size_t defaultLength = 200;
// Declares a constant variable 'defaultLength' with a value of 200.
// This variable represents the default length of a substring to be extracted.

std::size_t minPos = int64(int(pos) - 50) < 0 ? 0 : pos - 50;

// Calculates the minimum position from where the substring will be extracted.
// It subtracts 50 from the 'pos' value, casts it to int64, and checks if it's less than 0.
// If it is less than 0, sets 'minPos' to 0, otherwise sets 'minPos' to 'pos - 50'.
// With out the - 50 we will get a crash on certain substrings

std::size_t length = defaultLength + minPos > currentData.length() - 1 ? currentData.length() - minPos : defaultLength;
// Calculates the length of the substring to be extracted.
// It adds 'defaultLength' to 'minPos' and checks if it's greater than the length of 'currentData' minus 1.
// If it is greater, sets 'length' to 'currentData.length() - minPos', otherwise sets it to 'defaultLength'.

std::string macro = currentData.substr(minPos, length);
// Extracts a substring from 'currentData' starting at 'minPos' with a length of 'length' and assigns it to the variable 'macro'.

if (player)
{
// Checks if the 'player' pointer is not null (i.e., it points to a valid object, aka The NULL CHECK).

SF_LOG_INFO("anticheat", "ANTICHEAT COUNTER MEASURE::Player %s has inaccessible LUA MACRO, placing on watch list", player->GetName().c_str());
// Outputs a log message indicating that the player has an inaccessible Lua macro and is being placed on a watch list.

SaveLuaCheater(player->GetGUID(), player->GetSession()->GetAccountId(), macro);
// Calls the 'SaveLuaCheater' function, passing in the player's GUID, session account ID, and the 'macro' string.
// This function saves information about the Lua cheater, such as the id of the player account, character, and macro used, for further analysis or enforcement actions.
}

return true;
}
}
}

return false;
}

void AnticheatMgr::StartHackDetection(Player* player, MovementInfo& movementInfo, uint32 opcode)
{
if (!sWorld->GetBoolConfig(WorldBoolConfigs::CONFIG_ANTICHEAT_ENABLE))
Expand Down
4 changes: 0 additions & 4 deletions src/server/game/Anticheat/AnticheatMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ class AnticheatMgr
void AnticheatDeleteCommand(uint32 guid);
void AnticheatPurgeCommand(ChatHandler* handler);
void ResetDailyReportStates();
void LoadBlockedLuaFunctions();
void SaveLuaCheater(uint32 guid, uint32 accountId, std::string macro);
bool CheckIsLuaCheater(uint32 accountId);
bool CheckBlockedLuaFunctions(AccountData accountData[uint8(AccountDataType::NUM_ACCOUNT_DATA_TYPES)], Player* player);

private:
void SpeedHackDetection(Player* player, MovementInfo &movementInfo, AnticheatData& data);
Expand Down
13 changes: 0 additions & 13 deletions src/server/game/Server/WorldSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "WardenWin.h"
#include "WardenMac.h"
#include "CharacterBoost.h"
#include "AnticheatMgr.h"

namespace
{
Expand Down Expand Up @@ -122,8 +121,6 @@ WorldSession::WorldSession(uint32 id, WorldSocket* sock, AccountTypes sec, uint8
LoginDatabase.PExecute("UPDATE account SET online = 1 WHERE id = %u;", GetAccountId()); // One-time query
}

_isLuaCheater = false;

InitializeQueryCallbackParameters();

_compressionStream = new z_stream();
Expand Down Expand Up @@ -773,16 +770,6 @@ void WorldSession::LoadAccountData(PreparedQueryResult result, uint32 mask)
m_accountData[type].Data = fields[2].GetString();
}
while (result->NextRow());

bool cheater = sAnticheatMgr->CheckIsLuaCheater(GetAccountId());
if (!cheater)
{
cheater = sAnticheatMgr->CheckBlockedLuaFunctions(m_accountData, _player);
}
if (!_isLuaCheater)
{
_isLuaCheater = cheater;
}
}

void WorldSession::SetAccountData(AccountDataType type, time_t tm, std::string const& data)
Expand Down
4 changes: 0 additions & 4 deletions src/server/game/Server/WorldSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,6 @@ class WorldSession

z_stream_s* GetCompressionStream() { return _compressionStream; }

bool IsLuaCheater() const { return _isLuaCheater; }

public: // opcodes handlers
void Handle_NULL(WorldPacket& recvPacket); // not used
void Handle_EarlyProccess(WorldPacket& recvPacket); // just mark packets processed in WorldSocket::OnRead
Expand Down Expand Up @@ -1193,8 +1191,6 @@ class WorldSession
rbac::RBACData* _RBACData;
WorldSession(WorldSession const& right) = delete;
WorldSession & operator=(WorldSession const& right) = delete;

bool _isLuaCheater;
};
#endif
/// @}
1 change: 0 additions & 1 deletion src/server/game/Spells/Spell.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ class Spell
UsedSpellMods m_appliedMods;

int32 GetCastTime() const { return m_casttime; }
int32 GetTimer() const { return m_timer; }
bool IsAutoRepeat() const { return m_autoRepeat; }
void SetAutoRepeat(bool rep) { m_autoRepeat = rep; }
void ReSetTimer() { m_timer = m_casttime > 0 ? m_casttime : 0; }
Expand Down
14 changes: 0 additions & 14 deletions src/server/game/Spells/SpellEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3227,20 +3227,6 @@ void Spell::EffectInterruptCast(SpellEffIndex effIndex)
{
if (Spell* spell = unitTarget->GetCurrentSpell(CurrentSpellTypes(i)))
{
// if player is lua cheater dont interrupt cast until timer reached 600ms
if (auto player = m_caster->ToPlayer())
{
if (player->GetSession()->IsLuaCheater())
{
if (spell->GetCastTime() - spell->GetTimer() < 600)
{
std::string goXYZ = ".go xyz " + std::to_string(player->GetPositionX()) + " " + std::to_string(player->GetPositionY()) + " " + std::to_string(player->GetPositionZ() + 1.0f) + " " + std::to_string(player->GetMap()->GetId()) + " " + std::to_string(player->GetOrientation());
SF_LOG_INFO("anticheat", "ANTICHEAT COUNTER MEASURE::Played %s attempted repeat LUA spell Casting - IP: %s - Flagged at: %s", player->GetName().c_str(), player->GetSession()->GetRemoteAddress().c_str(), goXYZ.c_str());
return;
}
}
}

SpellInfo const* curSpellInfo = spell->m_spellInfo;
// check if we can interrupt spell
if ((spell->getState() == SPELL_STATE_CASTING
Expand Down
1 change: 0 additions & 1 deletion src/server/worldserver/worldserver.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3141,7 +3141,6 @@ Anticheat.Reports.InGame.Max = 70
# Default: 0 - (Disabled)
# 1 - (Enabled)

Anticheat.LUAblocker = 0
Anticheat.DetectFlyHack = 0
Anticheat.DetectWaterWalkHack = 0
Anticheat.DetectJumpHack = 0
Expand Down

0 comments on commit 251059b

Please sign in to comment.