From a142eb9f7a9683f98fe1e9153f6958f80d374c9d Mon Sep 17 00:00:00 2001 From: Shauren Date: Wed, 30 Apr 2014 20:16:08 +0200 Subject: Core/Auth: Battle.net stuff --- src/server/authserver/Authentication/AuthCodes.h | 51 ++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'src/server/authserver/Authentication/AuthCodes.h') diff --git a/src/server/authserver/Authentication/AuthCodes.h b/src/server/authserver/Authentication/AuthCodes.h index 5e6522f8981..e844863e4b1 100644 --- a/src/server/authserver/Authentication/AuthCodes.h +++ b/src/server/authserver/Authentication/AuthCodes.h @@ -70,6 +70,57 @@ enum LoginResult LOGIN_LOCKED_ENFORCED = 0x10 }; +namespace Battlenet +{ + enum AuthResult + { + AUTH_OK = 0, + AUTH_BAD_SERVER_PROOF = 103, + AUTH_UNKNOWN_ACCOUNT = 104, + AUTH_CLOSED = 105, + AUTH_LOGIN_TIMEOUT = 106, + AUTH_NO_GAME_ACCOUNTS = 107, + AUTH_INVALID_TOKEN = 108, + AUTH_INVALID_PROGRAM = 109, + AUTH_INVALID_OS = 110, + AUTH_UNSUPPORTED_LANGUAGE = 111, + AUTH_REGION_BAD_VERSION = 112, + AUTH_TEMP_OUTAGE = 113, + AUTH_CANT_DOWNLOAD_MODULE = 114, + AUTH_DUPLICATE_LOGON = 115, + AUTH_BAD_CREDENTIALS_2 = 116, + AUTH_VERSION_CHECK_SUCCEEDED = 117, + AUTH_BAD_VERSION_HASH = 118, + AUTH_CANT_RETRIEVE_PORTAL_LIST = 119, + AUTH_DARK_PORTAL_DOES_NOT_EXIST = 120, + AUTH_DARK_PORTAL_FILE_CORRUPTED = 121, + AUTH_BATTLENET_MAINTENANCE = 122, + AUTH_LOGON_TOO_FAST = 123, + AUTH_USE_GRUNT_LOGON = 124, + + LOGIN_NO_GAME_ACCOUNT = 201, + LOGIN_BANNED = 202, + LOGIN_SUSPENDED = 203, + LOGIN_GAME_ACCOUNT_LOCKED = 204, + LOGIN_ALREADY_ONLINE = 205, + LOGIN_NOTIME = 206, + LOGIN_EXPIRED = 207, + LOGIN_EXPIRED_2 = 208, + LOGIN_PARENTALCONTROL = 209, + LOGIN_TRIAL_EXPIRED = 210, + LOGIN_ANTI_INDULGENCE = 211, + LOGIN_INCORRECT_REGION = 212, + LOGIN_CHARGEBACK = 213, + LOGIN_IGR_WITHOUT_BNET = 214, + LOGIN_LOCKED_ENFORCED = 215, + LOGIN_UNLOCKABLE_LOCK = 216, + LOGIN_IGR_REQUIRED = 217, + LOGIN_PAYMENT_CHANGED = 218, + LOGIN_INVALID_PAYMENT = 219, + LOGIN_INVALID_ACCOUNT_STATE = 220 + }; +} + enum ExpansionFlags { POST_BC_EXP_FLAG = 0x2, -- cgit v1.2.3 From 6955d7c9ad0e55480aa97d9cafd878c6bc3dc426 Mon Sep 17 00:00:00 2001 From: Shauren Date: Fri, 2 May 2014 02:55:10 +0200 Subject: Core/Battle.net * Fixed AuthResult codes * Fixed BitStream::WriteBytes size check * Fixed comparison operator for packet header * Fixed channel for client packets without channel * Implemented loading modules from database --- src/server/authserver/Authentication/AuthCodes.h | 9 +++-- src/server/authserver/Server/BattlenetBitStream.h | 12 +++++- src/server/authserver/Server/BattlenetManager.cpp | 38 +++++++++++++++++- src/server/authserver/Server/BattlenetManager.h | 47 +++++++++++++++++++++-- src/server/authserver/Server/BattlenetPackets.cpp | 33 ++++++++-------- src/server/authserver/Server/BattlenetPackets.h | 18 ++++----- src/server/authserver/Server/BattlenetSocket.cpp | 34 ++++++++++++++-- src/server/authserver/Server/BattlenetSocket.h | 2 + src/server/shared/Utilities/Util.cpp | 25 ++++++++++++ src/server/shared/Utilities/Util.h | 1 + 10 files changed, 179 insertions(+), 40 deletions(-) (limited to 'src/server/authserver/Authentication/AuthCodes.h') diff --git a/src/server/authserver/Authentication/AuthCodes.h b/src/server/authserver/Authentication/AuthCodes.h index e844863e4b1..12c2a810abb 100644 --- a/src/server/authserver/Authentication/AuthCodes.h +++ b/src/server/authserver/Authentication/AuthCodes.h @@ -97,7 +97,10 @@ namespace Battlenet AUTH_BATTLENET_MAINTENANCE = 122, AUTH_LOGON_TOO_FAST = 123, AUTH_USE_GRUNT_LOGON = 124, + AUTH_NO_GAME_ACCOUNTS_IN_REGION = 140, + AUTH_ACCOUNT_LOCKED = 141, + LOGIN_SERVER_BUSY = 200, LOGIN_NO_GAME_ACCOUNT = 201, LOGIN_BANNED = 202, LOGIN_SUSPENDED = 203, @@ -110,9 +113,9 @@ namespace Battlenet LOGIN_TRIAL_EXPIRED = 210, LOGIN_ANTI_INDULGENCE = 211, LOGIN_INCORRECT_REGION = 212, - LOGIN_CHARGEBACK = 213, - LOGIN_IGR_WITHOUT_BNET = 214, - LOGIN_LOCKED_ENFORCED = 215, + LOGIN_LOCKED_ENFORCED = 213, + LOGIN_CHARGEBACK = 214, + LOGIN_IGR_WITHOUT_BNET = 215, LOGIN_UNLOCKABLE_LOCK = 216, LOGIN_IGR_REQUIRED = 217, LOGIN_PAYMENT_CHANGED = 218, diff --git a/src/server/authserver/Server/BattlenetBitStream.h b/src/server/authserver/Server/BattlenetBitStream.h index 4b6c7f882d4..d372e0933c2 100644 --- a/src/server/authserver/Server/BattlenetBitStream.h +++ b/src/server/authserver/Server/BattlenetBitStream.h @@ -22,16 +22,21 @@ #include #include #include +#include namespace Battlenet { class BitStreamPositionException : public std::exception { public: + BitStreamPositionException() : st(1) { } + char const* what() const { - return ""; + return st.c_str(); } + + ACE_Stack_Trace st; }; class BitStream @@ -121,7 +126,10 @@ namespace Battlenet void WriteBytes(T* data, uint32 count) { AlignToNextByte(); - if (_writePos + 8 * count > MaxSize) + if (!count || !data) + return; + + if (_writePos + count > MaxSize) throw BitStreamPositionException(); _buffer.resize(_buffer.size() + count); diff --git a/src/server/authserver/Server/BattlenetManager.cpp b/src/server/authserver/Server/BattlenetManager.cpp index b7df889809e..a43512e612e 100644 --- a/src/server/authserver/Server/BattlenetManager.cpp +++ b/src/server/authserver/Server/BattlenetManager.cpp @@ -18,6 +18,15 @@ #include "BattlenetManager.h" #include "DatabaseEnv.h" +BattlenetMgr::~BattlenetMgr() +{ + for (Battlenet::Component* component : _components) + delete component; + + for (auto const& m : _modules) + delete m.second; +} + void BattlenetMgr::Load() { LoadComponents(); @@ -40,7 +49,6 @@ void BattlenetMgr::LoadComponents() _components.insert(component); _programs.insert(component->Program); _platforms.insert(component->Platform); - _builds.insert(component->Build); } while (result->NextRow()); } @@ -48,7 +56,27 @@ void BattlenetMgr::LoadComponents() void BattlenetMgr::LoadModules() { + QueryResult result = LoginDatabase.Query("SELECT `Hash`, `Name`, `Type`, `System`, `Data` FROM battlenet_modules"); + if (result) + { + do + { + Field* fields = result->Fetch(); + Battlenet::ModuleInfo* module = new Battlenet::ModuleInfo(); + module->Type = fields[2].GetString(); + module->Region.assign("\0\0EU", 4); + HexStrToByteArray(fields[0].GetString(), module->ModuleId); + std::string data = fields[4].GetString(); + module->DataSize = data.length() / 2; + if (module->DataSize) + { + module->Data = new uint8[data.length() / 2]; + HexStrToByteArray(data, module->Data); + } + _modules[{ fields[3].GetString(), fields[1].GetString() }] = module; + } while (result->NextRow()); + } } bool BattlenetMgr::HasComponent(Battlenet::Component const* component) const @@ -59,3 +87,11 @@ bool BattlenetMgr::HasComponent(Battlenet::Component const* component) const return false; } + +Battlenet::ModuleInfo const* BattlenetMgr::GetModule(Battlenet::ModuleKey const& key) const +{ + if (_modules.count(key)) + return _modules.at(key); + + return NULL; +} diff --git a/src/server/authserver/Server/BattlenetManager.h b/src/server/authserver/Server/BattlenetManager.h index d3962a32c0d..9fceb973770 100644 --- a/src/server/authserver/Server/BattlenetManager.h +++ b/src/server/authserver/Server/BattlenetManager.h @@ -32,20 +32,61 @@ namespace Battlenet std::string Platform; uint32 Build; }; + + struct ModuleKey + { + std::string Platform; + std::string Name; + + bool operator<(ModuleKey const& right) const + { + int32 res = Platform.compare(right.Platform); + if (res < 0) + return true; + else if (res > 0) + return false; + + return Name < right.Name; + } + }; + + struct ModuleInfo + { + ModuleInfo() : DataSize(0), Data(nullptr) { } + ModuleInfo(ModuleInfo const& right) : Type(right.Type), Region(right.Region), DataSize(right.DataSize), Data(nullptr) + { + memcpy(ModuleId, right.ModuleId, 32); + if (DataSize) + { + Data = new uint8[DataSize]; + memcpy(Data, right.Data, DataSize); + } + } + ~ModuleInfo() + { + delete Data; + } + + std::string Type; + std::string Region; + uint8 ModuleId[32]; + uint32 DataSize; + uint8* Data; + }; } class BattlenetMgr { friend class ACE_Singleton; BattlenetMgr() { } - ~BattlenetMgr() { } + ~BattlenetMgr(); public: void Load(); bool HasComponent(Battlenet::Component const* component) const; bool HasProgram(std::string const& program) const { return _programs.count(program); } bool HasPlatform(std::string const& platform) const { return _platforms.count(platform); } - bool HasBuild(uint32 build) const { return _builds.count(build); } + Battlenet::ModuleInfo const* GetModule(Battlenet::ModuleKey const& key) const; private: void LoadComponents(); @@ -54,7 +95,7 @@ private: std::set _components; std::set _programs; std::set _platforms; - std::set _builds; + std::map _modules; }; #define sBattlenetMgr ACE_Singleton::instance() diff --git a/src/server/authserver/Server/BattlenetPackets.cpp b/src/server/authserver/Server/BattlenetPackets.cpp index 80213a0ba33..68a602d8598 100644 --- a/src/server/authserver/Server/BattlenetPackets.cpp +++ b/src/server/authserver/Server/BattlenetPackets.cpp @@ -78,14 +78,13 @@ std::string Battlenet::AuthChallenge::ToString() const void Battlenet::ProofRequest::Write() { _stream.Write(Modules.size(), 3); - for (size_t i = 0; i < Modules.size(); ++i) + for (ModuleInfo const* info : Modules) { - ModuleInfo& info = Modules[i]; - _stream.WriteBytes(info.AuthString.c_str(), 4); - _stream.WriteFourCC(info.Locale.c_str()); - _stream.WriteBytes(info.ModuleId, 32); - _stream.Write(info.BlobSize, 10); - _stream.WriteBytes(info.Blob, info.BlobSize); + _stream.WriteBytes(info->Type.c_str(), 4); + _stream.WriteFourCC(info->Region.c_str()); + _stream.WriteBytes(info->ModuleId, 32); + _stream.Write(info->DataSize, 10); + _stream.WriteBytes(info->Data, info->DataSize); } } @@ -93,8 +92,8 @@ std::string Battlenet::ProofRequest::ToString() const { std::ostringstream stream; stream << "Battlenet::ProofRequest modules " << Modules.size(); - for (ModuleInfo const& module : Modules) - stream << std::endl << "Locale " << module.Locale << "ModuleId " << ByteArrayToHexStr(module.ModuleId, 32) << "BlobSize " << module.BlobSize; + for (ModuleInfo const* module : Modules) + stream << std::endl << "Locale " << module->Region << "ModuleId " << ByteArrayToHexStr(module->ModuleId, 32) << "BlobSize " << module->DataSize; return stream.str(); } @@ -138,11 +137,11 @@ void Battlenet::AuthComplete::Write() for (size_t i = 0; i < Modules.size(); ++i) { ModuleInfo& info = Modules[i]; - _stream.WriteBytes(info.AuthString.c_str(), 4); - _stream.WriteFourCC(info.Locale.c_str()); + _stream.WriteBytes(info.Type.c_str(), 4); + _stream.WriteFourCC(info.Region.c_str()); _stream.WriteBytes(info.ModuleId, 32); - _stream.Write(info.BlobSize, 10); - _stream.WriteBytes(info.Blob, info.BlobSize); + _stream.Write(info.DataSize, 10); + _stream.WriteBytes(info.Data, info.DataSize); } _stream.Write(PingTimeout + std::numeric_limits::min(), 32); @@ -165,11 +164,11 @@ void Battlenet::AuthComplete::Write() if (!Modules.empty()) { ModuleInfo& info = Modules[0]; - _stream.WriteBytes(info.AuthString.c_str(), 4); - _stream.WriteFourCC(info.Locale.c_str()); + _stream.WriteBytes(info.Type.c_str(), 4); + _stream.WriteFourCC(info.Region.c_str()); _stream.WriteBytes(info.ModuleId, 32); - _stream.Write(info.BlobSize, 10); - _stream.WriteBytes(info.Blob, info.BlobSize); + _stream.Write(info.DataSize, 10); + _stream.WriteBytes(info.Data, info.DataSize); } _stream.Write(ErrorType, 2); diff --git a/src/server/authserver/Server/BattlenetPackets.h b/src/server/authserver/Server/BattlenetPackets.h index 86dcb99a4da..3b02c0c602a 100644 --- a/src/server/authserver/Server/BattlenetPackets.h +++ b/src/server/authserver/Server/BattlenetPackets.h @@ -58,7 +58,12 @@ namespace Battlenet bool operator<(PacketHeader const& right) const { - return Opcode < right.Opcode || Channel < right.Channel; + if (Opcode < right.Opcode) + return true; + if (Opcode > right.Opcode) + return false; + + return Channel < right.Channel; } bool operator==(PacketHeader const& right) const @@ -133,15 +138,6 @@ namespace Battlenet std::string Login; }; - struct ModuleInfo - { - std::string AuthString; - std::string Locale; - uint8 ModuleId[32]; - uint32 BlobSize; - uint8* Blob; - }; - class ProofRequest final : public ServerPacket { public: @@ -150,7 +146,7 @@ namespace Battlenet void Write() override; std::string ToString() const override; - std::vector Modules; + std::vector Modules; }; class ProofResponse final : public ClientPacket diff --git a/src/server/authserver/Server/BattlenetSocket.cpp b/src/server/authserver/Server/BattlenetSocket.cpp index 04005e30878..edd73080270 100644 --- a/src/server/authserver/Server/BattlenetSocket.cpp +++ b/src/server/authserver/Server/BattlenetSocket.cpp @@ -25,6 +25,32 @@ bool Battlenet::Socket::HandleAuthChallenge(PacketHeader& header, BitStream& pac AuthChallenge info(header, packet); info.Read(); + printf("%s\n", info.ToString().c_str()); + + if (info.Program != "WoW") + { + AuthComplete complete; + complete.SetAuthResult(AUTH_INVALID_PROGRAM); + Send(complete); + return true; + } + + if (!sBattlenetMgr->HasPlatform(info.Platform)) + { + AuthComplete complete; + complete.SetAuthResult(AUTH_INVALID_OS); + Send(complete); + return true; + } + + if (!sBattlenetMgr->HasPlatform(info.Locale)) + { + AuthComplete complete; + complete.SetAuthResult(AUTH_UNSUPPORTED_LANGUAGE); + Send(complete); + return true; + } + for (Component const& component : info.Components) { if (!sBattlenetMgr->HasComponent(&component)) @@ -34,7 +60,7 @@ bool Battlenet::Socket::HandleAuthChallenge(PacketHeader& header, BitStream& pac complete.SetAuthResult(AUTH_INVALID_PROGRAM); else if (!sBattlenetMgr->HasPlatform(component.Platform)) complete.SetAuthResult(AUTH_INVALID_OS); - else if (!sBattlenetMgr->HasBuild(component.Build)) + else complete.SetAuthResult(AUTH_REGION_BAD_VERSION); Send(complete); @@ -42,9 +68,9 @@ bool Battlenet::Socket::HandleAuthChallenge(PacketHeader& header, BitStream& pac } } - printf("%s\n", info.ToString().c_str()); - _accountName = info.Login; + _locale = info.Locale; + _os = info.Platform; ProofRequest request; Send(request); @@ -101,6 +127,8 @@ void Battlenet::Socket::OnRead() header.Opcode = packet.Read(6); if (packet.Read(1)) _currentChannel = header.Channel = packet.Read(4); + else + header.Channel = _currentChannel; printf("Battlenet::Socket::OnRead %s\n", header.ToString().c_str()); std::map::const_iterator itr = Handlers.find(header); diff --git a/src/server/authserver/Server/BattlenetSocket.h b/src/server/authserver/Server/BattlenetSocket.h index 7507f090a7f..b4db6c46251 100644 --- a/src/server/authserver/Server/BattlenetSocket.h +++ b/src/server/authserver/Server/BattlenetSocket.h @@ -48,6 +48,8 @@ namespace Battlenet uint32 _currentChannel; std::string _accountName; + std::string _locale; + std::string _os; PacketCrypt _crypt; }; diff --git a/src/server/shared/Utilities/Util.cpp b/src/server/shared/Utilities/Util.cpp index f2a6f1b7622..004335422c0 100644 --- a/src/server/shared/Utilities/Util.cpp +++ b/src/server/shared/Utilities/Util.cpp @@ -547,3 +547,28 @@ std::string ByteArrayToHexStr(uint8 const* bytes, uint32 arrayLen, bool reverse return ss.str(); } + +void HexStrToByteArray(std::string const& str, uint8* out, bool reverse /*= false*/) +{ + // string must have even number of characters + if (str.length() & 1) + return; + + int32 init = 0; + int32 end = str.length(); + int8 op = 1; + + if (reverse) + { + init = str.length() - 2; + end = -1; + op = -1; + } + + uint32 j = 0; + for (int32 i = init; i != end; i += 2 * op) + { + char buffer[3] = { str[i], str[i + 1], '\0' }; + out[j++] = strtoul(buffer, NULL, 16); + } +} diff --git a/src/server/shared/Utilities/Util.h b/src/server/shared/Utilities/Util.h index 236670e5cf1..d1cfeadff64 100644 --- a/src/server/shared/Utilities/Util.h +++ b/src/server/shared/Utilities/Util.h @@ -355,6 +355,7 @@ std::string GetAddressString(ACE_INET_Addr const& addr); uint32 CreatePIDFile(const std::string& filename); std::string ByteArrayToHexStr(uint8 const* bytes, uint32 length, bool reverse = false); +void HexStrToByteArray(std::string const& str, uint8* out, bool reverse = false); #endif //handler for operations on large flags -- cgit v1.2.3 From 769fadd104978b8a45995dc652539b2c619b54f1 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 4 May 2014 00:59:24 +0200 Subject: Core/Battle.net * Extended AuthResult enum * Implemented WriteString in BitStream * Fixed HexStrToByteArray in reverse mode --- src/server/authserver/Authentication/AuthCodes.h | 2 ++ src/server/authserver/Server/BattlenetBitStream.h | 8 ++++++-- src/server/shared/Utilities/Util.cpp | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src/server/authserver/Authentication/AuthCodes.h') diff --git a/src/server/authserver/Authentication/AuthCodes.h b/src/server/authserver/Authentication/AuthCodes.h index 12c2a810abb..158029bcefc 100644 --- a/src/server/authserver/Authentication/AuthCodes.h +++ b/src/server/authserver/Authentication/AuthCodes.h @@ -75,6 +75,8 @@ namespace Battlenet enum AuthResult { AUTH_OK = 0, + AUTH_INTERNAL_ERROR = 100, + AUTH_CORRUPTED_MODULE = 102, AUTH_BAD_SERVER_PROOF = 103, AUTH_UNKNOWN_ACCOUNT = 104, AUTH_CLOSED = 105, diff --git a/src/server/authserver/Server/BattlenetBitStream.h b/src/server/authserver/Server/BattlenetBitStream.h index 9d5f4c85f0d..bff1bffb3ab 100644 --- a/src/server/authserver/Server/BattlenetBitStream.h +++ b/src/server/authserver/Server/BattlenetBitStream.h @@ -61,7 +61,7 @@ namespace Battlenet _writePos = (_writePos + 7) & ~7; } - std::string ReadString(uint32 bitCount, uint32 baseLength = 0) + std::string ReadString(uint32 bitCount, int32 baseLength = 0) { uint32 len = Read(bitCount) + baseLength; AlignToNextByte(); @@ -120,7 +120,11 @@ namespace Battlenet return ret; } - //WriteString + void WriteString(std::string const& str, uint32 bitCount, int32 baseLength = 0) + { + Write(str.length() + baseLength, bitCount); + WriteBytes(str.c_str(), str.length()); + } template void WriteBytes(T* data, uint32 count) diff --git a/src/server/shared/Utilities/Util.cpp b/src/server/shared/Utilities/Util.cpp index 004335422c0..05d5d2c0749 100644 --- a/src/server/shared/Utilities/Util.cpp +++ b/src/server/shared/Utilities/Util.cpp @@ -561,7 +561,7 @@ void HexStrToByteArray(std::string const& str, uint8* out, bool reverse /*= fals if (reverse) { init = str.length() - 2; - end = -1; + end = -2; op = -1; } -- cgit v1.2.3 From c98853ca1c0f325296f509fe187b5505e32d607f Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 1 Jun 2014 15:03:22 +0200 Subject: Core/Authserver: Added game account flags --- src/server/authserver/Authentication/AuthCodes.h | 34 +++++++++++++++++++++++ src/server/authserver/Server/AuthSocket.cpp | 2 +- src/server/authserver/Server/BattlenetPackets.cpp | 4 +-- src/server/authserver/Server/BattlenetPackets.h | 4 ++- src/server/authserver/Server/BattlenetSocket.cpp | 6 ++-- 5 files changed, 43 insertions(+), 7 deletions(-) (limited to 'src/server/authserver/Authentication/AuthCodes.h') diff --git a/src/server/authserver/Authentication/AuthCodes.h b/src/server/authserver/Authentication/AuthCodes.h index 158029bcefc..57db55c98a8 100644 --- a/src/server/authserver/Authentication/AuthCodes.h +++ b/src/server/authserver/Authentication/AuthCodes.h @@ -70,6 +70,40 @@ enum LoginResult LOGIN_LOCKED_ENFORCED = 0x10 }; +enum GameAccountFlags +{ + GAMEACCOUNT_FLAG_GM = 0x00000001, + GAMEACCOUNT_FLAG_NOKICK = 0x00000002, + GAMEACCOUNT_FLAG_COLLECTOR = 0x00000004, + GAMEACCOUNT_FLAG_WOW_TRIAL = 0x00000008, + GAMEACCOUNT_FLAG_CANCELLED = 0x00000010, + GAMEACCOUNT_FLAG_IGR = 0x00000020, + GAMEACCOUNT_FLAG_WHOLESALER = 0x00000040, + GAMEACCOUNT_FLAG_PRIVILEGED = 0x00000080, + GAMEACCOUNT_FLAG_EU_FORBID_ELV = 0x00000100, + GAMEACCOUNT_FLAG_EU_FORBID_BILLING = 0x00000200, + GAMEACCOUNT_FLAG_WOW_RESTRICTED = 0x00000400, + GAMEACCOUNT_FLAG_REFERRAL = 0x00000800, + GAMEACCOUNT_FLAG_BLIZZARD = 0x00001000, + GAMEACCOUNT_FLAG_RECURRING_BILLING = 0x00002000, + GAMEACCOUNT_FLAG_NOELECTUP = 0x00004000, + GAMEACCOUNT_FLAG_KR_CERTIFICATE = 0x00008000, + GAMEACCOUNT_FLAG_EXPANSION_COLLECTOR = 0x00010000, + GAMEACCOUNT_FLAG_DISABLE_VOICE = 0x00020000, + GAMEACCOUNT_FLAG_DISABLE_VOICE_SPEAK = 0x00040000, + GAMEACCOUNT_FLAG_REFERRAL_RESURRECT = 0x00080000, + GAMEACCOUNT_FLAG_EU_FORBID_CC = 0x00100000, + GAMEACCOUNT_FLAG_OPENBETA_DELL = 0x00200000, + GAMEACCOUNT_FLAG_PROPASS = 0x00400000, + GAMEACCOUNT_FLAG_PROPASS_LOCK = 0x00800000, + GAMEACCOUNT_FLAG_PENDING_UPGRADE = 0x01000000, + GAMEACCOUNT_FLAG_RETAIL_FROM_TRIAL = 0x02000000, + GAMEACCOUNT_FLAG_EXPANSION2_COLLECTOR = 0x04000000, + GAMEACCOUNT_FLAG_OVERMIND_LINKED = 0x08000000, + GAMEACCOUNT_FLAG_DEMOS = 0x10000000, + GAMEACCOUNT_FLAG_DEATH_KNIGHT_OK = 0x20000000, +}; + namespace Battlenet { enum AuthResult diff --git a/src/server/authserver/Server/AuthSocket.cpp b/src/server/authserver/Server/AuthSocket.cpp index 8180967a92e..32140f76ba4 100644 --- a/src/server/authserver/Server/AuthSocket.cpp +++ b/src/server/authserver/Server/AuthSocket.cpp @@ -680,7 +680,7 @@ bool AuthSocket::_HandleLogonProof() memcpy(proof.M2, sha.GetDigest(), 20); proof.cmd = AUTH_LOGON_PROOF; proof.error = 0; - proof.unk1 = 0x00800000; // Accountflags. 0x01 = GM, 0x08 = Trial, 0x00800000 = Pro pass (arena tournament) + proof.unk1 = GAMEACCOUNT_FLAG_PROPASS_LOCK; proof.unk2 = 0x00; // SurveyId proof.unk3 = 0x00; socket().send((char *)&proof, sizeof(proof)); diff --git a/src/server/authserver/Server/BattlenetPackets.cpp b/src/server/authserver/Server/BattlenetPackets.cpp index 471a6128c4c..9997ea8d259 100644 --- a/src/server/authserver/Server/BattlenetPackets.cpp +++ b/src/server/authserver/Server/BattlenetPackets.cpp @@ -203,10 +203,10 @@ void Battlenet::AuthComplete::Write() _stream.WriteString(LastName, 8); // Last name - not set for WoW _stream.Write(GameAccountId, 32); - _stream.Write(2, 8); + _stream.Write(Region, 8); _stream.Write(0, 64); - _stream.Write(2, 8); + _stream.Write(GameAccountRegion, 8); _stream.WriteString(GameAccountName, 5, -1); _stream.Write(GameAccountFlags, 64); diff --git a/src/server/authserver/Server/BattlenetPackets.h b/src/server/authserver/Server/BattlenetPackets.h index d790760ea24..3fa628c2ba3 100644 --- a/src/server/authserver/Server/BattlenetPackets.h +++ b/src/server/authserver/Server/BattlenetPackets.h @@ -208,7 +208,7 @@ namespace Battlenet public: AuthComplete() : ServerPacket(PacketHeader(SMSG_AUTH_COMPLETE, AUTHENTICATION)), Result(AUTH_OK), ErrorType(0), PingTimeout(120000), Threshold(25000000), Rate(1000), - FirstName(""), LastName(""), GameAccountId(0), GameAccountName("") + FirstName(""), LastName(""), Region(2), GameAccountId(0), GameAccountRegion(2), GameAccountName("") { } @@ -227,7 +227,9 @@ namespace Battlenet uint32 Rate; std::string FirstName; std::string LastName; + uint8 Region; uint32 GameAccountId; + uint8 GameAccountRegion; std::string GameAccountName; uint64 GameAccountFlags; }; diff --git a/src/server/authserver/Server/BattlenetSocket.cpp b/src/server/authserver/Server/BattlenetSocket.cpp index 119fccd9abb..db72cbf5e07 100644 --- a/src/server/authserver/Server/BattlenetSocket.cpp +++ b/src/server/authserver/Server/BattlenetSocket.cpp @@ -466,11 +466,11 @@ bool Battlenet::Socket::HandleRealmUpdateSubscribe(PacketHeader& /*header*/, Bit if (flag & REALM_FLAG_SPECIFYBUILD) { std::ostringstream version; - version << buildInfo->MajorVersion << '.' << buildInfo->MinorVersion << '.' << buildInfo->BugfixVersion << '.' << buildInfo->HotfixVersion; + version << buildInfo->MajorVersion << '.' << buildInfo->MinorVersion << '.' << buildInfo->BugfixVersion << '.' << buildInfo->Build; update->Version = version.str(); update->Address = realm.GetAddressForClient(clientAddr); - update->Build = realm.gamebuild; + update->Build = buildInfo->Build; } update->Flags = flag; @@ -870,7 +870,7 @@ bool Battlenet::Socket::HandleRiskFingerprintModule(BitStream* dataStream, Serve complete->GameAccountId = _gameAccountId; complete->GameAccountName = str.str(); - complete->GameAccountFlags = 1; + complete->GameAccountFlags = GAMEACCOUNT_FLAG_PROPASS_LOCK; SQLTransaction trans = LoginDatabase.BeginTransaction(); -- cgit v1.2.3 From 9f69eda67f7fad50553f8d569851a5005437e677 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 8 Jun 2014 15:34:24 +0200 Subject: Core/Battle.net: Additional checks * Force grunt login for versions < 15595 * Force bn login if supported and game account is linked to bn account --- sql/base/auth_database.sql | 6 ------ sql/updates/auth/2014_06_08_01_auth_account_434.sql | 3 +++ src/server/authserver/Authentication/AuthCodes.cpp | 5 +++++ src/server/authserver/Authentication/AuthCodes.h | 1 + src/server/authserver/Server/AuthSocket.cpp | 4 +++- src/server/authserver/Server/BattlenetSocket.cpp | 8 ++++++-- src/server/shared/Database/Implementation/LoginDatabase.cpp | 2 +- 7 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 sql/updates/auth/2014_06_08_01_auth_account_434.sql (limited to 'src/server/authserver/Authentication/AuthCodes.h') diff --git a/sql/base/auth_database.sql b/sql/base/auth_database.sql index 6dca9aa1e14..3ccbadbbda0 100644 --- a/sql/base/auth_database.sql +++ b/sql/base/auth_database.sql @@ -216,18 +216,12 @@ LOCK TABLES `battlenet_components` WRITE; /*!40000 ALTER TABLE `battlenet_components` DISABLE KEYS */; INSERT INTO `battlenet_components` VALUES ('Bnet','Cmp1',3), -('Bnet','Win',21719), ('Bnet','Win',26487), ('Bnet','Wn64',26487), -('Tool','Win',1569), ('Tool','Win',2736), -('WoW','base',12340), ('WoW','base',15595), -('WoW','enGB',12340), ('WoW','enGB',15595), -('WoW','enUS',12340), ('WoW','enUS',15595), -('WoW','Win',12340), ('WoW','Win',15595), ('WoW','Wn64',15595); /*!40000 ALTER TABLE `battlenet_components` ENABLE KEYS */; diff --git a/sql/updates/auth/2014_06_08_01_auth_account_434.sql b/sql/updates/auth/2014_06_08_01_auth_account_434.sql new file mode 100644 index 00000000000..dc05a98d17b --- /dev/null +++ b/sql/updates/auth/2014_06_08_01_auth_account_434.sql @@ -0,0 +1,3 @@ +DELETE FROM `battlenet_components` WHERE `Program`='WoW' AND `Build`=12340; +DELETE FROM `battlenet_components` WHERE `Program`='Tool' AND `Build`=1569; +DELETE FROM `battlenet_components` WHERE `Program`='Bnet' AND `Build`=21719; diff --git a/src/server/authserver/Authentication/AuthCodes.cpp b/src/server/authserver/Authentication/AuthCodes.cpp index bb278dd6653..7a4998f7028 100644 --- a/src/server/authserver/Authentication/AuthCodes.cpp +++ b/src/server/authserver/Authentication/AuthCodes.cpp @@ -79,4 +79,9 @@ namespace AuthHelper return NULL; } + + bool IsBuildSupportingBattlenet(int build) + { + return build >= 15595; + } }; diff --git a/src/server/authserver/Authentication/AuthCodes.h b/src/server/authserver/Authentication/AuthCodes.h index 57db55c98a8..a6113b0d26d 100644 --- a/src/server/authserver/Authentication/AuthCodes.h +++ b/src/server/authserver/Authentication/AuthCodes.h @@ -182,6 +182,7 @@ namespace AuthHelper bool IsAcceptedClientBuild(int build); bool IsPostBCAcceptedClientBuild(int build); bool IsPreBCAcceptedClientBuild(int build); + bool IsBuildSupportingBattlenet(int build); }; #endif diff --git a/src/server/authserver/Server/AuthSocket.cpp b/src/server/authserver/Server/AuthSocket.cpp index 32140f76ba4..7ca49b03b56 100644 --- a/src/server/authserver/Server/AuthSocket.cpp +++ b/src/server/authserver/Server/AuthSocket.cpp @@ -480,7 +480,9 @@ bool AuthSocket::_HandleLogonChallenge() unk3.SetRand(16 * 8); // Fill the response packet with the result - if (AuthHelper::IsAcceptedClientBuild(_build)) + if (fields[9].GetUInt32() && AuthHelper::IsBuildSupportingBattlenet(_build)) + pkt << uint8(WOW_FAIL_USE_BATTLENET); + else if (AuthHelper::IsAcceptedClientBuild(_build)) pkt << uint8(WOW_SUCCESS); else pkt << uint8(WOW_FAIL_VERSION_INVALID); diff --git a/src/server/authserver/Server/BattlenetSocket.cpp b/src/server/authserver/Server/BattlenetSocket.cpp index eb8dc1158f0..4ee3c8e9b3d 100644 --- a/src/server/authserver/Server/BattlenetSocket.cpp +++ b/src/server/authserver/Server/BattlenetSocket.cpp @@ -107,7 +107,6 @@ void Battlenet::Socket::_SetVSFields(std::string const& pstr) bool Battlenet::Socket::HandleAuthChallenge(PacketHeader& header, BitStream& packet) { - // Verify that this IP is not in the ip_banned table LoginDatabase.Execute(LoginDatabase.GetPreparedStatement(LOGIN_DEL_EXPIRED_IP_BANS)); @@ -160,7 +159,12 @@ bool Battlenet::Socket::HandleAuthChallenge(PacketHeader& header, BitStream& pac else if (!sBattlenetMgr->HasPlatform(component.Platform)) complete.SetAuthResult(AUTH_INVALID_OS); else - complete.SetAuthResult(AUTH_REGION_BAD_VERSION); + { + if (component.Program != "WoW" || AuthHelper::IsBuildSupportingBattlenet(component.Build)) + complete.SetAuthResult(AUTH_REGION_BAD_VERSION); + else + complete.SetAuthResult(AUTH_USE_GRUNT_LOGON); + } Send(complete); return true; diff --git a/src/server/shared/Database/Implementation/LoginDatabase.cpp b/src/server/shared/Database/Implementation/LoginDatabase.cpp index 1da8088ed36..bccbe41a6ec 100644 --- a/src/server/shared/Database/Implementation/LoginDatabase.cpp +++ b/src/server/shared/Database/Implementation/LoginDatabase.cpp @@ -37,7 +37,7 @@ void LoginDatabaseConnection::DoPrepareStatements() PrepareStatement(LOGIN_SEL_SESSIONKEY, "SELECT a.sessionkey, a.id, aa.gmlevel FROM account a LEFT JOIN account_access aa ON (a.id = aa.id) WHERE username = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_UPD_VS, "UPDATE account SET v = ?, s = ? WHERE username = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_UPD_LOGONPROOF, "UPDATE account SET sessionkey = ?, last_ip = ?, last_login = NOW(), locale = ?, failed_logins = 0, os = ? WHERE username = ?", CONNECTION_SYNCH); - PrepareStatement(LOGIN_SEL_LOGONCHALLENGE, "SELECT a.sha_pass_hash, a.id, a.locked, a.lock_country, a.last_ip, aa.gmlevel, a.v, a.s, a.token_key FROM account a LEFT JOIN account_access aa ON (a.id = aa.id) WHERE a.username = ?", CONNECTION_SYNCH); + PrepareStatement(LOGIN_SEL_LOGONCHALLENGE, "SELECT a.sha_pass_hash, a.id, a.locked, a.lock_country, a.last_ip, aa.gmlevel, a.v, a.s, a.token_key, a.battlenet_account FROM account a LEFT JOIN account_access aa ON (a.id = aa.id) WHERE a.username = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_SEL_LOGON_COUNTRY, "SELECT country FROM ip2nation WHERE ip < ? ORDER BY ip DESC LIMIT 0,1", CONNECTION_SYNCH); PrepareStatement(LOGIN_UPD_FAILEDLOGINS, "UPDATE account SET failed_logins = failed_logins + 1 WHERE username = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_SEL_FAILEDLOGINS, "SELECT id, failed_logins FROM account WHERE username = ?", CONNECTION_SYNCH); -- cgit v1.2.3