AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
AuthSession Struct Reference

#include "AuthSession.h"

Inheritance diagram for AuthSession:
Socket< AuthSession >

Public Member Functions

 AuthSession (tcp::socket &&socket)
 
void Start () override
 
bool Update () override
 
void SendPacket (ByteBuffer &packet)
 
- Public Member Functions inherited from Socket< AuthSession >
 Socket (tcp::socket &&socket)
 
virtual ~Socket ()
 
boost::asio::ip::address GetRemoteIpAddress () const
 
uint16 GetRemotePort () const
 
void AsyncRead ()
 
void AsyncReadProxyHeader ()
 
void AsyncReadWithCallback (void(T::*callback)(boost::system::error_code, std::size_t))
 
void QueuePacket (MessageBuffer &&buffer)
 
ProxyHeaderReadingState GetProxyHeaderReadingState () const
 
bool IsOpen () const
 
void CloseSocket ()
 
void DelayedCloseSocket ()
 Marks the socket for closing after write buffer becomes empty.
 
MessageBufferGetReadBuffer ()
 

Static Public Member Functions

static std::unordered_map< uint8, AuthHandlerInitHandlers ()
 

Public Attributes

uint32 BattlegroupID = 0
 
uint32 LoginServerType = 0
 
uint32 RealmID = 0
 
uint32 Build = 0
 
std::array< uint8, 4 > LocalChallenge = {}
 
uint32 LoginServerID = 0
 
uint32 RegionID = 0
 
uint64 DosResponse = 0
 
Acore::Crypto::SHA1::Digest Digest = {}
 
std::string Account
 
ByteBuffer AddonInfo
 

Protected Member Functions

void ReadHandler () override
 
- Protected Member Functions inherited from Socket< AuthSession >
virtual void OnClose ()
 
bool AsyncProcessQueue ()
 
void SetNoDelay (bool enable)
 

Private Types

typedef Socket< AuthSessionAuthSocket
 

Private Member Functions

bool HandleLogonChallenge ()
 
bool HandleLogonProof ()
 
bool HandleReconnectChallenge ()
 
bool HandleReconnectProof ()
 
bool HandleRealmList ()
 
void CheckIpCallback (PreparedQueryResult result)
 
void LogonChallengeCallback (PreparedQueryResult result)
 
void ReconnectChallengeCallback (PreparedQueryResult result)
 
void RealmListCallback (PreparedQueryResult result)
 
bool VerifyVersion (uint8 const *a, int32 aLength, Acore::Crypto::SHA1::Digest const &versionProof, bool isReconnect)
 

Private Attributes

Optional< Acore::Crypto::SRP6_srp6
 
SessionKey _sessionKey = {}
 
std::array< uint8, 16 > _reconnectProof = {}
 
AuthStatus _status
 
AccountInfo _accountInfo
 
Optional< std::vector< uint8 > > _totpSecret
 
std::string _localizationName
 
std::string _os
 
std::string _ipCountry
 
uint16 _build
 
uint8 _expversion
 
QueryCallbackProcessor _queryProcessor
 

Detailed Description

Member Typedef Documentation

◆ AuthSocket

Constructor & Destructor Documentation

◆ AuthSession()

AuthSession::AuthSession ( tcp::socket &&  socket)
165 :
166 Socket(std::move(socket)), _status(STATUS_CHALLENGE), _build(0), _expversion(0) { }
@ STATUS_CHALLENGE
Definition AuthSession.h:39
AuthStatus _status
Definition AuthSession.h:98
uint16 _build
Definition AuthSession.h:104
uint8 _expversion
Definition AuthSession.h:105
Definition Socket.h:52

Member Function Documentation

◆ CheckIpCallback()

void AuthSession::CheckIpCallback ( PreparedQueryResult  result)
private
190{
191 if (result)
192 {
193 bool banned = false;
194
195 for (auto const& fields : *result)
196 {
197 if (fields[0].Get<uint64>() != 0)
198 {
199 banned = true;
200 break;
201 }
202 }
203
204 if (banned)
205 {
206 ByteBuffer pkt;
208 pkt << uint8(0x00);
209 pkt << uint8(WOW_FAIL_BANNED);
210 SendPacket(pkt);
211 LOG_DEBUG("session", "[AuthSession::CheckIpCallback] Banned ip '{}:{}' tries to login!", GetRemoteIpAddress().to_string(), GetRemotePort());
212 return;
213 }
214 }
215
216 AsyncRead();
217}
@ WOW_FAIL_BANNED
Definition AuthCodes.h:26
@ AUTH_LOGON_CHALLENGE
Definition AuthSession.cpp:39
std::uint8_t uint8
Definition Define.h:109
#define LOG_DEBUG(filterType__,...)
Definition Log.h:169
void SendPacket(ByteBuffer &packet)
Definition AuthSession.cpp:270
Definition ByteBuffer.h:70
boost::asio::ip::address GetRemoteIpAddress() const
Definition Socket.h:90
uint16 GetRemotePort() const
Definition Socket.h:95
void AsyncRead()
Definition Socket.h:100

References Socket< AuthSession >::AsyncRead(), AUTH_LOGON_CHALLENGE, Socket< AuthSession >::GetRemoteIpAddress(), Socket< AuthSession >::GetRemotePort(), LOG_DEBUG, SendPacket(), and WOW_FAIL_BANNED.

Referenced by Start().

◆ HandleLogonChallenge()

bool AuthSession::HandleLogonChallenge ( )
private
284{
286
287 sAuthLogonChallenge_C* challenge = reinterpret_cast<sAuthLogonChallenge_C*>(GetReadBuffer().GetReadPointer());
288 if (challenge->size - (sizeof(sAuthLogonChallenge_C) - AUTH_LOGON_CHALLENGE_INITIAL_SIZE - 1) != challenge->I_len)
289 return false;
290
291 std::string login((char const*)challenge->I, challenge->I_len);
292 LOG_DEBUG("server.authserver", "[AuthChallenge] '{}'", login);
293
294 _build = challenge->build;
296 std::array<char, 5> os;
297 os.fill('\0');
298 memcpy(os.data(), challenge->os, sizeof(challenge->os));
299 _os = os.data();
300
301 // Restore string order as its byte order is reversed
302 std::reverse(_os.begin(), _os.end());
303
304 _localizationName.resize(4);
305 for (int i = 0; i < 4; ++i)
306 _localizationName[i] = challenge->country[4 - i - 1];
307
308 // Get the account details from the account table
310 stmt->SetData(0, GetRemoteIpAddress().to_string());
311 stmt->SetData(1, login);
312
313 _queryProcessor.AddCallback(LoginDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&AuthSession::LogonChallengeCallback, this, std::placeholders::_1)));
314 return true;
315}
@ POST_BC_EXP_FLAG
Definition AuthCodes.h:76
@ NO_VALID_EXP_FLAG
Definition AuthCodes.h:78
@ PRE_BC_EXP_FLAG
Definition AuthCodes.h:77
#define AUTH_LOGON_CHALLENGE_INITIAL_SIZE
Definition AuthSession.cpp:119
@ STATUS_CLOSED
Definition AuthSession.h:44
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
Definition DatabaseEnv.cpp:22
@ LOGIN_SEL_LOGONCHALLENGE
Definition LoginDatabase.h:44
T & AddCallback(T &&query)
Definition AsyncCallbackProcessor.h:34
std::string _os
Definition AuthSession.h:102
QueryCallbackProcessor _queryProcessor
Definition AuthSession.h:107
void LogonChallengeCallback(PreparedQueryResult result)
Definition AuthSession.cpp:317
std::string _localizationName
Definition AuthSession.h:101
uint8 * GetReadPointer()
Definition MessageBuffer.h:58
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157
MessageBuffer & GetReadBuffer()
Definition Socket.h:173
Definition AuthCodes.cpp:22
bool IsPreBCAcceptedClientBuild(uint32 build)
Definition AuthCodes.cpp:25
bool IsPostBCAcceptedClientBuild(uint32 build)
Definition AuthCodes.cpp:30
Definition AuthSession.cpp:54
uint8 I[1]
Definition AuthSession.cpp:69
uint16 build
Definition AuthSession.cpp:62
uint8 country[4]
Definition AuthSession.cpp:65
uint8 I_len
Definition AuthSession.cpp:68
uint16 size
Definition AuthSession.cpp:57
uint8 os[4]
Definition AuthSession.cpp:64

References _build, _expversion, _localizationName, _os, _queryProcessor, _status, AsyncCallbackProcessor< T >::AddCallback(), AUTH_LOGON_CHALLENGE_INITIAL_SIZE, AUTH_LOGON_CHALLENGE_C::build, AUTH_LOGON_CHALLENGE_C::country, Socket< AuthSession >::GetReadBuffer(), MessageBuffer::GetReadPointer(), Socket< AuthSession >::GetRemoteIpAddress(), AUTH_LOGON_CHALLENGE_C::I, AUTH_LOGON_CHALLENGE_C::I_len, AuthHelper::IsPostBCAcceptedClientBuild(), AuthHelper::IsPreBCAcceptedClientBuild(), LOG_DEBUG, LOGIN_SEL_LOGONCHALLENGE, LoginDatabase, LogonChallengeCallback(), NO_VALID_EXP_FLAG, AUTH_LOGON_CHALLENGE_C::os, POST_BC_EXP_FLAG, PRE_BC_EXP_FLAG, PreparedStatementBase::SetData(), AUTH_LOGON_CHALLENGE_C::size, and STATUS_CLOSED.

Referenced by InitHandlers().

◆ HandleLogonProof()

bool AuthSession::HandleLogonProof ( )
private
457{
458 LOG_DEBUG("server.authserver", "Entering _HandleLogonProof");
460
461 // Read the packet
462 sAuthLogonProof_C* logonProof = reinterpret_cast<sAuthLogonProof_C*>(GetReadBuffer().GetReadPointer());
463
464 // If the client has no valid version
466 {
467 // Check if we have the appropriate patch on the disk
468 LOG_DEBUG("network", "Client with invalid version, patching is not implemented");
469 return false;
470 }
471
472 // Check if SRP6 results match (password is correct), else send an error
473 if (Optional<SessionKey> K = _srp6->VerifyChallengeResponse(logonProof->A, logonProof->clientM))
474 {
475 _sessionKey = *K;
476 // Check auth token
477 bool tokenSuccess = false;
478 bool sentToken = (logonProof->securityFlags & 0x04);
479 if (sentToken && _totpSecret)
480 {
481 uint8 size = *(GetReadBuffer().GetReadPointer() + sizeof(sAuthLogonProof_C));
482 std::string token(reinterpret_cast<char*>(GetReadBuffer().GetReadPointer() + sizeof(sAuthLogonProof_C) + sizeof(size)), size);
483 GetReadBuffer().ReadCompleted(sizeof(size) + size);
484
485 uint32 incomingToken = *Acore::StringTo<uint32>(token);
486 tokenSuccess = Acore::Crypto::TOTP::ValidateToken(*_totpSecret, incomingToken);
487 memset(_totpSecret->data(), 0, _totpSecret->size());
488 }
489 else if (!sentToken && !_totpSecret)
490 tokenSuccess = true;
491
492 if (!tokenSuccess)
493 {
494 ByteBuffer packet;
495 packet << uint8(AUTH_LOGON_PROOF);
497 packet << uint16(0); // LoginFlags, 1 has account message
498 SendPacket(packet);
499 return true;
500 }
501
502 if (!VerifyVersion(logonProof->A.data(), logonProof->A.size(), logonProof->crc_hash, false))
503 {
504 ByteBuffer packet;
505 packet << uint8(AUTH_LOGON_PROOF);
507 SendPacket(packet);
508 return true;
509 }
510
511 LOG_DEBUG("server.authserver", "'{}:{}' User '{}' successfully authenticated", GetRemoteIpAddress().to_string(), GetRemotePort(), _accountInfo.Login);
512
513 // Update the sessionkey, last_ip, last login time and reset number of failed logins in the account table for this account
514 // No SQL injection (escaped user name) and IP address as received by socket
515
516 std::string address = sConfigMgr->GetOption<bool>("AllowLoggingIPAddressesInDatabase", true, true) ? GetRemoteIpAddress().to_string() : "0.0.0.0";
518 stmt->SetData(0, _sessionKey);
519 stmt->SetData(1, address);
521 stmt->SetData(3, _os);
522 stmt->SetData(4, _accountInfo.Login);
523 LoginDatabase.DirectExecute(stmt);
524
525 // Finish SRP6 and send the final result to the client
527
528 ByteBuffer packet;
529 if (_expversion & POST_BC_EXP_FLAG) // 2.x and 3.x clients
530 {
531 sAuthLogonProof_S proof;
532 proof.M2 = M2;
533 proof.cmd = AUTH_LOGON_PROOF;
534 proof.error = 0;
535 proof.AccountFlags = 0x00800000; // 0x01 = GM, 0x08 = Trial, 0x00800000 = Pro pass (arena tournament)
536 proof.SurveyId = 0;
537 proof.LoginFlags = 0; // 0x1 = has account message
538
539 packet.resize(sizeof(proof));
540 std::memcpy(packet.contents(), &proof, sizeof(proof));
541 }
542 else
543 {
545 proof.M2 = M2;
546 proof.cmd = AUTH_LOGON_PROOF;
547 proof.error = 0;
548 proof.unk2 = 0x00;
549
550 packet.resize(sizeof(proof));
551 std::memcpy(packet.contents(), &proof, sizeof(proof));
552 }
553
554 SendPacket(packet);
556 }
557 else
558 {
559 ByteBuffer packet;
560 packet << uint8(AUTH_LOGON_PROOF);
562 packet << uint16(0); // LoginFlags, 1 has account message
563 SendPacket(packet);
564
565 LOG_INFO("server.authserver.hack", "'{}:{}' [AuthChallenge] account {} tried to login with invalid password!",
567
568 uint32 MaxWrongPassCount = sConfigMgr->GetOption<int32>("WrongPass.MaxCount", 0);
569
570 // We can not include the failed account login hook. However, this is a workaround to still log this.
571 if (sConfigMgr->GetOption<bool>("WrongPass.Logging", false))
572 {
574 logstmt->SetData(0, _accountInfo.Id);
575 logstmt->SetData(1, GetRemoteIpAddress().to_string());
576 logstmt->SetData(2, "Login to WoW Failed - Incorrect Password");
577
578 LoginDatabase.Execute(logstmt);
579 }
580
581 if (MaxWrongPassCount > 0)
582 {
583 //Increment number of failed logins by one and if it reaches the limit temporarily ban that account or IP
585 stmt->SetData(0, _accountInfo.Login);
586 LoginDatabase.Execute(stmt);
587
588 if (++_accountInfo.FailedLogins >= MaxWrongPassCount)
589 {
590 uint32 WrongPassBanTime = sConfigMgr->GetOption<int32>("WrongPass.BanTime", 600);
591 bool WrongPassBanType = sConfigMgr->GetOption<bool>("WrongPass.BanType", false);
592
593 if (WrongPassBanType)
594 {
595 stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_AUTO_BANNED);
596 stmt->SetData(0, _accountInfo.Id);
597 stmt->SetData(1, WrongPassBanTime);
598 LoginDatabase.Execute(stmt);
599
600 LOG_DEBUG("server.authserver", "'{}:{}' [AuthChallenge] account {} got banned for '{}' seconds because it failed to authenticate '{}' times",
601 GetRemoteIpAddress().to_string(), GetRemotePort(), _accountInfo.Login, WrongPassBanTime, _accountInfo.FailedLogins);
602 }
603 else
604 {
605 stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_IP_AUTO_BANNED);
606 stmt->SetData(0, GetRemoteIpAddress().to_string());
607 stmt->SetData(1, WrongPassBanTime);
608 LoginDatabase.Execute(stmt);
609
610 LOG_DEBUG("server.authserver", "'{}:{}' [AuthChallenge] IP got banned for '{}' seconds because account {} failed to authenticate '{}' times",
611 GetRemoteIpAddress().to_string(), GetRemotePort(), WrongPassBanTime, _accountInfo.Login, _accountInfo.FailedLogins);
612 }
613 }
614 }
615 }
616
617 return true;
618}
@ WOW_FAIL_UNKNOWN_ACCOUNT
Definition AuthCodes.h:27
@ WOW_FAIL_VERSION_INVALID
Definition AuthCodes.h:32
@ AUTH_LOGON_PROOF
Definition AuthSession.cpp:40
struct AUTH_LOGON_PROOF_C sAuthLogonProof_C
@ STATUS_AUTHED
Definition AuthSession.h:42
LocaleConstant GetLocaleByName(const std::string &name)
Definition Common.cpp:42
#define sConfigMgr
Definition Config.h:74
std::int32_t int32
Definition Define.h:103
std::uint32_t uint32
Definition Define.h:107
std::uint16_t uint16
Definition Define.h:108
#define LOG_INFO(filterType__,...)
Definition Log.h:165
@ LOGIN_INS_ACCOUNT_AUTO_BANNED
Definition LoginDatabase.h:40
@ LOGIN_INS_FALP_IP_LOGGING
Definition LoginDatabase.h:110
@ LOGIN_UPD_LOGONPROOF
Definition LoginDatabase.h:43
@ LOGIN_UPD_FAILEDLOGINS
Definition LoginDatabase.h:46
@ LOGIN_INS_IP_AUTO_BANNED
Definition LoginDatabase.h:36
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:24
static SHA1::Digest GetSessionVerifier(EphemeralKey const &A, SHA1::Digest const &clientM, SessionKey const &K)
Definition SRP6.h:52
std::array< uint8, DIGEST_LENGTH > Digest
Definition CryptoHash.h:46
Optional< Acore::Crypto::SRP6 > _srp6
Definition AuthSession.h:94
SessionKey _sessionKey
Definition AuthSession.h:95
AccountInfo _accountInfo
Definition AuthSession.h:99
bool VerifyVersion(uint8 const *a, int32 aLength, Acore::Crypto::SHA1::Digest const &versionProof, bool isReconnect)
Definition AuthSession.cpp:840
Optional< std::vector< uint8 > > _totpSecret
Definition AuthSession.h:100
void resize(std::size_t newsize)
Definition ByteBuffer.h:447
uint8 * contents()
Definition ByteBuffer.h:424
void ReadCompleted(size_type bytes)
Definition MessageBuffer.h:61
Definition AuthSession.cpp:74
Acore::Crypto::SHA1::Digest clientM
Definition AuthSession.cpp:77
Acore::Crypto::SRP6::EphemeralKey A
Definition AuthSession.cpp:76
uint8 securityFlags
Definition AuthSession.cpp:80
Acore::Crypto::SHA1::Digest crc_hash
Definition AuthSession.cpp:78
Definition AuthSession.cpp:96
uint8 error
Definition AuthSession.cpp:98
uint32 unk2
Definition AuthSession.cpp:100
uint8 cmd
Definition AuthSession.cpp:97
Acore::Crypto::SHA1::Digest M2
Definition AuthSession.cpp:99
Definition AuthSession.cpp:85
Acore::Crypto::SHA1::Digest M2
Definition AuthSession.cpp:88
uint8 cmd
Definition AuthSession.cpp:86
uint8 error
Definition AuthSession.cpp:87
uint32 AccountFlags
Definition AuthSession.cpp:89
uint32 SurveyId
Definition AuthSession.cpp:90
uint16 LoginFlags
Definition AuthSession.cpp:91
uint32 FailedLogins
Definition AuthSession.h:57
uint32 Id
Definition AuthSession.h:52
std::string Login
Definition AuthSession.h:53
static bool ValidateToken(Secret const &key, uint32 token)
Definition TOTP.cpp:44

References _accountInfo, _expversion, _localizationName, _os, _sessionKey, _srp6, _status, _totpSecret, AUTH_LOGON_PROOF_C::A, AUTH_LOGON_PROOF_S::AccountFlags, AUTH_LOGON_PROOF, AUTH_LOGON_PROOF_C::clientM, AUTH_LOGON_PROOF_S::cmd, AUTH_LOGON_PROOF_S_OLD::cmd, ByteBuffer::contents(), AUTH_LOGON_PROOF_C::crc_hash, AUTH_LOGON_PROOF_S::error, AUTH_LOGON_PROOF_S_OLD::error, AccountInfo::FailedLogins, GetLocaleByName(), Socket< AuthSession >::GetReadBuffer(), MessageBuffer::GetReadPointer(), Socket< AuthSession >::GetRemoteIpAddress(), Socket< AuthSession >::GetRemotePort(), Acore::Crypto::SRP6::GetSessionVerifier(), AccountInfo::Id, LOG_DEBUG, LOG_INFO, AccountInfo::Login, LOGIN_INS_ACCOUNT_AUTO_BANNED, LOGIN_INS_FALP_IP_LOGGING, LOGIN_INS_IP_AUTO_BANNED, LOGIN_UPD_FAILEDLOGINS, LOGIN_UPD_LOGONPROOF, LoginDatabase, AUTH_LOGON_PROOF_S::LoginFlags, AUTH_LOGON_PROOF_S::M2, AUTH_LOGON_PROOF_S_OLD::M2, NO_VALID_EXP_FLAG, POST_BC_EXP_FLAG, MessageBuffer::ReadCompleted(), ByteBuffer::resize(), sConfigMgr, AUTH_LOGON_PROOF_C::securityFlags, SendPacket(), PreparedStatementBase::SetData(), STATUS_AUTHED, STATUS_CLOSED, AUTH_LOGON_PROOF_S::SurveyId, AUTH_LOGON_PROOF_S_OLD::unk2, Acore::Crypto::TOTP::ValidateToken(), VerifyVersion(), WOW_FAIL_UNKNOWN_ACCOUNT, and WOW_FAIL_VERSION_INVALID.

Referenced by InitHandlers().

◆ HandleRealmList()

bool AuthSession::HandleRealmList ( )
private
727{
728 LOG_DEBUG("server.authserver", "Entering _HandleRealmList");
729
731 stmt->SetData(0, _accountInfo.Id);
732
733 _queryProcessor.AddCallback(LoginDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&AuthSession::RealmListCallback, this, std::placeholders::_1)));
735 return true;
736}
@ STATUS_WAITING_FOR_REALM_LIST
Definition AuthSession.h:43
@ LOGIN_SEL_REALM_CHARACTER_COUNTS
Definition LoginDatabase.h:53
void RealmListCallback(PreparedQueryResult result)
Definition AuthSession.cpp:738

References _accountInfo, _queryProcessor, _status, AsyncCallbackProcessor< T >::AddCallback(), AccountInfo::Id, LOG_DEBUG, LOGIN_SEL_REALM_CHARACTER_COUNTS, LoginDatabase, RealmListCallback(), PreparedStatementBase::SetData(), and STATUS_WAITING_FOR_REALM_LIST.

Referenced by InitHandlers().

◆ HandleReconnectChallenge()

bool AuthSession::HandleReconnectChallenge ( )
private
621{
623
624 sAuthLogonChallenge_C* challenge = reinterpret_cast<sAuthLogonChallenge_C*>(GetReadBuffer().GetReadPointer());
625 if (challenge->size - (sizeof(sAuthLogonChallenge_C) - AUTH_LOGON_CHALLENGE_INITIAL_SIZE - 1) != challenge->I_len)
626 return false;
627
628 std::string login((char const*)challenge->I, challenge->I_len);
629 LOG_DEBUG("server.authserver", "[ReconnectChallenge] '{}'", login);
630
631 _build = challenge->build;
633
634 std::array<char, 5> os;
635 os.fill('\0');
636 memcpy(os.data(), challenge->os, sizeof(challenge->os));
637 _os = os.data();
638
639 // Restore string order as its byte order is reversed
640 std::reverse(_os.begin(), _os.end());
641
642 _localizationName.resize(4);
643 for (int i = 0; i < 4; ++i)
644 _localizationName[i] = challenge->country[4 - i - 1];
645
646 // Get the account details from the account table
648 stmt->SetData(0, GetRemoteIpAddress().to_string());
649 stmt->SetData(1, login);
650
651 _queryProcessor.AddCallback(LoginDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&AuthSession::ReconnectChallengeCallback, this, std::placeholders::_1)));
652 return true;
653}
@ LOGIN_SEL_RECONNECTCHALLENGE
Definition LoginDatabase.h:45
void ReconnectChallengeCallback(PreparedQueryResult result)
Definition AuthSession.cpp:655

References _build, _expversion, _localizationName, _os, _queryProcessor, _status, AsyncCallbackProcessor< T >::AddCallback(), AUTH_LOGON_CHALLENGE_INITIAL_SIZE, AUTH_LOGON_CHALLENGE_C::build, AUTH_LOGON_CHALLENGE_C::country, Socket< AuthSession >::GetReadBuffer(), MessageBuffer::GetReadPointer(), Socket< AuthSession >::GetRemoteIpAddress(), AUTH_LOGON_CHALLENGE_C::I, AUTH_LOGON_CHALLENGE_C::I_len, AuthHelper::IsPostBCAcceptedClientBuild(), AuthHelper::IsPreBCAcceptedClientBuild(), LOG_DEBUG, LOGIN_SEL_RECONNECTCHALLENGE, LoginDatabase, NO_VALID_EXP_FLAG, AUTH_LOGON_CHALLENGE_C::os, POST_BC_EXP_FLAG, PRE_BC_EXP_FLAG, ReconnectChallengeCallback(), PreparedStatementBase::SetData(), AUTH_LOGON_CHALLENGE_C::size, and STATUS_CLOSED.

Referenced by InitHandlers().

◆ HandleReconnectProof()

bool AuthSession::HandleReconnectProof ( )
private
682{
683 LOG_DEBUG("server.authserver", "Entering _HandleReconnectProof");
685
686 sAuthReconnectProof_C* reconnectProof = reinterpret_cast<sAuthReconnectProof_C*>(GetReadBuffer().GetReadPointer());
687
688 if (_accountInfo.Login.empty())
689 return false;
690
693 sha.UpdateData(reconnectProof->R1, 16);
696 sha.Finalize();
697
698 if (sha.GetDigest() == reconnectProof->R2)
699 {
700 if (!VerifyVersion(reconnectProof->R1, sizeof(reconnectProof->R1), reconnectProof->R3, true))
701 {
702 ByteBuffer packet;
703 packet << uint8(AUTH_RECONNECT_PROOF);
705 SendPacket(packet);
706 return true;
707 }
708
709 // Sending response
710 ByteBuffer pkt;
712 pkt << uint8(WOW_SUCCESS);
713 pkt << uint16(0); // LoginFlags, 1 has account message
714 SendPacket(pkt);
716 return true;
717 }
718 else
719 {
720 LOG_ERROR("server.authserver.hack", "'{}:{}' [ERROR] user {} tried to login, but session is invalid.", GetRemoteIpAddress().to_string(),
722 return false;
723 }
724}
@ WOW_SUCCESS
Definition AuthCodes.h:25
@ AUTH_RECONNECT_PROOF
Definition AuthSession.cpp:42
#define LOG_ERROR(filterType__,...)
Definition Log.h:157
Definition CryptoHash.h:43
void Finalize()
Definition CryptoHash.h:123
void UpdateData(uint8 const *data, std::size_t len)
Definition CryptoHash.h:110
Digest const & GetDigest() const
Definition CryptoHash.h:131
std::array< uint8, 16 > _reconnectProof
Definition AuthSession.h:96
Definition AuthSession.cpp:105
uint8 R1[16]
Definition AuthSession.cpp:107
Acore::Crypto::SHA1::Digest R2
Definition AuthSession.cpp:108
Acore::Crypto::SHA1::Digest R3
Definition AuthSession.cpp:108

References _accountInfo, _reconnectProof, _sessionKey, _status, AUTH_RECONNECT_PROOF, Acore::Impl::GenericHash< HashCreator, DigestLength >::Finalize(), Acore::Impl::GenericHash< HashCreator, DigestLength >::GetDigest(), Socket< AuthSession >::GetReadBuffer(), MessageBuffer::GetReadPointer(), Socket< AuthSession >::GetRemoteIpAddress(), Socket< AuthSession >::GetRemotePort(), LOG_DEBUG, LOG_ERROR, AccountInfo::Login, AUTH_RECONNECT_PROOF_C::R1, AUTH_RECONNECT_PROOF_C::R2, AUTH_RECONNECT_PROOF_C::R3, SendPacket(), STATUS_AUTHED, STATUS_CLOSED, Acore::Impl::GenericHash< HashCreator, DigestLength >::UpdateData(), VerifyVersion(), WOW_FAIL_VERSION_INVALID, and WOW_SUCCESS.

Referenced by InitHandlers().

◆ InitHandlers()

std::unordered_map< uint8, AuthHandler > AuthSession::InitHandlers ( )
static
123{
124 std::unordered_map<uint8, AuthHandler> handlers;
125
131
132 return handlers;
133}
@ REALM_LIST
Definition AuthSession.cpp:43
@ AUTH_RECONNECT_CHALLENGE
Definition AuthSession.cpp:41
#define REALM_LIST_PACKET_SIZE
Definition AuthSession.cpp:120
@ STATUS_RECONNECT_PROOF
Definition AuthSession.h:41
@ STATUS_LOGON_PROOF
Definition AuthSession.h:40
bool HandleLogonChallenge()
Definition AuthSession.cpp:283
bool HandleLogonProof()
Definition AuthSession.cpp:456
bool HandleReconnectChallenge()
Definition AuthSession.cpp:620
bool HandleRealmList()
Definition AuthSession.cpp:726
bool HandleReconnectProof()
Definition AuthSession.cpp:681

References AUTH_LOGON_CHALLENGE, AUTH_LOGON_CHALLENGE_INITIAL_SIZE, AUTH_LOGON_PROOF, AUTH_RECONNECT_CHALLENGE, AUTH_RECONNECT_PROOF, HandleLogonChallenge(), HandleLogonProof(), HandleRealmList(), HandleReconnectChallenge(), HandleReconnectProof(), REALM_LIST, REALM_LIST_PACKET_SIZE, STATUS_AUTHED, STATUS_CHALLENGE, STATUS_LOGON_PROOF, and STATUS_RECONNECT_PROOF.

◆ LogonChallengeCallback()

void AuthSession::LogonChallengeCallback ( PreparedQueryResult  result)
private
318{
319 ByteBuffer pkt;
321 pkt << uint8(0x00);
322
323 if (!result)
324 {
326 SendPacket(pkt);
327 return;
328 }
329
330 Field* fields = result->Fetch();
331
332 _accountInfo.LoadResult(fields);
333
334 std::string ipAddress = GetRemoteIpAddress().to_string();
335 uint16 port = GetRemotePort();
336
337 // If the IP is 'locked', check that the player comes indeed from the correct IP address
339 {
340 LOG_DEBUG("server.authserver", "[AuthChallenge] Account '{}' is locked to IP - '{}' is logging in from '{}'", _accountInfo.Login, _accountInfo.LastIP, ipAddress);
341 if (_accountInfo.LastIP != ipAddress)
342 {
344 SendPacket(pkt);
345 return;
346 }
347 }
348 else
349 {
350 if (IpLocationRecord const* location = sIPLocation->GetLocationRecord(ipAddress))
351 _ipCountry = location->CountryCode;
352
353 LOG_DEBUG("server.authserver", "[AuthChallenge] Account '{}' is not locked to ip", _accountInfo.Login);
354 if (_accountInfo.LockCountry.empty() || _accountInfo.LockCountry == "00")
355 LOG_DEBUG("server.authserver", "[AuthChallenge] Account '{}' is not locked to country", _accountInfo.Login);
356 else if (!_ipCountry.empty())
357 {
358 LOG_DEBUG("server.authserver", "[AuthChallenge] Account '{}' is locked to country: '{}' Player country is '{}'", _accountInfo.Login, _accountInfo.LockCountry, _ipCountry);
360 {
362 SendPacket(pkt);
363 return;
364 }
365 }
366 }
367
368 // If the account is banned, reject the logon attempt
370 {
372 {
373 pkt << uint8(WOW_FAIL_BANNED);
374 SendPacket(pkt);
375 LOG_INFO("server.authserver.banned", "'{}:{}' [AuthChallenge] Banned account {} tried to login!", ipAddress, port, _accountInfo.Login);
376 return;
377 }
378 else
379 {
381 SendPacket(pkt);
382 LOG_INFO("server.authserver.banned", "'{}:{}' [AuthChallenge] Temporarily banned account {} tried to login!", ipAddress, port, _accountInfo.Login);
383 return;
384 }
385 }
386
387 uint8 securityFlags = 0;
388
389 // Check if a TOTP token is needed
390 if (!fields[11].IsNull())
391 {
392 securityFlags = 4;
393 _totpSecret = fields[11].Get<Binary>();
394
395 if (auto const& secret = sSecretMgr->GetSecret(SECRET_TOTP_MASTER_KEY))
396 {
397 bool success = Acore::Crypto::AEDecrypt<Acore::Crypto::AES>(*_totpSecret, *secret);
398 if (!success)
399 {
400 pkt << uint8(WOW_FAIL_DB_BUSY);
401 LOG_ERROR("server.authserver", "[AuthChallenge] Account '{}' has invalid ciphertext for TOTP token key stored", _accountInfo.Login);
402 SendPacket(pkt);
403 return;
404 }
405 }
406 }
407
408 _srp6.emplace(_accountInfo.Login,
409 fields[12].Get<Binary, Acore::Crypto::SRP6::SALT_LENGTH>(),
411
412 // Fill the response packet with the result
414 {
415 pkt << uint8(WOW_SUCCESS);
416
417 pkt.append(_srp6->B);
418 pkt << uint8(1);
419 pkt.append(_srp6->g);
420 pkt << uint8(32);
421 pkt.append(_srp6->N);
422 pkt.append(_srp6->s);
423 pkt.append(VersionChallenge.data(), VersionChallenge.size());
424 pkt << uint8(securityFlags); // security flags (0x0...0x04)
425
426 if (securityFlags & 0x01) // PIN input
427 {
428 pkt << uint32(0);
429 pkt << uint64(0) << uint64(0); // 16 bytes hash?
430 }
431
432 if (securityFlags & 0x02) // Matrix input
433 {
434 pkt << uint8(0);
435 pkt << uint8(0);
436 pkt << uint8(0);
437 pkt << uint8(0);
438 pkt << uint64(0);
439 }
440
441 if (securityFlags & 0x04) // Security token input
442 pkt << uint8(1);
443
444 LOG_DEBUG("server.authserver", "'{}:{}' [AuthChallenge] account {} is using '{}' locale ({})",
446
448 }
449 else
451
452 SendPacket(pkt);
453}
@ WOW_FAIL_LOCKED_ENFORCED
Definition AuthCodes.h:39
@ WOW_FAIL_SUSPENDED
Definition AuthCodes.h:35
@ WOW_FAIL_DB_BUSY
Definition AuthCodes.h:31
@ WOW_FAIL_UNLOCKABLE_LOCK
Definition AuthCodes.h:48
std::array< uint8, 16 > VersionChallenge
Definition AuthSession.cpp:115
std::uint64_t uint64
Definition Define.h:106
std::vector< uint8 > Binary
Definition Field.h:40
#define sIPLocation
Definition IPLocation.h:49
#define sSecretMgr
Definition SecretMgr.h:72
@ SECRET_TOTP_MASTER_KEY
Definition SecretMgr.h:30
static constexpr std::size_t VERIFIER_LENGTH
Definition SRP6.h:34
static constexpr std::size_t SALT_LENGTH
Definition SRP6.h:31
std::string _ipCountry
Definition AuthSession.h:103
void append(T value)
Definition ByteBuffer.h:129
Class used to access individual fields of database query result.
Definition Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112
bool IsAcceptedClientBuild(uint32 build)
Definition AuthCodes.cpp:35
std::string LockCountry
Definition AuthSession.h:55
bool IsPermanentlyBanned
Definition AuthSession.h:59
void LoadResult(Field *fields)
Definition AuthSession.cpp:137
bool IsBanned
Definition AuthSession.h:58
bool IsLockedToIP
Definition AuthSession.h:54
std::string LastIP
Definition AuthSession.h:56
Definition IPLocation.h:23

References _accountInfo, _build, _ipCountry, _localizationName, _srp6, _status, _totpSecret, ByteBuffer::append(), AUTH_LOGON_CHALLENGE, Field::Get(), GetLocaleByName(), Socket< AuthSession >::GetRemoteIpAddress(), Socket< AuthSession >::GetRemotePort(), AuthHelper::IsAcceptedClientBuild(), AccountInfo::IsBanned, AccountInfo::IsLockedToIP, AccountInfo::IsPermanentlyBanned, AccountInfo::LastIP, AccountInfo::LoadResult(), AccountInfo::LockCountry, LOG_DEBUG, LOG_ERROR, LOG_INFO, AccountInfo::Login, Acore::Crypto::SRP6::SALT_LENGTH, SECRET_TOTP_MASTER_KEY, SendPacket(), sIPLocation, sSecretMgr, STATUS_LOGON_PROOF, Acore::Crypto::SRP6::VERIFIER_LENGTH, VersionChallenge, WOW_FAIL_BANNED, WOW_FAIL_DB_BUSY, WOW_FAIL_LOCKED_ENFORCED, WOW_FAIL_SUSPENDED, WOW_FAIL_UNKNOWN_ACCOUNT, WOW_FAIL_UNLOCKABLE_LOCK, WOW_FAIL_VERSION_INVALID, and WOW_SUCCESS.

Referenced by HandleLogonChallenge().

◆ ReadHandler()

void AuthSession::ReadHandler ( )
overrideprotectedvirtual

Implements Socket< AuthSession >.

220{
221 MessageBuffer& packet = GetReadBuffer();
222
223 while (packet.GetActiveSize())
224 {
225 uint8 cmd = packet.GetReadPointer()[0];
226 auto itr = Handlers.find(cmd);
227 if (itr == Handlers.end())
228 {
229 // well we dont handle this, lets just ignore it
230 packet.Reset();
231 break;
232 }
233
234 if (_status != itr->second.status)
235 {
236 CloseSocket();
237 return;
238 }
239
240 uint16 size = uint16(itr->second.packetSize);
241 if (packet.GetActiveSize() < size)
242 break;
243
245 {
246 sAuthLogonChallenge_C* challenge = reinterpret_cast<sAuthLogonChallenge_C*>(packet.GetReadPointer());
247 size += challenge->size;
249 {
250 CloseSocket();
251 return;
252 }
253 }
254
255 if (packet.GetActiveSize() < size)
256 break;
257
258 if (!(*this.*itr->second.handler)())
259 {
260 CloseSocket();
261 return;
262 }
263
264 packet.ReadCompleted(size);
265 }
266
267 AsyncRead();
268}
#define MAX_ACCEPTED_CHALLENGE_SIZE
Definition AuthSession.cpp:117
std::unordered_map< uint8, AuthHandler > const Handlers
Definition AuthSession.cpp:135
Definition MessageBuffer.h:26
size_type GetActiveSize() const
Definition MessageBuffer.h:64
void Reset()
Definition MessageBuffer.h:46
void CloseSocket()
Definition Socket.h:155

References _status, Socket< AuthSession >::AsyncRead(), AUTH_LOGON_CHALLENGE, AUTH_RECONNECT_CHALLENGE, Socket< AuthSession >::CloseSocket(), MessageBuffer::GetActiveSize(), Socket< AuthSession >::GetReadBuffer(), MessageBuffer::GetReadPointer(), Handlers, MAX_ACCEPTED_CHALLENGE_SIZE, MessageBuffer::ReadCompleted(), MessageBuffer::Reset(), and AUTH_LOGON_CHALLENGE_C::size.

◆ RealmListCallback()

void AuthSession::RealmListCallback ( PreparedQueryResult  result)
private
739{
740 std::map<uint32, uint8> characterCounts;
741 if (result)
742 {
743 do
744 {
745 Field* fields = result->Fetch();
746 characterCounts[fields[0].Get<uint32>()] = fields[1].Get<uint8>();
747 } while (result->NextRow());
748 }
749
750 // Circle through realms in the RealmList and construct the return packet (including # of user characters in each realm)
751 ByteBuffer pkt;
752
753 std::size_t RealmListSize = 0;
754 for (auto const& [realmHandle, realm] : sRealmList->GetRealms())
755 {
756 // don't work with realms which not compatible with the client
758
759 // No SQL injection. id of realm is controlled by the database.
760 uint32 flag = realm.Flags;
761 RealmBuildInfo const* buildInfo = sRealmList->GetBuildInfo(realm.Build);
762 if (!okBuild)
763 {
764 if (!buildInfo)
765 continue;
766
767 flag |= REALM_FLAG_OFFLINE | REALM_FLAG_SPECIFYBUILD; // tell the client what build the realm is for
768 }
769
770 if (!buildInfo)
771 flag &= ~REALM_FLAG_SPECIFYBUILD;
772
773 std::string name = realm.Name;
775 {
776 std::ostringstream ss;
777 ss << name << " (" << buildInfo->MajorVersion << '.' << buildInfo->MinorVersion << '.' << buildInfo->BugfixVersion << ')';
778 name = ss.str();
779 }
780
782
783 pkt << uint8(realm.Type); // realm type
784 if (_expversion & POST_BC_EXP_FLAG) // only 2.x and 3.x clients
785 pkt << uint8(lock); // if 1, then realm locked
786
787 pkt << uint8(flag); // RealmFlags
788 pkt << name;
789 pkt << boost::lexical_cast<std::string>(realm.GetAddressForClient(GetRemoteIpAddress()));
790 pkt << float(realm.PopulationLevel);
791 pkt << uint8(characterCounts[realm.Id.Realm]);
792 pkt << uint8(realm.Timezone); // realm category
793
794 if (_expversion & POST_BC_EXP_FLAG) // 2.x and 3.x clients
795 pkt << uint8(realm.Id.Realm);
796 else
797 pkt << uint8(0x0); // 1.12.1 and 1.12.2 clients
798
800 {
801 pkt << uint8(buildInfo->MajorVersion);
802 pkt << uint8(buildInfo->MinorVersion);
803 pkt << uint8(buildInfo->BugfixVersion);
804 pkt << uint16(buildInfo->Build);
805 }
806
807 ++RealmListSize;
808 }
809
810 if (_expversion & POST_BC_EXP_FLAG) // 2.x and 3.x clients
811 {
812 pkt << uint8(0x10);
813 pkt << uint8(0x00);
814 }
815 else // 1.12.1 and 1.12.2 clients
816 {
817 pkt << uint8(0x00);
818 pkt << uint8(0x02);
819 }
820
821 // make a ByteBuffer which stores the RealmList's size
822 ByteBuffer RealmListSizeBuffer;
823 RealmListSizeBuffer << uint32(0);
824
825 if (_expversion & POST_BC_EXP_FLAG) // only 2.x and 3.x clients
826 RealmListSizeBuffer << uint16(RealmListSize);
827 else
828 RealmListSizeBuffer << uint32(RealmListSize);
829
830 ByteBuffer hdr;
831 hdr << uint8(REALM_LIST);
832 hdr << uint16(pkt.size() + RealmListSizeBuffer.size());
833 hdr.append(RealmListSizeBuffer); // append RealmList's size buffer
834 hdr.append(pkt); // append realms in the realmlist
835 SendPacket(hdr);
836
838}
#define sRealmList
Definition RealmList.h:83
@ REALM_FLAG_OFFLINE
Definition Realm.h:29
@ REALM_FLAG_SPECIFYBUILD
Definition Realm.h:30
std::size_t size() const
Definition ByteBuffer.h:444
Realm realm
Definition World.cpp:111
AccountTypes SecurityLevel
Definition AuthSession.h:60
Definition RealmList.h:40
uint32 MajorVersion
Definition RealmList.h:42
uint32 BugfixVersion
Definition RealmList.h:44
uint32 Build
Definition RealmList.h:41
uint32 MinorVersion
Definition RealmList.h:43
uint32 Realm
Definition Realm.h:43
RealmFlags Flags
Definition Realm.h:77
AccountTypes AllowedSecurityLevel
Definition Realm.h:79
boost::asio::ip::tcp_endpoint GetAddressForClient(boost::asio::ip::address const &clientAddr) const
Definition Realm.cpp:23
uint8 Timezone
Definition Realm.h:78
float PopulationLevel
Definition Realm.h:80
uint32 Build
Definition Realm.h:70
std::string Name
Definition Realm.h:75
RealmHandle Id
Definition Realm.h:69
uint8 Type
Definition Realm.h:76

References _accountInfo, _build, _expversion, _status, Realm::AllowedSecurityLevel, ByteBuffer::append(), RealmBuildInfo::BugfixVersion, Realm::Build, RealmBuildInfo::Build, Realm::Flags, Field::Get(), Realm::GetAddressForClient(), Socket< AuthSession >::GetRemoteIpAddress(), Realm::Id, AuthHelper::IsPreBCAcceptedClientBuild(), RealmBuildInfo::MajorVersion, RealmBuildInfo::MinorVersion, Realm::Name, Realm::PopulationLevel, POST_BC_EXP_FLAG, PRE_BC_EXP_FLAG, realm, RealmHandle::Realm, REALM_FLAG_OFFLINE, REALM_FLAG_SPECIFYBUILD, REALM_LIST, AccountInfo::SecurityLevel, SendPacket(), ByteBuffer::size(), sRealmList, STATUS_AUTHED, Realm::Timezone, and Realm::Type.

Referenced by HandleRealmList().

◆ ReconnectChallengeCallback()

void AuthSession::ReconnectChallengeCallback ( PreparedQueryResult  result)
private
656{
657 ByteBuffer pkt;
659
660 if (!result)
661 {
663 SendPacket(pkt);
664 return;
665 }
666
667 Field* fields = result->Fetch();
668
669 _accountInfo.LoadResult(fields);
670 _sessionKey = fields[11].Get<Binary, SESSION_KEY_LENGTH>();
673
674 pkt << uint8(WOW_SUCCESS);
676 pkt.append(VersionChallenge.data(), VersionChallenge.size());
677
678 SendPacket(pkt);
679}
constexpr std::size_t SESSION_KEY_LENGTH
Definition AuthDefines.h:24
std::array< uint8, S > GetRandomBytes()
Definition CryptoRandom.h:35

References _accountInfo, _reconnectProof, _sessionKey, _status, ByteBuffer::append(), AUTH_RECONNECT_CHALLENGE, Field::Get(), Acore::Crypto::GetRandomBytes(), AccountInfo::LoadResult(), SendPacket(), SESSION_KEY_LENGTH, STATUS_RECONNECT_PROOF, VersionChallenge, WOW_FAIL_UNKNOWN_ACCOUNT, and WOW_SUCCESS.

Referenced by HandleReconnectChallenge().

◆ SendPacket()

void AuthSession::SendPacket ( ByteBuffer packet)
271{
272 if (!IsOpen())
273 return;
274
275 if (!packet.empty())
276 {
277 MessageBuffer buffer(packet.size());
278 buffer.Write(packet.contents(), packet.size());
279 QueuePacket(std::move(buffer));
280 }
281}
bool empty() const
Definition ByteBuffer.h:445
void QueuePacket(MessageBuffer &&buffer)
Definition Socket.h:142
bool IsOpen() const
Definition Socket.h:153

References ByteBuffer::contents(), ByteBuffer::empty(), Socket< AuthSession >::IsOpen(), Socket< AuthSession >::QueuePacket(), ByteBuffer::size(), and MessageBuffer::Write().

Referenced by CheckIpCallback(), HandleLogonProof(), HandleReconnectProof(), LogonChallengeCallback(), RealmListCallback(), and ReconnectChallengeCallback().

◆ Start()

void AuthSession::Start ( )
overridevirtual

Implements Socket< AuthSession >.

169{
170 std::string ip_address = GetRemoteIpAddress().to_string();
171 LOG_TRACE("session", "Accepted connection from {}", ip_address);
172
174 stmt->SetData(0, ip_address);
175
176 _queryProcessor.AddCallback(LoginDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&AuthSession::CheckIpCallback, this, std::placeholders::_1)));
177}
#define LOG_TRACE(filterType__,...)
Definition Log.h:173
@ LOGIN_SEL_IP_INFO
Definition LoginDatabase.h:34
void CheckIpCallback(PreparedQueryResult result)
Definition AuthSession.cpp:189

References _queryProcessor, AsyncCallbackProcessor< T >::AddCallback(), CheckIpCallback(), Socket< AuthSession >::GetRemoteIpAddress(), LOG_TRACE, LOGIN_SEL_IP_INFO, LoginDatabase, and PreparedStatementBase::SetData().

◆ Update()

bool AuthSession::Update ( )
overridevirtual

Reimplemented from Socket< AuthSession >.

180{
181 if (!AuthSocket::Update())
182 return false;
183
185
186 return true;
187}
void ProcessReadyCallbacks()
Definition AsyncCallbackProcessor.h:40
virtual bool Update()
Definition Socket.h:70

References _queryProcessor, AsyncCallbackProcessor< T >::ProcessReadyCallbacks(), and Socket< AuthSession >::Update().

◆ VerifyVersion()

bool AuthSession::VerifyVersion ( uint8 const *  a,
int32  aLength,
Acore::Crypto::SHA1::Digest const &  versionProof,
bool  isReconnect 
)
private
841{
842 if (!sConfigMgr->GetOption<bool>("StrictVersionCheck", false))
843 return true;
844
846 Acore::Crypto::SHA1::Digest const* versionHash{ nullptr };
847
848 if (!isReconnect)
849 {
850 RealmBuildInfo const* buildInfo = sRealmList->GetBuildInfo(_build);
851 if (!buildInfo)
852 return false;
853
854 if (_os == "Win")
855 versionHash = &buildInfo->WindowsHash;
856 else if (_os == "OSX")
857 versionHash = &buildInfo->MacHash;
858
859 if (!versionHash)
860 return false;
861
862 if (zeros == *versionHash)
863 return true; // not filled serverside
864 }
865 else
866 versionHash = &zeros;
867
868 Acore::Crypto::SHA1 version;
869 version.UpdateData(a, aLength);
870 version.UpdateData(*versionHash);
871 version.Finalize();
872
873 return (versionProof == version.GetDigest());
874}
std::array< uint8, 20 > WindowsHash
Definition RealmList.h:46
std::array< uint8, 20 > MacHash
Definition RealmList.h:47

References _build, _os, Acore::Impl::GenericHash< HashCreator, DigestLength >::Finalize(), Acore::Impl::GenericHash< HashCreator, DigestLength >::GetDigest(), RealmBuildInfo::MacHash, sConfigMgr, sRealmList, Acore::Impl::GenericHash< HashCreator, DigestLength >::UpdateData(), and RealmBuildInfo::WindowsHash.

Referenced by HandleLogonProof(), and HandleReconnectProof().

Member Data Documentation

◆ _accountInfo

◆ _build

◆ _expversion

uint8 AuthSession::_expversion
private

◆ _ipCountry

std::string AuthSession::_ipCountry
private

Referenced by LogonChallengeCallback().

◆ _localizationName

std::string AuthSession::_localizationName
private

◆ _os

std::string AuthSession::_os
private

◆ _queryProcessor

◆ _reconnectProof

std::array<uint8, 16> AuthSession::_reconnectProof = {}
private

◆ _sessionKey

SessionKey AuthSession::_sessionKey = {}
private

◆ _srp6

Optional<Acore::Crypto::SRP6> AuthSession::_srp6
private

◆ _status

◆ _totpSecret

Optional<std::vector<uint8> > AuthSession::_totpSecret
private

◆ Account

std::string AuthSession::Account

◆ AddonInfo

ByteBuffer AuthSession::AddonInfo

◆ BattlegroupID

uint32 AuthSession::BattlegroupID = 0

◆ Build

uint32 AuthSession::Build = 0

◆ Digest

Acore::Crypto::SHA1::Digest AuthSession::Digest = {}
342{};

◆ DosResponse

uint64 AuthSession::DosResponse = 0

◆ LocalChallenge

std::array<uint8, 4> AuthSession::LocalChallenge = {}
338{};

◆ LoginServerID

uint32 AuthSession::LoginServerID = 0

◆ LoginServerType

uint32 AuthSession::LoginServerType = 0

◆ RealmID

uint32 AuthSession::RealmID = 0

◆ RegionID

uint32 AuthSession::RegionID = 0

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