ARCEmu項目wow私服伺服器網路模組分析(五)

來源:互聯網
上載者:User

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 keyHMAC(EVP_sha1(), s, 16, K, 40, decryptHash, &md_len);assert(md_len == SHA_DIGEST_LENGTH);// generate s->c keyHMAC(EVP_sha1(), r, 16, K, 40, encryptHash, &md_len);assert(md_len == SHA_DIGEST_LENGTH);// initialize rc4 structsRC4_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(){}

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.