TrinityCore
Warden.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef _WARDEN_BASE_H
19#define _WARDEN_BASE_H
20
21#include "ARC4.h"
22#include "AuthDefines.h"
23#include "Optional.h"
24#include "WardenCheckMgr.h"
25#include <array>
26
28{
29 // Client->Server
33 WARDEN_CMSG_MEM_CHECKS_RESULT = 3, // only sent if MEM_CHECK bytes doesn't match
35 WARDEN_CMSG_MODULE_FAILED = 5, // this is sent when client failed to load uploaded module due to cache fail
36
37 // Server->Client
42 WARDEN_SMSG_MEM_CHECKS_REQUEST = 4, // byte len; while (!EOF) { byte unk(1); byte index(++); string module(can be 0); int offset; byte len; byte[] bytes_to_compare[len]; }
44};
45
46#pragma pack(push, 1)
47
49{
51 std::array<uint8, 16> ModuleId;
52 std::array<uint8, 16> ModuleKey;
54};
55static_assert(sizeof(WardenModuleUse) == (1 + 16 + 16 + 4));
56
58{
61 uint8 Data[500];
62};
63static_assert(sizeof(WardenModuleTransfer) == (1 + 2 + 500));
64
66{
68 std::array<uint8, 16> Seed;
69};
70static_assert(sizeof(WardenHashRequest) == (1 + 16));
71
72#pragma pack(pop)
73
75{
76 std::array<uint8, 16> Id;
77 std::array<uint8, 16> Key;
80};
81
82class WorldSession;
83
85{
86 public:
87 Warden();
88 virtual ~Warden();
89
90 virtual void Init(WorldSession* session, SessionKey const& K) = 0;
91 void Update(uint32 diff);
92 void HandleData(ByteBuffer& buff);
93 bool ProcessLuaCheckResponse(std::string const& msg);
94
95 virtual size_t DEBUG_ForceSpecificChecks(std::vector<uint16> const& checks) = 0;
96
97 protected:
98 void DecryptData(uint8* buffer, uint32 length);
99 void EncryptData(uint8* buffer, uint32 length);
100
101 virtual void InitializeModule() = 0;
102 virtual void RequestHash() = 0;
103 virtual void HandleHashResult(ByteBuffer& buff) = 0;
104 virtual void HandleCheckResult(ByteBuffer& buff) = 0;
106 virtual void RequestChecks() = 0;
107
108 void MakeModuleForClient();
109 void SendModuleToClient();
110 void RequestModule();
111
112 static bool IsValidCheckSum(uint32 checksum, const uint8 *data, const uint16 length);
113 static uint32 BuildChecksum(const uint8 *data, uint32 length);
114
115 // If nullptr is passed, the default action from config is executed
116 char const* ApplyPenalty(WardenCheck const* check);
117
119 std::array<uint8, 16> _inputKey = {};
120 std::array<uint8, 16> _outputKey = {};
121 std::array<uint8, 16> _seed = {};
124 uint32 _checkTimer; // Timer for sending check requests
125 uint32 _clientResponseTimer; // Timer for client response delay
129};
130
131#endif
std::array< uint8, SESSION_KEY_LENGTH > SessionKey
Definition: AuthDefines.h:25
#define TC_GAME_API
Definition: Define.h:123
uint8_t uint8
Definition: Define.h:144
uint16_t uint16
Definition: Define.h:143
uint32_t uint32
Definition: Define.h:142
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:25
WardenOpcodes
Definition: Warden.h:28
@ WARDEN_CMSG_MODULE_MISSING
Definition: Warden.h:30
@ WARDEN_SMSG_MEM_CHECKS_REQUEST
Definition: Warden.h:42
@ WARDEN_CMSG_HASH_RESULT
Definition: Warden.h:34
@ WARDEN_CMSG_MODULE_FAILED
Definition: Warden.h:35
@ WARDEN_SMSG_HASH_REQUEST
Definition: Warden.h:43
@ WARDEN_CMSG_CHEAT_CHECKS_RESULT
Definition: Warden.h:32
@ WARDEN_CMSG_MODULE_OK
Definition: Warden.h:31
@ WARDEN_SMSG_MODULE_CACHE
Definition: Warden.h:39
@ WARDEN_SMSG_MODULE_INITIALIZE
Definition: Warden.h:41
@ WARDEN_SMSG_MODULE_USE
Definition: Warden.h:38
@ WARDEN_CMSG_MEM_CHECKS_RESULT
Definition: Warden.h:33
@ WARDEN_SMSG_CHEAT_CHECKS_REQUEST
Definition: Warden.h:40
Definition: Warden.h:85
virtual void InitializeModuleForClient(ClientWardenModule &module)=0
Optional< ClientWardenModule > _module
Definition: Warden.h:127
uint32 _checkTimer
Definition: Warden.h:124
uint32 _clientResponseTimer
Definition: Warden.h:125
virtual void RequestHash()=0
Trinity::Crypto::ARC4 _outputCrypto
Definition: Warden.h:123
Trinity::Crypto::ARC4 _inputCrypto
Definition: Warden.h:122
virtual size_t DEBUG_ForceSpecificChecks(std::vector< uint16 > const &checks)=0
bool _dataSent
Definition: Warden.h:126
virtual void InitializeModule()=0
virtual void Init(WorldSession *session, SessionKey const &K)=0
bool _initialized
Definition: Warden.h:128
virtual void HandleCheckResult(ByteBuffer &buff)=0
virtual void RequestChecks()=0
WorldSession * _session
Definition: Warden.h:118
virtual void HandleHashResult(ByteBuffer &buff)=0
Player session in the World.
Definition: WorldSession.h:963
void Update(VignetteData &vignette, WorldObject const *owner)
Definition: Vignette.cpp:90
uint8 const * CompressedData
Definition: Warden.h:78
size_t CompressedSize
Definition: Warden.h:79
std::array< uint8, 16 > Key
Definition: Warden.h:77
std::array< uint8, 16 > Id
Definition: Warden.h:76
std::array< uint8, 16 > Seed
Definition: Warden.h:68
uint8 Command
Definition: Warden.h:67
std::array< uint8, 16 > ModuleKey
Definition: Warden.h:52
uint8 Command
Definition: Warden.h:50
uint32 Size
Definition: Warden.h:53
std::array< uint8, 16 > ModuleId
Definition: Warden.h:51