ARCEmu项目wow私服服务器网络模块分析(五)
2011-10-13 10:22
281 查看
wow消息加密算法:
/* * ArcEmu MMORPG Server * Copyright (C) 2008-2011 <http://www.ArcEmu.org/> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ #ifndef _WOWCRYPT_H #define _WOWCRYPT_H #include <cstdlib> #include "../Common.h" #include "BigNumber.h" #include <vector> #include <openssl/sha.h> #include <openssl/rc4.h> class WowCrypt { public: WowCrypt(); ~WowCrypt(); void Init(uint8* K); ARCEMU_INLINE void DecryptRecv(uint8* pData, size_t len) { if(!m_initialized) { return; } RC4(&m_clientDecrypt, (unsigned long)len, pData, pData); } ARCEMU_INLINE void EncryptSend(uint8* pData, size_t len) { if(!m_initialized) { return; } RC4(&m_serverEncrypt, (unsigned long)len, pData, pData); } bool IsInitialized() { return m_initialized; } private: RC4_KEY m_clientDecrypt; RC4_KEY m_serverEncrypt; bool m_initialized; }; #endif
/* * ArcEmu MMORPG Server * Copyright (C) 2008-2011 <http://www.ArcEmu.org/> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ #include "WowCrypt.h" #include <algorithm> #include <openssl/hmac.h> WowCrypt::WowCrypt() { m_initialized = false; } void WowCrypt::Init(uint8* K) { static const uint8 s[16] = { 0xC2, 0xB3, 0x72, 0x3C, 0xC6, 0xAE, 0xD9, 0xB5, 0x34, 0x3C, 0x53, 0xEE, 0x2F, 0x43, 0x67, 0xCE }; static const uint8 r[16] = { 0xCC, 0x98, 0xAE, 0x04, 0xE8, 0x97, 0xEA, 0xCA, 0x12, 0xDD, 0xC0, 0x93, 0x42, 0x91, 0x53, 0x57 }; uint8 encryptHash[SHA_DIGEST_LENGTH]; uint8 decryptHash[SHA_DIGEST_LENGTH]; uint8 pass[1024]; uint32 md_len; // generate c->s key HMAC(EVP_sha1(), s, 16, K, 40, decryptHash, &md_len); assert(md_len == SHA_DIGEST_LENGTH); // generate s->c key HMAC(EVP_sha1(), r, 16, K, 40, encryptHash, &md_len); assert(md_len == SHA_DIGEST_LENGTH); // initialize rc4 structs RC4_set_key(&m_clientDecrypt, SHA_DIGEST_LENGTH, decryptHash); RC4_set_key(&m_serverEncrypt, SHA_DIGEST_LENGTH, encryptHash); // initial encryption pass -- this is just to get key position, // the data doesn't actually have to be initialized as discovered // by client debugging. RC4(&m_serverEncrypt, 1024, pass, pass); RC4(&m_clientDecrypt, 1024, pass, pass); m_initialized = true; } WowCrypt::~WowCrypt() { }
相关文章推荐
- ARCEmu项目wow私服服务器网络模块分析(三)
- ARCEmu项目wow私服服务器网络模块分析(一)
- ARCEmu项目wow私服服务器网络模块分析(二)
- ARCEmu项目wow私服服务器网络模块分析(四)
- WoW服务器模拟器Ascent网络模块分析
- WoW服务器模拟器Ascent网络模块分析
- WoW服务器模拟器Ascent网络模块分析
- WoW服务器模拟器Ascent网络模块分析
- 几种经典的网络服务器架构模型的分析与比较
- NT_DB服务器性能分析检测项目表
- 【Unity3D_常用模块】 Socket网络模块(超级详细完整,上线项目中稳定使用着)
- 几种经典的网络服务器架构模型的分析与比较
- 几种经典的网络服务器架构模型的分析与比较
- 从写项目到部署linux服务器全过程-MyEclipse创建多模块Maven依赖项目
- 网络对讲机C#服务器 Android客户端(二) C#服务器代码分析 附加
- 录音函数网络对讲机C#服务器 Android客户端(二) C#服务器代码分析 附加
- 几种经典的网络服务器架构模型的分析与比较
- HTTP核心模块配置静态web服务器 4-网络连接的设置
- Ceph网络模块(2) - AsyncMessenger数据结构分析
- Linux内核分析 - 网络[十二]:UDP模块 - 收发