Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
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
15
enum
WardenOpcodes
16
{
17
// Client->Server
18
WARDEN_CMSG_MODULE_MISSING
= 0,
19
WARDEN_CMSG_MODULE_OK
= 1,
20
WARDEN_CMSG_CHEAT_CHECKS_RESULT
= 2,
21
WARDEN_CMSG_MEM_CHECKS_RESULT
= 3,
// only sent if MEM_CHECK bytes doesn't match
22
WARDEN_CMSG_HASH_RESULT
= 4,
23
WARDEN_CMSG_MODULE_FAILED
= 5,
// this is sent when client failed to load uploaded module due to cache fail
24
25
// Server->Client
26
WARDEN_SMSG_MODULE_USE
= 0,
27
WARDEN_SMSG_MODULE_CACHE
= 1,
28
WARDEN_SMSG_CHEAT_CHECKS_REQUEST
= 2,
29
WARDEN_SMSG_MODULE_INITIALIZE
= 3,
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]; }
31
WARDEN_SMSG_HASH_REQUEST
= 5
32
};
33
34
enum
WardenCheckType
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
53
struct
WardenModuleUse
54
{
55
uint8
Command
;
56
uint8
ModuleId
[16];
57
uint8
ModuleKey
[16];
58
uint32
Size
;
59
};
60
61
struct
WardenModuleTransfer
62
{
63
uint8
Command
;
64
uint16
DataSize
;
65
uint8
Data
[500];
66
};
67
68
struct
WardenHashRequest
69
{
70
uint8
Command
;
71
uint8
Seed
[16];
72
};
73
74
#if defined(__GNUC__)
75
#pragma pack()
76
#else
77
#pragma pack(pop)
78
#endif
79
80
struct
ClientWardenModule
81
{
82
uint8
Id
[16];
83
uint8
Key
[16];
84
uint32
CompressedSize
;
85
uint8
*
CompressedData
;
86
};
87
88
class
WorldSession
;
89
90
class
Warden
91
{
92
friend
class
WardenWin
;
93
friend
class
WardenMac
;
94
95
public
:
96
Warden
();
97
virtual
~Warden
();
98
99
virtual
void
Init
(
WorldSession
* session,
SessionKey
const
& k) = 0;
100
virtual
ClientWardenModule
*
GetModuleForClient
() = 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
119
private
:
120
WorldSession
*
_session
;
121
uint8
_inputKey
[16] = { };
122
uint8
_outputKey
[16] = { };
123
uint8
_seed
[16] = { };
124
SkyFire::Crypto::ARC4
_inputCrypto
;
125
SkyFire::Crypto::ARC4
_outputCrypto
;
126
uint32
_checkTimer
;
// Timer for sending check requests
127
uint32
_clientResponseTimer
;
// Timer for client response delay
128
bool
_dataSent
;
129
uint32
_previousTimestamp
;
130
ClientWardenModule
*
_module
;
131
bool
_initialized
;
132
};
133
134
#endif
ARC4.h
AuthDefines.h
SessionKey
std::array< uint8, SESSION_KEY_LENGTH > SessionKey
Definition
AuthDefines.h:8
ByteBuffer.h
uint8
std::uint8_t uint8
Definition
Define.h:79
uint32
std::uint32_t uint32
Definition
Define.h:77
uint16
std::uint16_t uint16
Definition
Define.h:78
WardenCheckType
WardenCheckType
Definition
Warden.h:35
PROC_CHECK
@ PROC_CHECK
Definition
Warden.h:43
DRIVER_CHECK
@ DRIVER_CHECK
Definition
Warden.h:41
PAGE_CHECK_A
@ PAGE_CHECK_A
Definition
Warden.h:37
PAGE_CHECK_B
@ PAGE_CHECK_B
Definition
Warden.h:38
MPQ_CHECK
@ MPQ_CHECK
Definition
Warden.h:39
MEM_CHECK
@ MEM_CHECK
Definition
Warden.h:36
TIMING_CHECK
@ TIMING_CHECK
Definition
Warden.h:42
MODULE_CHECK
@ MODULE_CHECK
Definition
Warden.h:44
LUA_STR_CHECK
@ LUA_STR_CHECK
Definition
Warden.h:40
WardenOpcodes
WardenOpcodes
Definition
Warden.h:16
WARDEN_CMSG_MODULE_MISSING
@ WARDEN_CMSG_MODULE_MISSING
Definition
Warden.h:18
WARDEN_SMSG_MEM_CHECKS_REQUEST
@ WARDEN_SMSG_MEM_CHECKS_REQUEST
Definition
Warden.h:30
WARDEN_CMSG_HASH_RESULT
@ WARDEN_CMSG_HASH_RESULT
Definition
Warden.h:22
WARDEN_CMSG_MODULE_FAILED
@ WARDEN_CMSG_MODULE_FAILED
Definition
Warden.h:23
WARDEN_SMSG_HASH_REQUEST
@ WARDEN_SMSG_HASH_REQUEST
Definition
Warden.h:31
WARDEN_CMSG_CHEAT_CHECKS_RESULT
@ WARDEN_CMSG_CHEAT_CHECKS_RESULT
Definition
Warden.h:20
WARDEN_CMSG_MODULE_OK
@ WARDEN_CMSG_MODULE_OK
Definition
Warden.h:19
WARDEN_SMSG_MODULE_CACHE
@ WARDEN_SMSG_MODULE_CACHE
Definition
Warden.h:27
WARDEN_SMSG_MODULE_INITIALIZE
@ WARDEN_SMSG_MODULE_INITIALIZE
Definition
Warden.h:29
WARDEN_SMSG_MODULE_USE
@ WARDEN_SMSG_MODULE_USE
Definition
Warden.h:26
WARDEN_CMSG_MEM_CHECKS_RESULT
@ WARDEN_CMSG_MEM_CHECKS_RESULT
Definition
Warden.h:21
WARDEN_SMSG_CHEAT_CHECKS_REQUEST
@ WARDEN_SMSG_CHEAT_CHECKS_REQUEST
Definition
Warden.h:28
WardenCheckMgr.h
ByteBuffer
Definition
ByteBuffer.h:120
SkyFire::Crypto::ARC4
Definition
ARC4.h:17
Warden::Warden
Warden()
Definition
Warden.cpp:20
Warden::EncryptData
void EncryptData(uint8 *buffer, uint32 length)
Definition
Warden.cpp:118
Warden::_checkTimer
uint32 _checkTimer
Definition
Warden.h:126
Warden::DecryptData
void DecryptData(uint8 *buffer, uint32 length)
Definition
Warden.cpp:113
Warden::_outputCrypto
SkyFire::Crypto::ARC4 _outputCrypto
Definition
Warden.h:125
Warden::_clientResponseTimer
uint32 _clientResponseTimer
Definition
Warden.h:127
Warden::_inputCrypto
SkyFire::Crypto::ARC4 _inputCrypto
Definition
Warden.h:124
Warden::_inputKey
uint8 _inputKey[16]
Definition
Warden.h:121
Warden::_previousTimestamp
uint32 _previousTimestamp
Definition
Warden.h:129
Warden::_outputKey
uint8 _outputKey[16]
Definition
Warden.h:122
Warden::_seed
uint8 _seed[16]
Definition
Warden.h:123
Warden::RequestHash
virtual void RequestHash()=0
Warden::RequestModule
void RequestModule()
Definition
Warden.cpp:56
Warden::_module
ClientWardenModule * _module
Definition
Warden.h:130
Warden::Update
void Update()
Definition
Warden.cpp:76
Warden::WardenWin
friend class WardenWin
Definition
Warden.h:92
Warden::HandleData
virtual void HandleData(ByteBuffer &buff)=0
Warden::GetModuleForClient
virtual ClientWardenModule * GetModuleForClient()=0
Warden::IsValidCheckSum
static bool IsValidCheckSum(uint32 checksum, const uint8 *data, const uint16 length)
Definition
Warden.cpp:123
Warden::SendModuleToClient
void SendModuleToClient()
Definition
Warden.cpp:30
Warden::_dataSent
bool _dataSent
Definition
Warden.h:128
Warden::InitializeModule
virtual void InitializeModule()=0
Warden::_initialized
bool _initialized
Definition
Warden.h:131
Warden::WardenMac
friend class WardenMac
Definition
Warden.h:93
Warden::BuildChecksum
static uint32 BuildChecksum(const uint8 *data, uint32 length)
Definition
Warden.cpp:154
Warden::Init
virtual void Init(WorldSession *session, SessionKey const &k)=0
Warden::Penalty
std::string Penalty(WardenCheck *check=NULL)
Definition
Warden.cpp:165
Warden::RequestData
virtual void RequestData()=0
Warden::_session
WorldSession * _session
Definition
Warden.h:120
Warden::HandleHashResult
virtual void HandleHashResult(ByteBuffer &buff)=0
Warden::~Warden
virtual ~Warden()
Definition
Warden.cpp:22
WorldSession
Player session in the World.
Definition
WorldSession.h:254
ClientWardenModule
Definition
Warden.h:81
ClientWardenModule::CompressedData
uint8 * CompressedData
Definition
Warden.h:85
ClientWardenModule::Id
uint8 Id[16]
Definition
Warden.h:82
ClientWardenModule::CompressedSize
uint32 CompressedSize
Definition
Warden.h:84
ClientWardenModule::Key
uint8 Key[16]
Definition
Warden.h:83
WardenCheck
Definition
WardenCheckMgr.h:21
WardenHashRequest
Definition
Warden.h:69
WardenHashRequest::Seed
uint8 Seed[16]
Definition
Warden.h:71
WardenHashRequest::Command
uint8 Command
Definition
Warden.h:70
WardenModuleTransfer
Definition
Warden.h:62
WardenModuleTransfer::DataSize
uint16 DataSize
Definition
Warden.h:64
WardenModuleTransfer::Command
uint8 Command
Definition
Warden.h:63
WardenModuleTransfer::Data
uint8 Data[500]
Definition
Warden.h:65
WardenModuleUse
Definition
Warden.h:54
WardenModuleUse::Command
uint8 Command
Definition
Warden.h:55
WardenModuleUse::Size
uint32 Size
Definition
Warden.h:58
WardenModuleUse::ModuleId
uint8 ModuleId[16]
Definition
Warden.h:56
WardenModuleUse::ModuleKey
uint8 ModuleKey[16]
Definition
Warden.h:57
src
server
game
Warden
Warden.h
Generated on
for Project SkyFire Core by
1.17.0