Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
Warden.h
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#ifndef SF_WARDEN_BASE_H
7#define SF_WARDEN_BASE_H
8
9#include "ARC4.h"
10#include "AuthDefines.h"
11#include "ByteBuffer.h"
12#include "WardenCheckMgr.h"
13#include <array>
14
16{
17 // Client->Server
21 WARDEN_CMSG_MEM_CHECKS_RESULT = 3, // only sent if MEM_CHECK bytes doesn't match
23 WARDEN_CMSG_MODULE_FAILED = 5, // this is sent when client failed to load uploaded module due to cache fail
24
25 // Server->Client
30 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]; }
32};
33
35{
36 MEM_CHECK = 0xF3, // 243: byte moduleNameIndex + uint Offset + byte Len (check to ensure memory isn't modified)
37 PAGE_CHECK_A = 0xB2, // 178: uint Seed + byte[20] SHA1 + uint Addr + byte Len (scans all pages for specified hash)
38 PAGE_CHECK_B = 0xBF, // 191: uint Seed + byte[20] SHA1 + uint Addr + byte Len (scans only pages starts with MZ+PE headers for specified hash)
39 MPQ_CHECK = 0x98, // 152: byte fileNameIndex (check to ensure MPQ file isn't modified)
40 LUA_STR_CHECK = 0x8B, // 139: byte luaNameIndex (check to ensure LUA string isn't used)
41 DRIVER_CHECK = 0x71, // 113: uint Seed + byte[20] SHA1 + byte driverNameIndex (check to ensure driver isn't loaded)
42 TIMING_CHECK = 0x57, // 87: empty (check to ensure GetTickCount() isn't detoured)
43 PROC_CHECK = 0x7E, // 126: uint Seed + byte[20] SHA1 + byte moluleNameIndex + byte procNameIndex + uint Offset + byte Len (check to ensure proc isn't detoured)
44 MODULE_CHECK = 0xD9 // 217: uint Seed + byte[20] SHA1 (check to ensure module isn't injected)
45};
46
47#if defined(__GNUC__)
48#pragma pack(1)
49#else
50#pragma pack(push, 1)
51#endif
52
60
67
73
74#if defined(__GNUC__)
75#pragma pack()
76#else
77#pragma pack(pop)
78#endif
79
87
88class WorldSession;
89
90class Warden
91{
92 friend class WardenWin;
93 friend class WardenMac;
94
95public:
96 Warden();
97 virtual ~Warden();
98
99 virtual void Init(WorldSession* session, SessionKey const& k) = 0;
101 virtual void InitializeModule() = 0;
102 virtual void RequestHash() = 0;
103 virtual void HandleHashResult(ByteBuffer& buff) = 0;
104 virtual void RequestData() = 0;
105 virtual void HandleData(ByteBuffer& buff) = 0;
106
107 void SendModuleToClient();
108 void RequestModule();
109 void Update();
110 void DecryptData(uint8* buffer, uint32 length);
111 void EncryptData(uint8* buffer, uint32 length);
112
113 static bool IsValidCheckSum(uint32 checksum, const uint8* data, const uint16 length);
114 static uint32 BuildChecksum(const uint8* data, uint32 length);
115
116 // If no check is passed, the default action from config is executed
117 std::string Penalty(WardenCheck* check = NULL);
118
119private:
121 uint8 _inputKey[16] = { };
122 uint8 _outputKey[16] = { };
123 uint8 _seed[16] = { };
126 uint32 _checkTimer; // Timer for sending check requests
127 uint32 _clientResponseTimer; // Timer for client response delay
132};
133
134#endif
std::array< uint8, SESSION_KEY_LENGTH > SessionKey
Definition AuthDefines.h:8
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
std::uint16_t uint16
Definition Define.h:78
WardenCheckType
Definition Warden.h:35
@ PROC_CHECK
Definition Warden.h:43
@ DRIVER_CHECK
Definition Warden.h:41
@ PAGE_CHECK_A
Definition Warden.h:37
@ PAGE_CHECK_B
Definition Warden.h:38
@ MPQ_CHECK
Definition Warden.h:39
@ MEM_CHECK
Definition Warden.h:36
@ TIMING_CHECK
Definition Warden.h:42
@ MODULE_CHECK
Definition Warden.h:44
@ LUA_STR_CHECK
Definition Warden.h:40
WardenOpcodes
Definition Warden.h:16
@ WARDEN_CMSG_MODULE_MISSING
Definition Warden.h:18
@ WARDEN_SMSG_MEM_CHECKS_REQUEST
Definition Warden.h:30
@ WARDEN_CMSG_HASH_RESULT
Definition Warden.h:22
@ WARDEN_CMSG_MODULE_FAILED
Definition Warden.h:23
@ WARDEN_SMSG_HASH_REQUEST
Definition Warden.h:31
@ WARDEN_CMSG_CHEAT_CHECKS_RESULT
Definition Warden.h:20
@ WARDEN_CMSG_MODULE_OK
Definition Warden.h:19
@ WARDEN_SMSG_MODULE_CACHE
Definition Warden.h:27
@ WARDEN_SMSG_MODULE_INITIALIZE
Definition Warden.h:29
@ WARDEN_SMSG_MODULE_USE
Definition Warden.h:26
@ WARDEN_CMSG_MEM_CHECKS_RESULT
Definition Warden.h:21
@ WARDEN_SMSG_CHEAT_CHECKS_REQUEST
Definition Warden.h:28
Warden()
Definition Warden.cpp:20
void EncryptData(uint8 *buffer, uint32 length)
Definition Warden.cpp:118
uint32 _checkTimer
Definition Warden.h:126
void DecryptData(uint8 *buffer, uint32 length)
Definition Warden.cpp:113
SkyFire::Crypto::ARC4 _outputCrypto
Definition Warden.h:125
uint32 _clientResponseTimer
Definition Warden.h:127
SkyFire::Crypto::ARC4 _inputCrypto
Definition Warden.h:124
uint8 _inputKey[16]
Definition Warden.h:121
uint32 _previousTimestamp
Definition Warden.h:129
uint8 _outputKey[16]
Definition Warden.h:122
uint8 _seed[16]
Definition Warden.h:123
virtual void RequestHash()=0
void RequestModule()
Definition Warden.cpp:56
ClientWardenModule * _module
Definition Warden.h:130
void Update()
Definition Warden.cpp:76
friend class WardenWin
Definition Warden.h:92
virtual void HandleData(ByteBuffer &buff)=0
virtual ClientWardenModule * GetModuleForClient()=0
static bool IsValidCheckSum(uint32 checksum, const uint8 *data, const uint16 length)
Definition Warden.cpp:123
void SendModuleToClient()
Definition Warden.cpp:30
bool _dataSent
Definition Warden.h:128
virtual void InitializeModule()=0
bool _initialized
Definition Warden.h:131
friend class WardenMac
Definition Warden.h:93
static uint32 BuildChecksum(const uint8 *data, uint32 length)
Definition Warden.cpp:154
virtual void Init(WorldSession *session, SessionKey const &k)=0
std::string Penalty(WardenCheck *check=NULL)
Definition Warden.cpp:165
virtual void RequestData()=0
WorldSession * _session
Definition Warden.h:120
virtual void HandleHashResult(ByteBuffer &buff)=0
virtual ~Warden()
Definition Warden.cpp:22
Player session in the World.
uint8 * CompressedData
Definition Warden.h:85
uint8 Id[16]
Definition Warden.h:82
uint32 CompressedSize
Definition Warden.h:84
uint8 Key[16]
Definition Warden.h:83
uint8 Seed[16]
Definition Warden.h:71
uint8 Data[500]
Definition Warden.h:65
uint8 Command
Definition Warden.h:55
uint32 Size
Definition Warden.h:58
uint8 ModuleId[16]
Definition Warden.h:56
uint8 ModuleKey[16]
Definition Warden.h:57