From bee304a45305697aabdeef21a5ee691235566d4f Mon Sep 17 00:00:00 2001 From: shlainn Date: Sun, 4 Sep 2011 23:37:53 +0200 Subject: [PATCH] * SMSG_AUTH_CHALLENGE should be backwards-compatible now Auth must be fixed, as the Authentication Methods have changed between major versions --- src/Client/World/WorldSession.cpp | 70 ++++++++++++++++++------------- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/src/Client/World/WorldSession.cpp b/src/Client/World/WorldSession.cpp index d445b83..78ed4be 100644 --- a/src/Client/World/WorldSession.cpp +++ b/src/Client/World/WorldSession.cpp @@ -520,37 +520,51 @@ std::string WorldSession::GetOrRequestPlayerName(uint64 guid) void WorldSession::_HandleAuthChallengeOpcode(WorldPacket& recvPacket) { + //Read Packet + uint32 sp, serverseed; + if(GetInstance()->GetConf()->clientbuild>6005)//TODO: Check TBC + { + recvPacket >> sp; + } + recvPacket >> serverseed; + + // Do stuff with the data std::string acc = stringToUpper(GetInstance()->GetConf()->accname); - uint32 sp; - recvPacket >> sp; - uint32 serverseed; - recvPacket >> serverseed; - logdebug("Auth: serverseed=0x%X",serverseed); - Sha1Hash digest; - digest.UpdateData(acc); - uint32 unk=0; - uint64 unk64=0; - digest.UpdateData((uint8*)&unk,sizeof(uint32)); - BigNumber clientseed; - clientseed.SetRand(8*4); - uint32 clientseed_uint32=clientseed.AsDword(); - digest.UpdateData((uint8*)&clientseed_uint32,sizeof(uint32)); - digest.UpdateData((uint8*)&serverseed,sizeof(uint32)); - digest.UpdateBigNumbers(GetInstance()->GetSessionKey(),NULL); - digest.Finalize(); - WorldPacket auth; - auth<<(uint32)(GetInstance()->GetConf()->clientbuild)<GetSessionKey(),NULL); + digest.Finalize(); + + // Send Reply + WorldPacket auth; + if(GetInstance()->GetConf()->clientbuild<=6005) + { + auth<<(uint32)(GetInstance()->GetConf()->clientbuild)<GetConf()->clientbuild)<InitCrypt(GetInstance()->GetSessionKey()); + // note that if the sessionkey/auth is wrong or failed, the server sends the following packet UNENCRYPTED! + // so its not 100% correct to init the crypt here, but it should do the job if authing was correct + _socket->InitCrypt(GetInstance()->GetSessionKey()); } @@ -570,7 +584,7 @@ void WorldSession::_HandleAuthResponseOpcode(WorldPacket& recvPacket) } else { - logerror("World Authentication failed, errcode=0x%X",(unsigned char)errcode); + logerror("World Authentication failed, errcode=0x%X",(uint8)errcode); SetMustDie(); } }