mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-24 14:16:31 +00:00
feat(Core/Crypto): add support OpenSSL 3.0 (#13354)
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include "IoContext.h"
|
||||
#include "Log.h"
|
||||
#include "MySQLThreading.h"
|
||||
#include "OpenSSLCrypto.h"
|
||||
#include "ProcessPriority.h"
|
||||
#include "RealmList.h"
|
||||
#include "SecretMgr.h"
|
||||
@@ -96,10 +97,14 @@ int main(int argc, char** argv)
|
||||
[]()
|
||||
{
|
||||
LOG_INFO("server.authserver", "> Using configuration file {}", sConfigMgr->GetFilename());
|
||||
LOG_INFO("server.authserver", "> Using SSL version: {} (library: {})", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
|
||||
LOG_INFO("server.authserver", "> Using SSL version: {} (library: {})", OPENSSL_VERSION_TEXT, OpenSSL_version(OPENSSL_VERSION));
|
||||
LOG_INFO("server.authserver", "> Using Boost version: {}.{}.{}", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
|
||||
});
|
||||
|
||||
OpenSSLCrypto::threadsSetup();
|
||||
|
||||
std::shared_ptr<void> opensslHandle(nullptr, [](void*) { OpenSSLCrypto::threadsCleanup(); });
|
||||
|
||||
// authserver PID file creation
|
||||
std::string pidFile = sConfigMgr->GetOption<std::string>("PidFile", "");
|
||||
if (!pidFile.empty())
|
||||
|
||||
@@ -160,7 +160,7 @@ int main(int argc, char** argv)
|
||||
[]()
|
||||
{
|
||||
LOG_INFO("server.worldserver", "> Using configuration file {}", sConfigMgr->GetFilename());
|
||||
LOG_INFO("server.worldserver", "> Using SSL version: {} (library: {})", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
|
||||
LOG_INFO("server.worldserver", "> Using SSL version: {} (library: {})", OPENSSL_VERSION_TEXT, OpenSSL_version(OPENSSL_VERSION));
|
||||
LOG_INFO("server.worldserver", "> Using Boost version: {}.{}.{}", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
|
||||
});
|
||||
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
|
||||
#include "AddonMgr.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "CryptoHash.h"
|
||||
#include "Log.h"
|
||||
#include "Timer.h"
|
||||
#include <list>
|
||||
#include <openssl/md5.h>
|
||||
|
||||
namespace AddonMgr
|
||||
{
|
||||
@@ -66,6 +66,7 @@ namespace AddonMgr
|
||||
|
||||
oldMSTime = getMSTime();
|
||||
result = CharacterDatabase.Query("SELECT id, name, version, UNIX_TIMESTAMP(timestamp) FROM banned_addons");
|
||||
|
||||
if (result)
|
||||
{
|
||||
uint32 count2 = 0;
|
||||
@@ -78,14 +79,10 @@ namespace AddonMgr
|
||||
BannedAddon addon{};
|
||||
addon.Id = fields[0].Get<uint32>() + offset;
|
||||
addon.Timestamp = uint32(fields[3].Get<uint64>());
|
||||
addon.NameMD5 = Acore::Crypto::MD5::GetDigestOf(fields[1].Get<std::string>());
|
||||
addon.VersionMD5 = Acore::Crypto::MD5::GetDigestOf(fields[2].Get<std::string>());
|
||||
|
||||
std::string name = fields[1].Get<std::string>();
|
||||
std::string version = fields[2].Get<std::string>();
|
||||
|
||||
MD5(reinterpret_cast<uint8 const*>(name.c_str()), name.length(), addon.NameMD5);
|
||||
MD5(reinterpret_cast<uint8 const*>(version.c_str()), version.length(), addon.VersionMD5);
|
||||
|
||||
m_bannedAddons.push_back(addon);
|
||||
m_bannedAddons.emplace_back(addon);
|
||||
|
||||
++count2;
|
||||
} while (result->NextRow());
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#define _ADDONMGR_H
|
||||
|
||||
#include "Define.h"
|
||||
#include <array>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
@@ -49,8 +50,8 @@ struct SavedAddon
|
||||
struct BannedAddon
|
||||
{
|
||||
uint32 Id;
|
||||
uint8 NameMD5[16];
|
||||
uint8 VersionMD5[16];
|
||||
std::array<uint8, 16> NameMD5;
|
||||
std::array<uint8, 16> VersionMD5;
|
||||
uint32 Timestamp;
|
||||
};
|
||||
|
||||
|
||||
@@ -1254,8 +1254,8 @@ void WorldSession::SendAddonsInfo()
|
||||
for (AddonMgr::BannedAddonList::const_iterator itr = bannedAddons->begin(); itr != bannedAddons->end(); ++itr)
|
||||
{
|
||||
data << uint32(itr->Id);
|
||||
data.append(itr->NameMD5, sizeof(itr->NameMD5));
|
||||
data.append(itr->VersionMD5, sizeof(itr->VersionMD5));
|
||||
data.append(itr->NameMD5);
|
||||
data.append(itr->VersionMD5);
|
||||
data << uint32(itr->Timestamp);
|
||||
data << uint32(1); // IsBanned
|
||||
}
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
#ifndef _WARDEN_MODULE_MAC_H
|
||||
#define _WARDEN_MODULE_MAC_H
|
||||
|
||||
uint8 Module_0DBBF209A27B1E279A9FEC5C168A15F7_Data[9318] =
|
||||
#include <array>
|
||||
|
||||
std::array<uint8, 9318> Module_0DBBF209A27B1E279A9FEC5C168A15F7_Data =
|
||||
{
|
||||
0x07, 0x0C, 0x44, 0xCD, 0xC9, 0xFB, 0x99, 0xBC, 0x7C, 0x77, 0xDC, 0xE8, 0x8D, 0x07, 0xBE, 0x55,
|
||||
0x37, 0x5C, 0x84, 0x10, 0x23, 0xE1, 0x36, 0x5B, 0xF1, 0xBC, 0x60, 0xF3, 0x68, 0xBA, 0x60, 0x69,
|
||||
@@ -605,7 +607,7 @@ uint8 Module_0DBBF209A27B1E279A9FEC5C168A15F7_Data[9318] =
|
||||
0x43, 0x82, 0xAA, 0x0C, 0xEE, 0x1B
|
||||
};
|
||||
|
||||
uint8 Module_0DBBF209A27B1E279A9FEC5C168A15F7_Key[16] =
|
||||
std::array<uint8, 16> Module_0DBBF209A27B1E279A9FEC5C168A15F7_Key =
|
||||
{
|
||||
0x5B, 0x27, 0x27, 0x01, 0x24, 0x56, 0xB4, 0xD4, 0x2D, 0xD0, 0x96, 0x77, 0x49, 0x51, 0xDC, 0x0A
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "AccountMgr.h"
|
||||
#include "BanMgr.h"
|
||||
#include "ByteBuffer.h"
|
||||
#include "Common.h"
|
||||
#include "CryptoHash.h"
|
||||
#include "Log.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Player.h"
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
#include <openssl/sha.h>
|
||||
|
||||
Warden::Warden() : _session(nullptr), _checkTimer(10000/*10 sec*/), _clientResponseTimer(0),
|
||||
_dataSent(false), _module(nullptr), _initialized(false)
|
||||
@@ -77,11 +76,11 @@ void Warden::RequestModule()
|
||||
LOG_DEBUG("warden", "Request module");
|
||||
|
||||
// Create packet structure
|
||||
WardenModuleUse request;
|
||||
WardenModuleUse request{};
|
||||
request.Command = WARDEN_SMSG_MODULE_USE;
|
||||
|
||||
memcpy(request.ModuleId, _module->Id, 16);
|
||||
memcpy(request.ModuleKey, _module->Key, 16);
|
||||
memcpy(request.ModuleId, _module->Id.data(), 16);
|
||||
memcpy(request.ModuleKey, _module->Key.data(), 16);
|
||||
request.Size = _module->CompressedSize;
|
||||
|
||||
EndianConvert(request.Size);
|
||||
@@ -155,30 +154,21 @@ bool Warden::IsValidCheckSum(uint32 checksum, const uint8* data, const uint16 le
|
||||
}
|
||||
}
|
||||
|
||||
struct keyData
|
||||
union keyData
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint8 bytes[20];
|
||||
} bytes;
|
||||
|
||||
struct
|
||||
{
|
||||
uint32 ints[5];
|
||||
} ints;
|
||||
};
|
||||
std::array<uint8, 20> bytes;
|
||||
std::array<uint32, 5> ints;
|
||||
};
|
||||
|
||||
uint32 Warden::BuildChecksum(const uint8* data, uint32 length)
|
||||
{
|
||||
keyData hash;
|
||||
SHA1(data, length, hash.bytes.bytes);
|
||||
keyData hash{};
|
||||
hash.bytes = Acore::Crypto::SHA1::GetDigestOf(data, size_t(length));
|
||||
uint32 checkSum = 0;
|
||||
|
||||
for (uint8 i = 0; i < 5; ++i)
|
||||
{
|
||||
checkSum = checkSum ^ hash.ints.ints[i];
|
||||
checkSum = checkSum ^ hash.ints[i];
|
||||
}
|
||||
|
||||
return checkSum;
|
||||
|
||||
@@ -91,10 +91,10 @@ struct WardenHashRequest
|
||||
|
||||
struct ClientWardenModule
|
||||
{
|
||||
uint8 Id[16];
|
||||
uint8 Key[16];
|
||||
uint32 CompressedSize;
|
||||
uint8* CompressedData;
|
||||
std::array<uint8, 16> Id{};
|
||||
std::array<uint8, 16> Key{};
|
||||
uint32 CompressedSize{};
|
||||
uint8* CompressedData{};
|
||||
};
|
||||
|
||||
class WorldSession;
|
||||
|
||||
@@ -25,15 +25,12 @@
|
||||
#include "WardenModuleMac.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
#include <openssl/md5.h>
|
||||
|
||||
WardenMac::WardenMac() : Warden()
|
||||
{
|
||||
}
|
||||
|
||||
WardenMac::~WardenMac()
|
||||
{
|
||||
}
|
||||
WardenMac::~WardenMac() = default;
|
||||
|
||||
void WardenMac::Init(WorldSession* pClient, SessionKey const& K)
|
||||
{
|
||||
@@ -64,29 +61,21 @@ void WardenMac::Init(WorldSession* pClient, SessionKey const& K)
|
||||
|
||||
_module = GetModuleForClient();
|
||||
|
||||
LOG_DEBUG("warden", "Module Key: {}", Acore::Impl::ByteArrayToHexStr(_module->Key, 16));
|
||||
LOG_DEBUG("warden", "Module ID: {}", Acore::Impl::ByteArrayToHexStr(_module->Id, 16));
|
||||
LOG_DEBUG("warden", "Module Key: {}", ByteArrayToHexStr(_module->Key));
|
||||
LOG_DEBUG("warden", "Module ID: {}", ByteArrayToHexStr(_module->Id));
|
||||
RequestModule();
|
||||
}
|
||||
|
||||
ClientWardenModule* WardenMac::GetModuleForClient()
|
||||
{
|
||||
ClientWardenModule* mod = new ClientWardenModule;
|
||||
|
||||
uint32 len = sizeof(Module_0DBBF209A27B1E279A9FEC5C168A15F7_Data);
|
||||
auto mod = new ClientWardenModule;
|
||||
|
||||
// data assign
|
||||
mod->CompressedSize = len;
|
||||
mod->CompressedData = new uint8[len];
|
||||
memcpy(mod->CompressedData, Module_0DBBF209A27B1E279A9FEC5C168A15F7_Data, len);
|
||||
memcpy(mod->Key, Module_0DBBF209A27B1E279A9FEC5C168A15F7_Key, 16);
|
||||
mod->CompressedSize = Module_0DBBF209A27B1E279A9FEC5C168A15F7_Data.size();
|
||||
mod->CompressedData = Module_0DBBF209A27B1E279A9FEC5C168A15F7_Data.data();
|
||||
|
||||
// md5 hash
|
||||
MD5_CTX ctx;
|
||||
MD5_Init(&ctx);
|
||||
MD5_Update(&ctx, mod->CompressedData, len);
|
||||
MD5_Final((uint8*)&mod->Id, &ctx);
|
||||
|
||||
mod->Id = Acore::Crypto::MD5::GetDigestOf(mod->CompressedData, mod->CompressedSize);
|
||||
return mod;
|
||||
}
|
||||
|
||||
@@ -100,7 +89,7 @@ void WardenMac::RequestHash()
|
||||
LOG_DEBUG("warden", "Request hash");
|
||||
|
||||
// Create packet structure
|
||||
WardenHashRequest Request;
|
||||
WardenHashRequest Request{};
|
||||
Request.Command = WARDEN_SMSG_HASH_REQUEST;
|
||||
memcpy(Request.Seed, _seed, 16);
|
||||
|
||||
@@ -242,7 +231,7 @@ void WardenMac::HandleData(ByteBuffer& buff)
|
||||
sha1.UpdateData((uint8*)&magic, 4);
|
||||
sha1.Finalize();
|
||||
|
||||
std::array<uint8, Acore::Crypto::SHA1::DIGEST_LENGTH> sha1Hash;
|
||||
Acore::Crypto::SHA1::Digest sha1Hash{};
|
||||
buff.read(sha1Hash.data(), sha1Hash.size());
|
||||
|
||||
if (sha1Hash != sha1.GetDigest())
|
||||
@@ -251,20 +240,15 @@ void WardenMac::HandleData(ByteBuffer& buff)
|
||||
//found = true;
|
||||
}
|
||||
|
||||
MD5_CTX ctx;
|
||||
MD5_Init(&ctx);
|
||||
MD5_Update(&ctx, str.c_str(), str.size());
|
||||
uint8 ourMD5Hash[16];
|
||||
MD5_Final(ourMD5Hash, &ctx);
|
||||
auto ourMD5Hash = Acore::Crypto::MD5::GetDigestOf(str);
|
||||
Acore::Crypto::MD5::Digest theirsMD5Hash{};
|
||||
buff.read(theirsMD5Hash);
|
||||
|
||||
uint8 theirsMD5Hash[16];
|
||||
buff.read(theirsMD5Hash, 16);
|
||||
|
||||
if (memcmp(ourMD5Hash, theirsMD5Hash, 16))
|
||||
if (ourMD5Hash != theirsMD5Hash)
|
||||
{
|
||||
LOG_DEBUG("warden", "Handle data failed: MD5 hash is wrong!");
|
||||
//found = true;
|
||||
}
|
||||
|
||||
_session->KickPlayer("WardenMac");
|
||||
_session->KickPlayer("WardenMac::HandleData");
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
#include <openssl/md5.h>
|
||||
|
||||
// GUILD is the shortest string that has no client validation (RAID only sends if in a raid group)
|
||||
static constexpr char _luaEvalPrefix[] = "local S,T,R=SendAddonMessage,function()";
|
||||
@@ -97,9 +96,7 @@ static WorldIntConfigs GetMaxWardenChecksForType(uint8 type)
|
||||
|
||||
WardenWin::WardenWin() : Warden(), _serverTicks(0) { }
|
||||
|
||||
WardenWin::~WardenWin()
|
||||
{
|
||||
}
|
||||
WardenWin::~WardenWin() = default;
|
||||
|
||||
void WardenWin::Init(WorldSession* session, SessionKey const& k)
|
||||
{
|
||||
@@ -121,14 +118,14 @@ void WardenWin::Init(WorldSession* session, SessionKey const& k)
|
||||
|
||||
_module = GetModuleForClient();
|
||||
|
||||
LOG_DEBUG("warden", "Module Key: {}", Acore::Impl::ByteArrayToHexStr(_module->Key, 16));
|
||||
LOG_DEBUG("warden", "Module ID: {}", Acore::Impl::ByteArrayToHexStr(_module->Id, 16));
|
||||
LOG_DEBUG("warden", "Module Key: {}", ByteArrayToHexStr(_module->Key));
|
||||
LOG_DEBUG("warden", "Module ID: {}", ByteArrayToHexStr(_module->Id));
|
||||
RequestModule();
|
||||
}
|
||||
|
||||
ClientWardenModule* WardenWin::GetModuleForClient()
|
||||
{
|
||||
ClientWardenModule* mod = new ClientWardenModule;
|
||||
auto mod = new ClientWardenModule;
|
||||
|
||||
uint32 length = sizeof(Module.Module);
|
||||
|
||||
@@ -136,13 +133,10 @@ ClientWardenModule* WardenWin::GetModuleForClient()
|
||||
mod->CompressedSize = length;
|
||||
mod->CompressedData = new uint8[length];
|
||||
memcpy(mod->CompressedData, Module.Module, length);
|
||||
memcpy(mod->Key, Module.ModuleKey, 16);
|
||||
memcpy(mod->Key.data(), Module.ModuleKey, 16);
|
||||
|
||||
// md5 hash
|
||||
MD5_CTX ctx;
|
||||
MD5_Init(&ctx);
|
||||
MD5_Update(&ctx, mod->CompressedData, length);
|
||||
MD5_Final((uint8*)&mod->Id, &ctx);
|
||||
mod->Id = Acore::Crypto::MD5::GetDigestOf(mod->CompressedData, mod->CompressedSize);
|
||||
|
||||
return mod;
|
||||
}
|
||||
@@ -152,7 +146,7 @@ void WardenWin::InitializeModule()
|
||||
LOG_DEBUG("warden", "Initialize module");
|
||||
|
||||
// Create packet structure
|
||||
WardenInitModuleRequest Request;
|
||||
WardenInitModuleRequest Request{};
|
||||
Request.Command1 = WARDEN_SMSG_MODULE_INITIALIZE;
|
||||
Request.Size1 = 20;
|
||||
Request.Unk1 = 1;
|
||||
@@ -209,7 +203,7 @@ void WardenWin::RequestHash()
|
||||
LOG_DEBUG("warden", "Request hash");
|
||||
|
||||
// Create packet structure
|
||||
WardenHashRequest Request;
|
||||
WardenHashRequest Request{};
|
||||
Request.Command = WARDEN_SMSG_HASH_REQUEST;
|
||||
memcpy(Request.Seed, _seed, 16);
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
}
|
||||
|
||||
handler->PSendSysMessage("%s", GitRevision::GetFullVersion());
|
||||
handler->PSendSysMessage("Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
|
||||
handler->PSendSysMessage("Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, OpenSSL_version(OPENSSL_VERSION));
|
||||
handler->PSendSysMessage("Using Boost version: %i.%i.%i", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
|
||||
handler->PSendSysMessage("Using MySQL version: %u", MySQL::GetLibraryVersion());
|
||||
handler->PSendSysMessage("Using CMake version: %s", GitRevision::GetCMakeVersion());
|
||||
|
||||
Reference in New Issue
Block a user