TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
WardenWin Class Reference

#include <WardenWin.h>

Public Member Functions

 WardenWin ()
 
 ~WardenWin ()
 
void Init (WorldSession *session, BigNumber *K) override
 
ClientWardenModuleGetModuleForClient () override
 
void InitializeModule () override
 
void RequestHash () override
 
void HandleHashResult (ByteBuffer &buff) override
 
void RequestData () override
 
void HandleData (ByteBuffer &buff) override
 
- Public Member Functions inherited from Warden
 Warden ()
 
virtual ~Warden ()
 
void SendModuleToClient ()
 
void RequestModule ()
 
void Update ()
 
void DecryptData (uint8 *buffer, uint32 length)
 
void EncryptData (uint8 *buffer, uint32 length)
 
std::string Penalty (WardenCheck *check=NULL)
 

Private Attributes

uint32 _serverTicks
 
std::list< uint16_otherChecksTodo
 
std::list< uint16_memChecksTodo
 
std::list< uint16_currentChecks
 

Additional Inherited Members

- Static Public Member Functions inherited from Warden
static bool IsValidCheckSum (uint32 checksum, const uint8 *data, const uint16 length)
 
static uint32 BuildChecksum (const uint8 *data, uint32 length)
 

Constructor & Destructor Documentation

WardenWin::WardenWin ( )
38 : Warden(), _serverTicks(0) {}
Warden()
Definition: Warden.cpp:33
uint32 _serverTicks
Definition: WardenWin.h:80
WardenWin::~WardenWin ( )
40 { }

Member Function Documentation

ClientWardenModule * WardenWin::GetModuleForClient ( )
overridevirtual

Implements Warden.

68 {
70 
71  uint32 length = sizeof(Module.Module);
72 
73  // data assign
74  mod->CompressedSize = length;
75  mod->CompressedData = new uint8[length];
76  memcpy(mod->CompressedData, Module.Module, length);
77  memcpy(mod->Key, Module.ModuleKey, 16);
78 
79  // md5 hash
80  MD5_CTX ctx;
81  MD5_Init(&ctx);
82  MD5_Update(&ctx, mod->CompressedData, length);
83  MD5_Final((uint8*)&mod->Id, &ctx);
84 
85  return mod;
86 }
uint8 ModuleKey[16]
Definition: WardenModuleWin.h:33
uint8 Id[16]
Definition: Warden.h:87
uint32 CompressedSize
Definition: Warden.h:89
uint8 Key[16]
Definition: Warden.h:88
uint8 * CompressedData
Definition: Warden.h:90
uint8 Module[18756]
Definition: WardenModuleWin.h:32
struct Module_79C0768D657977D697E10BAD956CCED1 Module
uint32_t uint32
Definition: Define.h:150
float length(float v)
Definition: vectorMath.h:208
uint8_t uint8
Definition: Define.h:152
Definition: Warden.h:85

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WardenWin::HandleData ( ByteBuffer buff)
overridevirtual
Todo:
test it.

Implements Warden.

327 {
328  TC_LOG_DEBUG("warden", "Handle data");
329 
330  _dataSent = false;
332 
333  uint16 Length;
334  buff >> Length;
335  uint32 Checksum;
336  buff >> Checksum;
337 
338  if (!IsValidCheckSum(Checksum, buff.contents() + buff.rpos(), Length))
339  {
340  buff.rpos(buff.wpos());
341  TC_LOG_WARN("warden", "%s failed checksum. Action: %s", _session->GetPlayerInfo().c_str(), Penalty().c_str());
342  return;
343  }
344 
345  // TIMING_CHECK
346  {
347  uint8 result;
348  buff >> result;
350  if (result == 0x00)
351  {
352  TC_LOG_WARN("warden", "%s failed timing check. Action: %s", _session->GetPlayerInfo().c_str(), Penalty().c_str());
353  return;
354  }
355 
356  uint32 newClientTicks;
357  buff >> newClientTicks;
358 
359  uint32 ticksNow = getMSTime();
360  uint32 ourTicks = newClientTicks + (ticksNow - _serverTicks);
361 
362  TC_LOG_DEBUG("warden", "ServerTicks %u", ticksNow); // Now
363  TC_LOG_DEBUG("warden", "RequestTicks %u", _serverTicks); // At request
364  TC_LOG_DEBUG("warden", "Ticks %u", newClientTicks); // At response
365  TC_LOG_DEBUG("warden", "Ticks diff %u", ourTicks - newClientTicks);
366  }
367 
368  WardenCheckResult* rs;
369  WardenCheck *rd;
370  uint8 type;
371  uint16 checkFailed = 0;
372 
373  boost::shared_lock<boost::shared_mutex> lock(sWardenCheckMgr->_checkStoreLock);
374 
375  for (std::list<uint16>::iterator itr = _currentChecks.begin(); itr != _currentChecks.end(); ++itr)
376  {
377  rd = sWardenCheckMgr->GetWardenDataById(*itr);
378  rs = sWardenCheckMgr->GetWardenResultById(*itr);
379 
380  type = rd->Type;
381  switch (type)
382  {
383  case MEM_CHECK:
384  {
385  uint8 Mem_Result;
386  buff >> Mem_Result;
387 
388  if (Mem_Result != 0)
389  {
390  TC_LOG_DEBUG("warden", "RESULT MEM_CHECK not 0x00, CheckId %u account Id %u", *itr, _session->GetAccountId());
391  checkFailed = *itr;
392  continue;
393  }
394 
395  if (memcmp(buff.contents() + buff.rpos(), rs->Result.AsByteArray(0, false).get(), rd->Length) != 0)
396  {
397  TC_LOG_DEBUG("warden", "RESULT MEM_CHECK fail CheckId %u account Id %u", *itr, _session->GetAccountId());
398  checkFailed = *itr;
399  buff.rpos(buff.rpos() + rd->Length);
400  continue;
401  }
402 
403  buff.rpos(buff.rpos() + rd->Length);
404  TC_LOG_DEBUG("warden", "RESULT MEM_CHECK passed CheckId %u account Id %u", *itr, _session->GetAccountId());
405  break;
406  }
407  case PAGE_CHECK_A:
408  case PAGE_CHECK_B:
409  case DRIVER_CHECK:
410  case MODULE_CHECK:
411  {
412  const uint8 byte = 0xE9;
413  if (memcmp(buff.contents() + buff.rpos(), &byte, sizeof(uint8)) != 0)
414  {
415  if (type == PAGE_CHECK_A || type == PAGE_CHECK_B)
416  TC_LOG_DEBUG("warden", "RESULT PAGE_CHECK fail, CheckId %u account Id %u", *itr, _session->GetAccountId());
417  if (type == MODULE_CHECK)
418  TC_LOG_DEBUG("warden", "RESULT MODULE_CHECK fail, CheckId %u account Id %u", *itr, _session->GetAccountId());
419  if (type == DRIVER_CHECK)
420  TC_LOG_DEBUG("warden", "RESULT DRIVER_CHECK fail, CheckId %u account Id %u", *itr, _session->GetAccountId());
421  checkFailed = *itr;
422  buff.rpos(buff.rpos() + 1);
423  continue;
424  }
425 
426  buff.rpos(buff.rpos() + 1);
427  if (type == PAGE_CHECK_A || type == PAGE_CHECK_B)
428  TC_LOG_DEBUG("warden", "RESULT PAGE_CHECK passed CheckId %u account Id %u", *itr, _session->GetAccountId());
429  else if (type == MODULE_CHECK)
430  TC_LOG_DEBUG("warden", "RESULT MODULE_CHECK passed CheckId %u account Id %u", *itr, _session->GetAccountId());
431  else if (type == DRIVER_CHECK)
432  TC_LOG_DEBUG("warden", "RESULT DRIVER_CHECK passed CheckId %u account Id %u", *itr, _session->GetAccountId());
433  break;
434  }
435  case LUA_STR_CHECK:
436  {
437  uint8 Lua_Result;
438  buff >> Lua_Result;
439 
440  if (Lua_Result != 0)
441  {
442  TC_LOG_DEBUG("warden", "RESULT LUA_STR_CHECK fail, CheckId %u account Id %u", *itr, _session->GetAccountId());
443  checkFailed = *itr;
444  continue;
445  }
446 
447  uint8 luaStrLen;
448  buff >> luaStrLen;
449 
450  if (luaStrLen != 0)
451  {
452  char *str = new char[luaStrLen + 1];
453  memcpy(str, buff.contents() + buff.rpos(), luaStrLen);
454  str[luaStrLen] = '\0'; // null terminator
455  TC_LOG_DEBUG("warden", "Lua string: %s", str);
456  delete[] str;
457  }
458  buff.rpos(buff.rpos() + luaStrLen); // Skip string
459  TC_LOG_DEBUG("warden", "RESULT LUA_STR_CHECK passed, CheckId %u account Id %u", *itr, _session->GetAccountId());
460  break;
461  }
462  case MPQ_CHECK:
463  {
464  uint8 Mpq_Result;
465  buff >> Mpq_Result;
466 
467  if (Mpq_Result != 0)
468  {
469  TC_LOG_DEBUG("warden", "RESULT MPQ_CHECK not 0x00 account id %u", _session->GetAccountId());
470  checkFailed = *itr;
471  continue;
472  }
473 
474  if (memcmp(buff.contents() + buff.rpos(), rs->Result.AsByteArray(0, false).get(), 20) != 0) // SHA1
475  {
476  TC_LOG_DEBUG("warden", "RESULT MPQ_CHECK fail, CheckId %u account Id %u", *itr, _session->GetAccountId());
477  checkFailed = *itr;
478  buff.rpos(buff.rpos() + 20); // 20 bytes SHA1
479  continue;
480  }
481 
482  buff.rpos(buff.rpos() + 20); // 20 bytes SHA1
483  TC_LOG_DEBUG("warden", "RESULT MPQ_CHECK passed, CheckId %u account Id %u", *itr, _session->GetAccountId());
484  break;
485  }
486  default: // Should never happen
487  break;
488  }
489  }
490 
491  if (checkFailed > 0)
492  {
493  WardenCheck* check = sWardenCheckMgr->GetWardenDataById(checkFailed);
494  TC_LOG_WARN("warden", "%s failed Warden check %u. Action: %s", _session->GetPlayerInfo().c_str(), checkFailed, Penalty(check).c_str());
495  }
496 
497  // Set hold off timer, minimum timer should at least be 1 second
498  uint32 holdOff = sWorld->getIntConfig(CONFIG_WARDEN_CLIENT_CHECK_HOLDOFF);
499  _checkTimer = (holdOff < 1 ? 1 : holdOff) * IN_MILLISECONDS;
500 }
uint8 * contents()
Definition: ByteBuffer.h:573
uint32 _clientResponseTimer
Definition: Warden.h:132
uint8 Length
Definition: WardenCheckMgr.h:39
Definition: WardenCheckMgr.h:46
Definition: Warden.h:54
Definition: Warden.h:51
BigNumber Result
Definition: WardenCheckMgr.h:48
uint8 Type
Definition: WardenCheckMgr.h:36
uint32 getMSTime()
Definition: Timer.h:24
std::string Penalty(WardenCheck *check=NULL)
Definition: Warden.cpp:184
bool _dataSent
Definition: Warden.h:133
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Warden.h:53
uint32 GetAccountId() const
Definition: WorldSession.h:922
#define sWorld
Definition: World.h:887
#define byte(x, n)
Definition: tomcrypt_macros.h:419
Definition: Warden.h:57
std::list< uint16 > _currentChecks
Definition: WardenWin.h:83
size_t wpos() const
Definition: ByteBuffer.h:454
Definition: Warden.h:52
Definition: Warden.h:50
uint32_t uint32
Definition: Define.h:150
uint16_t uint16
Definition: Define.h:151
WorldSession * _session
Definition: Warden.h:125
uint32 _serverTicks
Definition: WardenWin.h:80
Definition: World.h:345
uint8_t uint8
Definition: g3dmath.h:164
Definition: Common.h:103
#define sWardenCheckMgr
Definition: WardenCheckMgr.h:80
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
std::unique_ptr< uint8[]> AsByteArray(int32 minSize=0, bool littleEndian=true)
Definition: BigNumber.cpp:177
#define TC_LOG_WARN(filterType__,...)
Definition: Log.h:204
uint8_t uint8
Definition: Define.h:152
static bool IsValidCheckSum(uint32 checksum, const uint8 *data, const uint16 length)
Definition: Warden.cpp:142
uint32 _checkTimer
Definition: Warden.h:131
Definition: WardenCheckMgr.h:34
T check(T value)
Definition: format.h:305
size_t rpos() const
Definition: ByteBuffer.h:441
Definition: Warden.h:49

+ Here is the call graph for this function:

void WardenWin::HandleHashResult ( ByteBuffer buff)
overridevirtual

Implements Warden.

150 {
151  buff.rpos(buff.wpos());
152 
153  // Verify key
154  if (memcmp(buff.contents() + 1, Module.ClientKeySeedHash, 20) != 0)
155  {
156  TC_LOG_WARN("warden", "%s failed hash reply. Action: %s", _session->GetPlayerInfo().c_str(), Penalty().c_str());
157  return;
158  }
159 
160  TC_LOG_DEBUG("warden", "Request hash reply: succeed");
161 
162  // Change keys here
163  memcpy(_inputKey, Module.ClientKeySeed, 16);
164  memcpy(_outputKey, Module.ServerKeySeed, 16);
165 
168 
169  _initialized = true;
170 
172 }
uint8 * contents()
Definition: ByteBuffer.h:573
uint8 ClientKeySeedHash[20]
Definition: WardenModuleWin.h:37
uint32 _previousTimestamp
Definition: Warden.h:134
uint32 getMSTime()
Definition: Timer.h:24
std::string Penalty(WardenCheck *check=NULL)
Definition: Warden.cpp:184
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint8 ClientKeySeed[16]
Definition: WardenModuleWin.h:36
size_t wpos() const
Definition: ByteBuffer.h:454
void Init(uint8 *seed)
Definition: ARC4.cpp:42
struct Module_79C0768D657977D697E10BAD956CCED1 Module
WorldSession * _session
Definition: Warden.h:125
uint8 _outputKey[16]
Definition: Warden.h:127
ARC4 _outputCrypto
Definition: Warden.h:130
ARC4 _inputCrypto
Definition: Warden.h:129
uint8 _inputKey[16]
Definition: Warden.h:126
bool _initialized
Definition: Warden.h:136
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
#define TC_LOG_WARN(filterType__,...)
Definition: Log.h:204
size_t rpos() const
Definition: ByteBuffer.h:441
uint8 ServerKeySeed[16]
Definition: WardenModuleWin.h:35

+ Here is the call graph for this function:

void WardenWin::Init ( WorldSession session,
BigNumber K 
)
overridevirtual

Implements Warden.

43 {
44  _session = session;
45  // Generate Warden Key
46  SessionKeyGenerator<SHA1Hash> WK(k->AsByteArray().get(), k->GetNumBytes());
47  WK.Generate(_inputKey, 16);
48  WK.Generate(_outputKey, 16);
49 
50  memcpy(_seed, Module.Seed, 16);
51 
54  TC_LOG_DEBUG("warden", "Server side warden for client %u initializing...", session->GetAccountId());
55  TC_LOG_DEBUG("warden", "C->S Key: %s", ByteArrayToHexStr(_inputKey, 16).c_str());
56  TC_LOG_DEBUG("warden", "S->C Key: %s", ByteArrayToHexStr(_outputKey, 16).c_str());
57  TC_LOG_DEBUG("warden", " Seed: %s", ByteArrayToHexStr(_seed, 16).c_str());
58  TC_LOG_DEBUG("warden", "Loading Module...");
59 
61 
62  TC_LOG_DEBUG("warden", "Module Key: %s", ByteArrayToHexStr(_module->Key, 16).c_str());
63  TC_LOG_DEBUG("warden", "Module ID: %s", ByteArrayToHexStr(_module->Id, 16).c_str());
64  RequestModule();
65 }
void Generate(uint8 *buf, uint32 sz)
Definition: SessionKeyGeneration.h:49
ClientWardenModule * _module
Definition: Warden.h:135
uint8 Id[16]
Definition: Warden.h:87
uint8 Key[16]
Definition: Warden.h:88
Definition: SessionKeyGeneration.h:25
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 GetAccountId() const
Definition: WorldSession.h:922
uint8 _seed[16]
Definition: Warden.h:128
void Init(uint8 *seed)
Definition: ARC4.cpp:42
struct Module_79C0768D657977D697E10BAD956CCED1 Module
WorldSession * _session
Definition: Warden.h:125
void RequestModule()
Definition: Warden.cpp:75
ClientWardenModule * GetModuleForClient() override
Definition: WardenWin.cpp:67
uint8 _outputKey[16]
Definition: Warden.h:127
uint8 Seed[16]
Definition: WardenModuleWin.h:34
ARC4 _outputCrypto
Definition: Warden.h:130
ARC4 _inputCrypto
Definition: Warden.h:129
std::string ByteArrayToHexStr(uint8 const *bytes, uint32 arrayLen, bool reverse)
Definition: Util.cpp:509
uint8 _inputKey[16]
Definition: Warden.h:126

+ Here is the call graph for this function:

void WardenWin::InitializeModule ( )
overridevirtual

Implements Warden.

89 {
90  TC_LOG_DEBUG("warden", "Initialize module");
91 
92  // Create packet structure
95  Request.Size1 = 20;
96  Request.Unk1 = 1;
97  Request.Unk2 = 0;
98  Request.Type = 1;
99  Request.String_library1 = 0;
100  Request.Function1[0] = 0x00024F80; // 0x00400000 + 0x00024F80 SFileOpenFile
101  Request.Function1[1] = 0x000218C0; // 0x00400000 + 0x000218C0 SFileGetFileSize
102  Request.Function1[2] = 0x00022530; // 0x00400000 + 0x00022530 SFileReadFile
103  Request.Function1[3] = 0x00022910; // 0x00400000 + 0x00022910 SFileCloseFile
104  Request.CheckSumm1 = BuildChecksum(&Request.Unk1, 20);
105 
107  Request.Size2 = 8;
108  Request.Unk3 = 4;
109  Request.Unk4 = 0;
110  Request.String_library2 = 0;
111  Request.Function2 = 0x00419D40; // 0x00400000 + 0x00419D40 FrameScript::GetText
112  Request.Function2_set = 1;
113  Request.CheckSumm2 = BuildChecksum(&Request.Unk2, 8);
114 
116  Request.Size3 = 8;
117  Request.Unk5 = 1;
118  Request.Unk6 = 1;
119  Request.String_library3 = 0;
120  Request.Function3 = 0x0046AE20; // 0x00400000 + 0x0046AE20 PerformanceCounter
121  Request.Function3_set = 1;
122  Request.CheckSumm3 = BuildChecksum(&Request.Unk5, 8);
123 
124  // Encrypt with warden RC4 key.
125  EncryptData((uint8*)&Request, sizeof(WardenInitModuleRequest));
126 
128  pkt.append((uint8*)&Request, sizeof(WardenInitModuleRequest));
129  _session->SendPacket(&pkt);
130 }
uint8 Command2
Definition: WardenWin.h:41
uint8 Function2_set
Definition: WardenWin.h:48
uint8 Unk1
Definition: WardenWin.h:35
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
static uint32 BuildChecksum(const uint8 *data, uint32 length)
Definition: Warden.cpp:173
uint8 Command1
Definition: WardenWin.h:32
uint16 Size3
Definition: WardenWin.h:51
uint32 Function3
Definition: WardenWin.h:56
uint32 CheckSumm2
Definition: WardenWin.h:43
uint8 Unk3
Definition: WardenWin.h:44
uint8 Unk4
Definition: WardenWin.h:45
uint8 Unk5
Definition: WardenWin.h:53
uint32 CheckSumm3
Definition: WardenWin.h:52
Definition: Warden.h:42
void EncryptData(uint8 *buffer, uint32 length)
Definition: Warden.cpp:137
WorldSession * _session
Definition: Warden.h:125
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint16 Size2
Definition: WardenWin.h:42
uint8 Function3_set
Definition: WardenWin.h:57
uint8 Unk2
Definition: WardenWin.h:36
uint8 String_library1
Definition: WardenWin.h:38
uint16 Size1
Definition: WardenWin.h:33
uint8 String_library3
Definition: WardenWin.h:55
uint8 Unk6
Definition: WardenWin.h:54
uint8_t uint8
Definition: Define.h:152
uint32 Function2
Definition: WardenWin.h:47
uint8 Type
Definition: WardenWin.h:37
uint8 String_library2
Definition: WardenWin.h:46
uint8 Command3
Definition: WardenWin.h:50
Definition: WardenWin.h:30
Definition: Opcodes.h:1623
Definition: WorldPacket.h:26
uint32 CheckSumm1
Definition: WardenWin.h:34
uint32 Function1[4]
Definition: WardenWin.h:39

+ Here is the call graph for this function:

void WardenWin::RequestData ( )
overridevirtual

Implements Warden.

175 {
176  TC_LOG_DEBUG("warden", "Request data");
177 
178  // If all checks were done, fill the todo list again
179  if (_memChecksTodo.empty())
180  _memChecksTodo.assign(sWardenCheckMgr->MemChecksIdPool.begin(), sWardenCheckMgr->MemChecksIdPool.end());
181 
182  if (_otherChecksTodo.empty())
183  _otherChecksTodo.assign(sWardenCheckMgr->OtherChecksIdPool.begin(), sWardenCheckMgr->OtherChecksIdPool.end());
184 
186 
187  uint16 id;
188  uint8 type;
189  WardenCheck* wd;
190  _currentChecks.clear();
191 
192  // Build check request
193  for (uint32 i = 0; i < sWorld->getIntConfig(CONFIG_WARDEN_NUM_MEM_CHECKS); ++i)
194  {
195  // If todo list is done break loop (will be filled on next Update() run)
196  if (_memChecksTodo.empty())
197  break;
198 
199  // Get check id from the end and remove it from todo
200  id = _memChecksTodo.back();
201  _memChecksTodo.pop_back();
202 
203  // Add the id to the list sent in this cycle
204  _currentChecks.push_back(id);
205  }
206 
207  ByteBuffer buff;
209 
210  boost::shared_lock<boost::shared_mutex> lock(sWardenCheckMgr->_checkStoreLock);
211 
212  for (uint32 i = 0; i < sWorld->getIntConfig(CONFIG_WARDEN_NUM_OTHER_CHECKS); ++i)
213  {
214  // If todo list is done break loop (will be filled on next Update() run)
215  if (_otherChecksTodo.empty())
216  break;
217 
218  // Get check id from the end and remove it from todo
219  id = _otherChecksTodo.back();
220  _otherChecksTodo.pop_back();
221 
222  // Add the id to the list sent in this cycle
223  _currentChecks.push_back(id);
224 
225  wd = sWardenCheckMgr->GetWardenDataById(id);
226 
227  switch (wd->Type)
228  {
229  case MPQ_CHECK:
230  case LUA_STR_CHECK:
231  case DRIVER_CHECK:
232  buff << uint8(wd->Str.size());
233  buff.append(wd->Str.c_str(), wd->Str.size());
234  break;
235  default:
236  break;
237  }
238  }
239 
240  uint8 xorByte = _inputKey[0];
241 
242  // Add TIMING_CHECK
243  buff << uint8(0x00);
244  buff << uint8(TIMING_CHECK ^ xorByte);
245 
246  uint8 index = 1;
247 
248  for (std::list<uint16>::iterator itr = _currentChecks.begin(); itr != _currentChecks.end(); ++itr)
249  {
250  wd = sWardenCheckMgr->GetWardenDataById(*itr);
251 
252  type = wd->Type;
253  buff << uint8(type ^ xorByte);
254  switch (type)
255  {
256  case MEM_CHECK:
257  {
258  buff << uint8(0x00);
259  buff << uint32(wd->Address);
260  buff << uint8(wd->Length);
261  break;
262  }
263  case PAGE_CHECK_A:
264  case PAGE_CHECK_B:
265  {
266  buff.append(wd->Data.AsByteArray(0, false).get(), wd->Data.GetNumBytes());
267  buff << uint32(wd->Address);
268  buff << uint8(wd->Length);
269  break;
270  }
271  case MPQ_CHECK:
272  case LUA_STR_CHECK:
273  {
274  buff << uint8(index++);
275  break;
276  }
277  case DRIVER_CHECK:
278  {
279  buff.append(wd->Data.AsByteArray(0, false).get(), wd->Data.GetNumBytes());
280  buff << uint8(index++);
281  break;
282  }
283  case MODULE_CHECK:
284  {
285  uint32 seed = rand32();
286  buff << uint32(seed);
287  HmacSha1 hmac(4, (uint8*)&seed);
288  hmac.UpdateData(wd->Str);
289  hmac.Finalize();
290  buff.append(hmac.GetDigest(), hmac.GetLength());
291  break;
292  }
293  /*case PROC_CHECK:
294  {
295  buff.append(wd->i.AsByteArray(0, false).get(), wd->i.GetNumBytes());
296  buff << uint8(index++);
297  buff << uint8(index++);
298  buff << uint32(wd->Address);
299  buff << uint8(wd->Length);
300  break;
301  }*/
302  default:
303  break; // Should never happen
304  }
305  }
306  buff << uint8(xorByte);
307  buff.hexlike();
308 
309  // Encrypt with warden RC4 key
310  EncryptData(buff.contents(), buff.size());
311 
312  WorldPacket pkt(SMSG_WARDEN_DATA, buff.size());
313  pkt.append(buff);
314  _session->SendPacket(&pkt);
315 
316  _dataSent = true;
317 
318  std::stringstream stream;
319  stream << "Sent check id's: ";
320  for (std::list<uint16>::iterator itr = _currentChecks.begin(); itr != _currentChecks.end(); ++itr)
321  stream << *itr << " ";
322 
323  TC_LOG_DEBUG("warden", "%s", stream.str().c_str());
324 }
uint8 * contents()
Definition: ByteBuffer.h:573
Definition: ByteBuffer.h:70
uint8 Length
Definition: WardenCheckMgr.h:39
Definition: World.h:349
Definition: Warden.h:54
Definition: Warden.h:51
uint8 Type
Definition: WardenCheckMgr.h:36
uint32 getMSTime()
Definition: Timer.h:24
bool _dataSent
Definition: Warden.h:133
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Warden.h:53
std::list< uint16 > _otherChecksTodo
Definition: WardenWin.h:81
#define sWorld
Definition: World.h:887
Definition: HmacHash.h:34
Definition: Warden.h:57
std::list< uint16 > _memChecksTodo
Definition: WardenWin.h:82
int32 GetNumBytes(void)
Definition: BigNumber.cpp:157
std::list< uint16 > _currentChecks
Definition: WardenWin.h:83
Definition: Warden.h:41
Definition: World.h:348
BigNumber Data
Definition: WardenCheckMgr.h:37
size_t size() const
Definition: ByteBuffer.h:587
Definition: Warden.h:52
Definition: Warden.h:50
uint32_t uint32
Definition: Define.h:150
uint16_t uint16
Definition: Define.h:151
void EncryptData(uint8 *buffer, uint32 length)
Definition: Warden.cpp:137
WorldSession * _session
Definition: Warden.h:125
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
void hexlike() const
Definition: ByteBuffer.cpp:82
void append(T value)
Definition: ByteBuffer.h:143
uint32 _serverTicks
Definition: WardenWin.h:80
uint8_t uint8
Definition: g3dmath.h:164
Definition: Warden.h:55
uint8 _inputKey[16]
Definition: Warden.h:126
#define sWardenCheckMgr
Definition: WardenCheckMgr.h:80
std::unique_ptr< uint8[]> AsByteArray(int32 minSize=0, bool littleEndian=true)
Definition: BigNumber.cpp:177
uint32 rand32()
Definition: Random.cpp:64
uint8_t uint8
Definition: Define.h:152
std::string Str
Definition: WardenCheckMgr.h:40
Definition: WardenCheckMgr.h:34
uint32_t uint32
Definition: g3dmath.h:168
uint32 Address
Definition: WardenCheckMgr.h:38
Definition: Opcodes.h:1623
Definition: WorldPacket.h:26
Definition: Warden.h:49

+ Here is the call graph for this function:

void WardenWin::RequestHash ( )
overridevirtual

Implements Warden.

133 {
134  TC_LOG_DEBUG("warden", "Request hash");
135 
136  // Create packet structure
137  WardenHashRequest Request;
139  memcpy(Request.Seed, _seed, 16);
140 
141  // Encrypt with warden RC4 key.
142  EncryptData((uint8*)&Request, sizeof(WardenHashRequest));
143 
145  pkt.append((uint8*)&Request, sizeof(WardenHashRequest));
146  _session->SendPacket(&pkt);
147 }
Definition: Warden.h:44
Definition: Warden.h:77
uint8 Seed[16]
Definition: Warden.h:80
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint8 _seed[16]
Definition: Warden.h:128
void EncryptData(uint8 *buffer, uint32 length)
Definition: Warden.cpp:137
WorldSession * _session
Definition: Warden.h:125
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint8 Command
Definition: Warden.h:79
uint8_t uint8
Definition: Define.h:152
Definition: Opcodes.h:1623
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

Member Data Documentation

std::list<uint16> WardenWin::_currentChecks
private
std::list<uint16> WardenWin::_memChecksTodo
private
std::list<uint16> WardenWin::_otherChecksTodo
private
uint32 WardenWin::_serverTicks
private

The documentation for this class was generated from the following files: