diff options
| author | Shauren <shauren.trinity@gmail.com> | 2019-12-07 13:02:10 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2019-12-07 13:14:16 +0100 |
| commit | b990a79fd8643159ebe5c302c564c9ef52b2b5c6 (patch) | |
| tree | c9c0ccbe1111f8180f12b4f8d23f550404253a9f /src/server/authserver | |
| parent | 60763fc5e2d7bb32150d8e03bfd0fb3e7cb890f3 (diff) | |
Core/Realms: Move build info (and auth seeds) to database
(cherry picked from commit 61f2eed3531ebfd2585ab05add31ae9e97598233)
Diffstat (limited to 'src/server/authserver')
| -rw-r--r-- | src/server/authserver/Authentication/AuthCodes.cpp | 61 | ||||
| -rw-r--r-- | src/server/authserver/Authentication/AuthCodes.h | 12 | ||||
| -rw-r--r-- | src/server/authserver/Server/AuthSession.cpp | 65 |
3 files changed, 39 insertions, 99 deletions
diff --git a/src/server/authserver/Authentication/AuthCodes.cpp b/src/server/authserver/Authentication/AuthCodes.cpp index 982cf1cb465..a3877c26ce2 100644 --- a/src/server/authserver/Authentication/AuthCodes.cpp +++ b/src/server/authserver/Authentication/AuthCodes.cpp @@ -16,75 +16,24 @@ */ #include "AuthCodes.h" +#include "RealmList.h" namespace AuthHelper { - static RealmBuildInfo const PostBcAcceptedClientBuilds[] = - { - {15595, 4, 3, 4, ' ', {{}}, {{}}}, - {14545, 4, 2, 2, ' ', {{}}, {{}}}, - {13623, 4, 0, 6, 'a', {{}}, {{}}}, - {13930, 3, 3, 5, 'a', {{}}, {{}}}, // 3.3.5a China Mainland build - {12340, 3, 3, 5, 'a', - {{ 0xCD, 0xCB, 0xBD, 0x51, 0x88, 0x31, 0x5E, 0x6B, 0x4D, 0x19, 0x44, 0x9D, 0x49, 0x2D, 0xBC, 0xFA, 0xF1, 0x56, 0xA3, 0x47 }}, - {{ 0xB7, 0x06, 0xD1, 0x3F, 0xF2, 0xF4, 0x01, 0x88, 0x39, 0x72, 0x94, 0x61, 0xE3, 0xF8, 0xA0, 0xE2, 0xB5, 0xFD, 0xC0, 0x34 }}, - }, - {11723, 3, 3, 3, 'a', {{}}, {{}}}, - {11403, 3, 3, 2, ' ', {{}}, {{}}}, - {11159, 3, 3, 0, 'a', {{}}, {{}}}, - {10505, 3, 2, 2, 'a', {{}}, {{}}}, - {9947, 3, 1, 3, ' ', {{}}, {{}}}, - {8606, 2, 4, 3, ' ', - {{ 0x31, 0x9A, 0xFA, 0xA3, 0xF2, 0x55, 0x96, 0x82, 0xF9, 0xFF, 0x65, 0x8B, 0xE0, 0x14, 0x56, 0x25, 0x5F, 0x45, 0x6F, 0xB1 }}, - {{}}, - }, - {0, 0, 0, 0, ' ', {{}}, {{}}} // terminator - }; - - static RealmBuildInfo const PreBcAcceptedClientBuilds[] = - { - {6141, 1, 12, 3, ' ', {{}}, {{}}}, - {6005, 1, 12, 2, ' ', {{}}, {{}}}, - {5875, 1, 12, 1, ' ', - {{}}, - {{ 0x8D, 0x17, 0x3C, 0xC3, 0x81, 0x96, 0x1E, 0xEB, 0xAB, 0xF3, 0x36, 0xF5, 0xE6, 0x67, 0x5B, 0x10, 0x1B, 0xB5, 0x13, 0xE5 }}, - }, - {0, 0, 0, 0, ' ', {{}}, {{}}} // terminator - }; + constexpr static uint32 MAX_PRE_BC_CLIENT_BUILD = 6141; bool IsPreBCAcceptedClientBuild(int build) { - for (int i = 0; PreBcAcceptedClientBuilds[i].Build; ++i) - if (PreBcAcceptedClientBuilds[i].Build == build) - return true; - - return false; + return build <= MAX_PRE_BC_CLIENT_BUILD && sRealmList->GetBuildInfo(build); } bool IsPostBCAcceptedClientBuild(int build) { - for (int i = 0; PostBcAcceptedClientBuilds[i].Build; ++i) - if (PostBcAcceptedClientBuilds[i].Build == build) - return true; - - return false; + return build > MAX_PRE_BC_CLIENT_BUILD && sRealmList->GetBuildInfo(build); } bool IsAcceptedClientBuild(int build) { - return (IsPostBCAcceptedClientBuild(build) || IsPreBCAcceptedClientBuild(build)); - } - - RealmBuildInfo const* GetBuildInfo(int build) - { - for (int i = 0; PostBcAcceptedClientBuilds[i].Build; ++i) - if (PostBcAcceptedClientBuilds[i].Build == build) - return &PostBcAcceptedClientBuilds[i]; - - for (int i = 0; PreBcAcceptedClientBuilds[i].Build; ++i) - if (PreBcAcceptedClientBuilds[i].Build == build) - return &PreBcAcceptedClientBuilds[i]; - - return nullptr; + return sRealmList->GetBuildInfo(build) != nullptr; } } diff --git a/src/server/authserver/Authentication/AuthCodes.h b/src/server/authserver/Authentication/AuthCodes.h index c734a87968f..1441e0e16f3 100644 --- a/src/server/authserver/Authentication/AuthCodes.h +++ b/src/server/authserver/Authentication/AuthCodes.h @@ -80,20 +80,10 @@ enum ExpansionFlags NO_VALID_EXP_FLAG = 0x0 }; -struct RealmBuildInfo -{ - int Build; - int MajorVersion; - int MinorVersion; - int BugfixVersion; - int HotfixVersion; - std::array<uint8, 20> WindowsHash; - std::array<uint8, 20> MacHash; -}; +struct RealmBuildInfo; namespace AuthHelper { - RealmBuildInfo const* GetBuildInfo(int build); bool IsAcceptedClientBuild(int build); bool IsPostBCAcceptedClientBuild(int build); bool IsPreBCAcceptedClientBuild(int build); diff --git a/src/server/authserver/Server/AuthSession.cpp b/src/server/authserver/Server/AuthSession.cpp index 5c0628334fd..3dd5bd11e30 100644 --- a/src/server/authserver/Server/AuthSession.cpp +++ b/src/server/authserver/Server/AuthSession.cpp @@ -430,41 +430,42 @@ void AuthSession::LogonChallengeCallback(PreparedQueryResult result) if (AuthHelper::IsAcceptedClientBuild(_build)) { pkt << uint8(WOW_SUCCESS); - _status = STATUS_LOGON_PROOF; - } - else - pkt << uint8(WOW_FAIL_VERSION_INVALID); - // B may be calculated < 32B so we force minimal length to 32B - pkt.append(B.AsByteArray(32).get(), 32); // 32 bytes - pkt << uint8(1); - pkt.append(g.AsByteArray(1).get(), 1); - pkt << uint8(32); - pkt.append(N.AsByteArray(32).get(), 32); - pkt.append(s.AsByteArray(int32(BufferSizes::SRP_6_S)).get(), size_t(BufferSizes::SRP_6_S)); // 32 bytes - pkt.append(VersionChallenge.data(), VersionChallenge.size()); - pkt << uint8(securityFlags); // security flags (0x0...0x04) + // B may be calculated < 32B so we force minimal length to 32B + pkt.append(B.AsByteArray(32).get(), 32); // 32 bytes + pkt << uint8(1); + pkt.append(g.AsByteArray(1).get(), 1); + pkt << uint8(32); + pkt.append(N.AsByteArray(32).get(), 32); + pkt.append(s.AsByteArray(int32(BufferSizes::SRP_6_S)).get(), size_t(BufferSizes::SRP_6_S)); // 32 bytes + pkt.append(VersionChallenge.data(), VersionChallenge.size()); + pkt << uint8(securityFlags); // security flags (0x0...0x04) + + if (securityFlags & 0x01) // PIN input + { + pkt << uint32(0); + pkt << uint64(0) << uint64(0); // 16 bytes hash? + } - if (securityFlags & 0x01) // PIN input - { - pkt << uint32(0); - pkt << uint64(0) << uint64(0); // 16 bytes hash? - } + if (securityFlags & 0x02) // Matrix input + { + pkt << uint8(0); + pkt << uint8(0); + pkt << uint8(0); + pkt << uint8(0); + pkt << uint64(0); + } - if (securityFlags & 0x02) // Matrix input - { - pkt << uint8(0); - pkt << uint8(0); - pkt << uint8(0); - pkt << uint8(0); - pkt << uint64(0); - } + if (securityFlags & 0x04) // Security token input + pkt << uint8(1); - if (securityFlags & 0x04) // Security token input - pkt << uint8(1); + TC_LOG_DEBUG("server.authserver", "'%s:%d' [AuthChallenge] account %s is using '%s' locale (%u)", + ipAddress.c_str(), port, _accountInfo.Login.c_str(), _localizationName.c_str(), GetLocaleByName(_localizationName)); - TC_LOG_DEBUG("server.authserver", "'%s:%d' [AuthChallenge] account %s is using '%s' locale (%u)", - ipAddress.c_str(), port, _accountInfo.Login.c_str(), _localizationName.c_str(), GetLocaleByName(_localizationName)); + _status = STATUS_LOGON_PROOF; + } + else + pkt << uint8(WOW_FAIL_VERSION_INVALID); SendPacket(pkt); } @@ -849,7 +850,7 @@ void AuthSession::RealmListCallback(PreparedQueryResult result) // No SQL injection. id of realm is controlled by the database. uint32 flag = realm.Flags; - RealmBuildInfo const* buildInfo = AuthHelper::GetBuildInfo(realm.Build); + RealmBuildInfo const* buildInfo = sRealmList->GetBuildInfo(realm.Build); if (!okBuild) { if (!buildInfo) @@ -964,7 +965,7 @@ bool AuthSession::VerifyVersion(uint8 const* a, int32 aLength, uint8 const* vers std::array<uint8, 20> const* versionHash = nullptr; if (!isReconnect) { - RealmBuildInfo const* buildInfo = AuthHelper::GetBuildInfo(_build); + RealmBuildInfo const* buildInfo = sRealmList->GetBuildInfo(_build); if (!buildInfo) return false; |
