diff options
Diffstat (limited to 'src')
| -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 | ||||
| -rw-r--r-- | src/server/shared/Realm/RealmList.cpp | 42 | ||||
| -rw-r--r-- | src/server/shared/Realm/RealmList.h | 16 |
5 files changed, 97 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; diff --git a/src/server/shared/Realm/RealmList.cpp b/src/server/shared/Realm/RealmList.cpp index ec0a707eb61..a8d7dab9337 100644 --- a/src/server/shared/Realm/RealmList.cpp +++ b/src/server/shared/Realm/RealmList.cpp @@ -46,6 +46,7 @@ void RealmList::Initialize(Trinity::Asio::IoContext& ioContext, uint32 updateInt _updateTimer = Trinity::make_unique<Trinity::Asio::DeadlineTimer>(ioContext); _resolver = Trinity::make_unique<boost::asio::ip::tcp::resolver>(ioContext); + LoadBuildInfo(); // Get the content of the realmlist table in the database UpdateRealms(boost::system::error_code()); } @@ -55,6 +56,38 @@ void RealmList::Close() _updateTimer->cancel(); } +void RealmList::LoadBuildInfo() +{ + // 0 1 2 3 4 5 6 + if (QueryResult result = LoginDatabase.Query("SELECT majorVersion, minorVersion, bugfixVersion, hotfixVersion, build, winChecksumSeed, macChecksumSeed FROM build_info ORDER BY build ASC")) + { + do + { + Field* fields = result->Fetch(); + _builds.emplace_back(); + RealmBuildInfo& build = _builds.back(); + build.MajorVersion = fields[0].GetUInt32(); + build.MinorVersion = fields[1].GetUInt32(); + build.BugfixVersion = fields[2].GetUInt32(); + std::string hotfixVersion = fields[3].GetString(); + if (hotfixVersion.length() < build.HotfixVersion.size()) + std::copy(hotfixVersion.begin(), hotfixVersion.end(), build.HotfixVersion.begin()); + else + std::fill(hotfixVersion.begin(), hotfixVersion.end(), '\0'); + + build.Build = fields[4].GetUInt32(); + std::string windowsHash = fields[5].GetString(); + if (windowsHash.length() == build.WindowsHash.size() * 2) + HexStrToByteArray(windowsHash, build.WindowsHash.data()); + + std::string macHash = fields[6].GetString(); + if (macHash.length() == build.MacHash.size() * 2) + HexStrToByteArray(macHash, build.MacHash.data()); + + } while (result->NextRow()); + } +} + void RealmList::UpdateRealm(RealmHandle const& id, uint32 build, std::string const& name, boost::asio::ip::address&& address, boost::asio::ip::address&& localAddr, boost::asio::ip::address&& localSubmask, uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float population) @@ -181,3 +214,12 @@ Realm const* RealmList::GetRealm(RealmHandle const& id) const return nullptr; } + +RealmBuildInfo const* RealmList::GetBuildInfo(uint32 build) const +{ + for (RealmBuildInfo const& clientBuild : _builds) + if (clientBuild.Build == build) + return &clientBuild; + + return nullptr; +} diff --git a/src/server/shared/Realm/RealmList.h b/src/server/shared/Realm/RealmList.h index 62f615c0cae..b7358afa35a 100644 --- a/src/server/shared/Realm/RealmList.h +++ b/src/server/shared/Realm/RealmList.h @@ -21,10 +21,22 @@ #include "Define.h" #include "Realm.h" +#include <array> #include <map> #include <vector> #include <unordered_set> +struct RealmBuildInfo +{ + uint32 Build; + uint32 MajorVersion; + uint32 MinorVersion; + uint32 BugfixVersion; + std::array<char, 4> HotfixVersion; + std::array<uint8, 20> WindowsHash; + std::array<uint8, 20> MacHash; +}; + namespace boost { namespace system @@ -58,14 +70,18 @@ public: RealmMap const& GetRealms() const { return _realms; } Realm const* GetRealm(RealmHandle const& id) const; + RealmBuildInfo const* GetBuildInfo(uint32 build) const; + private: RealmList(); + void LoadBuildInfo(); void UpdateRealms(boost::system::error_code const& error); void UpdateRealm(RealmHandle const& id, uint32 build, std::string const& name, boost::asio::ip::address&& address, boost::asio::ip::address&& localAddr, boost::asio::ip::address&& localSubmask, uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float population); + std::vector<RealmBuildInfo> _builds; RealmMap _realms; uint32 _updateInterval; std::unique_ptr<Trinity::Asio::DeadlineTimer> _updateTimer; |
