std::string Warden::Penalty(WardenCheck* check /*= NULL*/) { WardenActions action; if (check) action = check->Action; else action = WardenActions(sWorld->getIntConfig(CONFIG_WARDEN_CLIENT_FAIL_ACTION)); switch (action) { case WARDEN_ACTION_LOG: return "None"; break; case WARDEN_ACTION_KICK: _session->KickPlayer(); return "Kick"; break; case WARDEN_ACTION_BAN: { std::stringstream duration; duration << sWorld->getIntConfig(CONFIG_WARDEN_CLIENT_BAN_DURATION) << "s"; std::string accountName; AccountMgr::GetName(_session->GetAccountId(), accountName); sWorld->BanAccount(BAN_ACCOUNT, accountName, duration.str(), "Warden Anticheat violation","Server"); return "Ban"; break; } default: return "Undefined"; break; } }
void WardenCheckMgr::LoadWardenOverrides() { // Check if Warden is enabled by config before loading anything if (!sWorld->getBoolConfig(CONFIG_WARDEN_ENABLED)) { sLog->outInfo(LOG_FILTER_WARDEN, ">> Warden disabled, loading check overrides skipped."); return; } // 0 1 QueryResult result = CharacterDatabase.Query("SELECT wardenId, action FROM warden_action"); if (!result) { sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 Warden action overrides. DB table `warden_action` is empty!"); return; } uint32 count = 0; ACE_WRITE_GUARD(ACE_RW_Mutex, g, _checkStoreLock); do { Field* fields = result->Fetch(); uint16 checkId = fields[0].GetUInt16(); uint8 action = fields[1].GetUInt8(); // Check if action value is in range (0-2, see WardenActions enum) if (action > WARDEN_ACTION_BAN) sLog->outError(LOG_FILTER_WARDEN, "Warden check override action out of range (ID: %u, action: %u)", checkId, action); // Check if check actually exists before accessing the CheckStore vector else if (checkId > CheckStore.size()) sLog->outError(LOG_FILTER_WARDEN, "Warden check action override for non-existing check (ID: %u, action: %u), skipped", checkId, action); else { CheckStore[checkId]->Action = WardenActions(action); ++count; } } while (result->NextRow()); sLog->outInfo(LOG_FILTER_WARDEN, ">> Loaded %u warden action overrides.", count); }
void WardenCheckMgr::LoadWardenOverrides() { uint32 oldMSTime = getMSTime(); // Check if Warden is enabled by config before loading anything if (!sWorld->getBoolConfig(CONFIG_WARDEN_ENABLED)) { TC_LOG_INFO("warden", ">> Warden disabled, loading check overrides skipped."); return; } // 0 1 QueryResult result = CharacterDatabase.Query("SELECT wardenId, action FROM warden_action"); if (!result) { TC_LOG_INFO("server.loading", ">> Loaded 0 Warden action overrides. DB table `warden_action` is empty!"); return; } uint32 count = 0; boost::unique_lock<boost::shared_mutex> lock(sWardenCheckMgr->_checkStoreLock); do { Field* fields = result->Fetch(); uint16 checkId = fields[0].GetUInt16(); uint8 action = fields[1].GetUInt8(); // Check if action value is in range (0-2, see WardenActions enum) if (action > WARDEN_ACTION_BAN) TC_LOG_ERROR("warden", "Warden check override action out of range (ID: %u, action: %u)", checkId, action); // Check if check actually exists before accessing the CheckStore vector else if (checkId > CheckStore.size()) TC_LOG_ERROR("warden", "Warden check action override for non-existing check (ID: %u, action: %u), skipped", checkId, action); else { CheckStore[checkId]->Action = WardenActions(action); ++count; } } while (result->NextRow()); TC_LOG_INFO("server.loading", ">> Loaded %u warden action overrides in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); }
void WardenCheckMgr::LoadWardenOverrides() { // 0 1 QueryResult result = CharacterDatabase.Query("SELECT wardenId, action FROM warden_action"); if (!result) { sLog->outString(">> Loaded 0 Warden action overrides. DB table `warden_action` is empty!"); sLog->outString(); return; } uint32 count = 0; ACE_WRITE_GUARD(ACE_RW_Mutex, g, _checkStoreLock); do { Field* fields = result->Fetch(); uint16 checkId = fields[0].GetUInt16(); uint8 action = fields[1].GetUInt8(); // Check if action value is in range (0-2, see WardenActions enum) if (action > WARDEN_ACTION_BAN) sLog->outError("Warden check override action out of range (ID: %u, action: %u)", checkId, action); // Check if check actually exists before accessing the CheckStore vector else if (checkId > CheckStore.size()) sLog->outError("Warden check action override for non-existing check (ID: %u, action: %u), skipped", checkId, action); else { CheckStore[checkId]->Action = WardenActions(action); ++count; } } while (result->NextRow()); sLog->outString(">> Loaded %u warden action overrides.", count); sLog->outString(); }
std::string Warden::Penalty(WardenCheck* check /*= NULL*/) { WardenActions action; if (check) action = check->Action; else action = WardenActions(sWorld->getIntConfig(CONFIG_WARDEN_CLIENT_FAIL_ACTION)); switch (action) { case WARDEN_ACTION_LOG: return "None"; break; case WARDEN_ACTION_KICK: _session->KickPlayer(); return "Kick"; break; case WARDEN_ACTION_BAN: { std::stringstream duration; duration << sWorld->getIntConfig(CONFIG_WARDEN_CLIENT_BAN_DURATION) << "s"; std::string accountName; AccountMgr::GetName(_session->GetAccountId(), accountName); std::stringstream banReason; banReason << "Warden Anticheat Violation"; // Check can be NULL, for example if the client sent a wrong signature in the warden packet (CHECKSUM FAIL) if (check) banReason << ": " << check->Comment << " (CheckId: " << check->CheckId << ")"; sWorld->BanAccount(BAN_ACCOUNT, accountName, duration.str(), banReason.str(),"Server"); return "Ban"; break; } default: break; } return "Undefined"; }
void WardenCheckMgr::LoadWardenChecks() { // Check if Warden is enabled by config before loading anything if (!sWorld->getBoolConfig(CONFIG_WARDEN_ENABLED)) { TC_LOG_INFO("warden", ">> Warden disabled, loading checks skipped."); return; } QueryResult result = WorldDatabase.Query("SELECT MAX(id) FROM warden_checks"); if (!result) { TC_LOG_INFO("server.loading", ">> Loaded 0 Warden checks. DB table `warden_checks` is empty!"); return; } Field* fields = result->Fetch(); uint16 maxCheckId = fields[0].GetUInt16(); CheckStore.resize(maxCheckId + 1); // 0 1 2 3 4 5 6 7 result = WorldDatabase.Query("SELECT id, type, data, result, address, length, str, comment FROM warden_checks ORDER BY id ASC"); uint32 count = 0; do { fields = result->Fetch(); uint16 id = fields[0].GetUInt16(); uint8 checkType = fields[1].GetUInt8(); std::string data = fields[2].GetString(); std::string checkResult = fields[3].GetString(); uint32 address = fields[4].GetUInt32(); uint8 length = fields[5].GetUInt8(); std::string str = fields[6].GetString(); std::string comment = fields[7].GetString(); WardenCheck* wardenCheck = new WardenCheck(); wardenCheck->Type = checkType; wardenCheck->CheckId = id; // Initialize action with default action from config wardenCheck->Action = WardenActions(sWorld->getIntConfig(CONFIG_WARDEN_CLIENT_FAIL_ACTION)); if (checkType == PAGE_CHECK_A || checkType == PAGE_CHECK_B || checkType == DRIVER_CHECK) { wardenCheck->Data.SetHexStr(data.c_str()); int len = data.size() / 2; if (wardenCheck->Data.GetNumBytes() < len) { uint8 temp[24]; memset(temp, 0, len); memcpy(temp, wardenCheck->Data.AsByteArray().get(), wardenCheck->Data.GetNumBytes()); std::reverse(temp, temp + len); wardenCheck->Data.SetBinary((uint8*)temp, len); } } if (checkType == MEM_CHECK || checkType == MODULE_CHECK) MemChecksIdPool.push_back(id); else OtherChecksIdPool.push_back(id); if (checkType == MEM_CHECK || checkType == PAGE_CHECK_A || checkType == PAGE_CHECK_B || checkType == PROC_CHECK) { wardenCheck->Address = address; wardenCheck->Length = length; } // PROC_CHECK support missing if (checkType == MEM_CHECK || checkType == MPQ_CHECK || checkType == LUA_STR_CHECK || checkType == DRIVER_CHECK || checkType == MODULE_CHECK) wardenCheck->Str = str; CheckStore[id] = wardenCheck; if (checkType == MPQ_CHECK || checkType == MEM_CHECK) { WardenCheckResult* wr = new WardenCheckResult(); wr->Result.SetHexStr(checkResult.c_str()); int len = checkResult.size() / 2; if (wr->Result.GetNumBytes() < len) { uint8 *temp = new uint8[len]; memset(temp, 0, len); memcpy(temp, wr->Result.AsByteArray().get(), wr->Result.GetNumBytes()); std::reverse(temp, temp + len); wr->Result.SetBinary((uint8*)temp, len); delete [] temp; } CheckResultStore[id] = wr; } if (comment.empty()) wardenCheck->Comment = "Undocumented Check"; else wardenCheck->Comment = comment; ++count; } while (result->NextRow()); TC_LOG_INFO("server.loading", ">> Loaded %u warden checks.", count); }