Skip to content

Commit

Permalink
[9750] Add structure of SMSG_REDIRECT_CLIENT (0x50D).
Browse files Browse the repository at this point in the history
Thanks to TOM_RUS for help with research.
  • Loading branch information
XTZGZoReX committed Apr 15, 2010
1 parent 3638fc3 commit cc082e6
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/game/Opcodes.h
Expand Up @@ -1327,15 +1327,15 @@ enum Opcodes
SMSG_CAMERA_SHAKE = 0x50A, // uint32 SpellEffectCameraShakes.dbc index, uint32
SMSG_UNKNOWN_1291 = 0x50B, // some item update packet?
UMSG_UNKNOWN_1292 = 0x50C, // not found
SMSG_UNKNOWN_1293 = 0x50D, //
SMSG_REDIRECT_CLIENT = 0x50D, // uint32 ip, uint16 port, uint32 unk, uint8[20] hash
CMSG_UNKNOWN_1294 = 0x50E, // something with networking
SMSG_UNKNOWN_1295 = 0x50F, //
CMSG_UNKNOWN_1296 = 0x510, // something with networking
SMSG_UNKNOWN_1297 = 0x511, //
CMSG_UNKNOWN_1298 = 0x512, // something with networking
UMSG_UNKNOWN_1299 = 0x513, // not found
SMSG_UNKNOWN_1300 = 0x514, // SMSG, multi combatlog
SMSG_UNKNOWN_1301 = 0x515, // event EVENT_LFG_OPEN_FROM_GOSSIP (opens dungeon finder, probably for outdoor bosses)
SMSG_COMBAT_LOG_MULTIPLE = 0x514, // SMSG, multi combatlog
SMSG_LFG_OPEN_FROM_GOSSIP = 0x515, // event EVENT_LFG_OPEN_FROM_GOSSIP (opens dungeon finder, probably for outdoor bosses)
SMSG_UNKNOWN_1302 = 0x516, // something with player movement (move event 58?)
CMSG_UNKNOWN_1303 = 0x517, // something with player movement (move event 58?)
SMSG_UNKNOWN_1304 = 0x518, // something with player movement (move event 58?), speed packet
Expand Down
21 changes: 21 additions & 0 deletions src/game/WorldSession.cpp
Expand Up @@ -35,6 +35,8 @@
#include "BattleGroundMgr.h"
#include "MapManager.h"
#include "SocialMgr.h"
#include "Auth/AuthCrypt.h"
#include "Auth/HMACSHA1.h"
#include "zlib/zlib.h"

/// WorldSession constructor
Expand Down Expand Up @@ -856,3 +858,22 @@ void WorldSession::SetPlayer( Player *plr )
if(_player)
m_GUIDLow = _player->GetGUIDLow();
}

void WorldSession::SendRedirectClient(std::string& ip, uint16 port)
{
uint32 ip2 = ACE_OS::inet_addr(ip.c_str());
WorldPacket pkt(SMSG_REDIRECT_CLIENT, 4 + 2 + 4 + 20);

pkt << uint32(ip2); // inet_addr(ipstr)
pkt << uint16(port); // port

pkt << uint32(GetLatency()); // latency-related?

HMACSHA1 sha1(20, m_Socket->GetSessionKey().AsByteArray());
sha1.UpdateData((uint8*)&ip2, 4);
sha1.UpdateData((uint8*)&port, 2);
sha1.Finalize();
pkt.append(sha1.GetDigest(), 20); // hmacsha1(ip+port) w/ sessionkey as seed

SendPacket(&pkt);
}
1 change: 1 addition & 0 deletions src/game/WorldSession.h
Expand Up @@ -158,6 +158,7 @@ class MANGOS_DLL_SPEC WorldSession
void SendAreaTriggerMessage(const char* Text, ...) ATTR_PRINTF(2,3);
void SendSetPhaseShift(uint32 phaseShift);
void SendQueryTimeResponse();
void SendRedirectClient(std::string& ip, uint16 port);

AccountTypes GetSecurity() const { return _security; }
uint32 GetAccountId() const { return _accountId; }
Expand Down
4 changes: 2 additions & 2 deletions src/game/WorldSocket.cpp
Expand Up @@ -37,7 +37,6 @@
#include "ByteBuffer.h"
#include "Opcodes.h"
#include "Database/DatabaseEnv.h"
#include "Auth/BigNumber.h"
#include "Auth/Sha1.h"
#include "WorldSession.h"
#include "WorldSocketMgr.h"
Expand Down Expand Up @@ -826,7 +825,8 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
g.SetDword (7);

v.SetHexStr(fields[5].GetString());
s.SetHexStr (fields[6].GetString ());
s.SetHexStr (fields[6].GetString());
m_s = s;

const char* sStr = s.AsHexStr (); //Must be freed by OPENSSL_free()
const char* vStr = v.AsHexStr (); //Must be freed by OPENSSL_free()
Expand Down
6 changes: 6 additions & 0 deletions src/game/WorldSocket.h
Expand Up @@ -42,6 +42,7 @@

#include "Common.h"
#include "Auth/AuthCrypt.h"
#include "Auth/BigNumber.h"

class ACE_Message_Block;
class WorldPacket;
Expand Down Expand Up @@ -121,6 +122,9 @@ class WorldSocket : protected WorldHandler
/// Remove reference to this object.
long RemoveReference (void);

/// Return the session key
BigNumber& GetSessionKey() { return m_s; }

This comment has been minimized.

Copy link
@LordJZ

LordJZ Aug 15, 2010

Contributor

This function is fail.

This comment has been minimized.

Copy link
@VladimirMangos

VladimirMangos Aug 15, 2010

Lol, it can't fail, it just provide pointer to field...

This comment has been minimized.

Copy link
@LordJZ

LordJZ Aug 15, 2010

Contributor

I mean the functions not fails, but is a fail, because it is really returning Salt, not SessionKey.

This comment has been minimized.

Copy link
@LordJZ

LordJZ Aug 15, 2010

Contributor

Also, currently it is the ONLY use of account.v/s fields, leaving the fact that the whole auth system is exploitable right now.

This comment has been minimized.

Copy link
@LordJZ

LordJZ Aug 16, 2010

Contributor

I've made some changes to the auth system: http://github.com/LordJZ/mangos/commits/security (still under testing)
Going to post it on forums after testing.

Anyway this commit is Zor / TOM_RUS fail and should be either reverted or fixed


protected:
/// things called by ACE framework.
WorldSocket (void);
Expand Down Expand Up @@ -212,6 +216,8 @@ class WorldSocket : protected WorldHandler
bool m_OutActive;

uint32 m_Seed;

BigNumber m_s;
};

#endif /* _WORLDSOCKET_H */
Expand Down
7 changes: 5 additions & 2 deletions src/game/WorldSocketMgr.cpp
Expand Up @@ -273,12 +273,15 @@ WorldSocketMgr::StartReactiveIO (ACE_UINT16 port, const char* address)
}

int
WorldSocketMgr::StartNetwork (ACE_UINT16 port, const char* address)
WorldSocketMgr::StartNetwork (ACE_UINT16 port, std::string& address)
{
m_addr = address;
m_port = port;

if (!sLog.IsOutDebug ())
ACE_Log_Msg::instance ()->priority_mask (LM_ERROR, ACE_Log_Msg::PROCESS);

if (StartReactiveIO (port, address) == -1)
if (StartReactiveIO (port, address.c_str()) == -1)
return -1;

return 0;
Expand Down
10 changes: 9 additions & 1 deletion src/game/WorldSocketMgr.h
Expand Up @@ -29,6 +29,8 @@
#include <ace/Singleton.h>
#include <ace/Thread_Mutex.h>

#include <string>

class WorldSocket;
class ReactorRunnable;
class ACE_Event_Handler;
Expand All @@ -41,14 +43,17 @@ class WorldSocketMgr
friend class ACE_Singleton<WorldSocketMgr,ACE_Thread_Mutex>;

/// Start network, listen at address:port .
int StartNetwork (ACE_UINT16 port, const char* address);
int StartNetwork (ACE_UINT16 port, std::string& address);

/// Stops all network threads, It will wait for all running threads .
void StopNetwork ();

/// Wait untill all network threads have "joined" .
void Wait ();

std::string& GetBindAddress() { return m_addr; }
ACE_UINT16 GetBindPort() { return m_port; }

/// Make this class singleton .
static WorldSocketMgr* Instance ();

Expand All @@ -68,6 +73,9 @@ class WorldSocketMgr
int m_SockOutUBuff;
bool m_UseNoDelay;

std::string m_addr;
ACE_UINT16 m_port;

ACE_Event_Handler* m_Acceptor;
};

Expand Down
2 changes: 1 addition & 1 deletion src/mangosd/Master.cpp
Expand Up @@ -312,7 +312,7 @@ int Master::Run()
uint16 wsport = sWorld.getConfig (CONFIG_UINT32_PORT_WORLD);
std::string bind_ip = sConfig.GetStringDefault ("BindIP", "0.0.0.0");

if (sWorldSocketMgr->StartNetwork (wsport, bind_ip.c_str ()) == -1)
if (sWorldSocketMgr->StartNetwork (wsport, bind_ip) == -1)
{
sLog.outError ("Failed to start network");
World::StopNow(ERROR_EXIT_CODE);
Expand Down
1 change: 1 addition & 0 deletions src/shared/Common.h
Expand Up @@ -94,6 +94,7 @@
#include <ace/Guard_T.h>
#include <ace/RW_Thread_Mutex.h>
#include <ace/Thread_Mutex.h>
#include <ace/OS_NS_arpa_inet.h>

#if PLATFORM == PLATFORM_WINDOWS
# define FD_SETSIZE 4096
Expand Down
2 changes: 1 addition & 1 deletion src/shared/Util.cpp
Expand Up @@ -206,7 +206,7 @@ bool IsIPAddress(char const* ipaddress)

// Let the big boys do it.
// Drawback: all valid ip address formats are recognized e.g.: 12.23,121234,0xABCD)
return inet_addr(ipaddress) != INADDR_NONE;
return ACE_OS::inet_addr(ipaddress) != INADDR_NONE;
}

/// create PID file
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9749"
#define REVISION_NR "9750"
#endif // __REVISION_NR_H__

6 comments on commit cc082e6

@LordJZ
Copy link
Contributor

@LordJZ LordJZ commented on cc082e6 Apr 15, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally, thank you.

@arjanwoldring
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to understand the code, but can't figure out exactly what it does. It has probably something to do with redirecting a connection(?). Can someone enlighten me?

@alexrp
Copy link

@alexrp alexrp commented on cc082e6 Apr 16, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently Blizz only uses this to redirect you to the BattleNet World of Warcraft channel upon login.

@alexrp
Copy link

@alexrp alexrp commented on cc082e6 Apr 16, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all we know, Blizzard's battlegroup clustering is done 100% server-side.

@necromancer-zz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're to be connected to a Proxy

@alexrp
Copy link

@alexrp alexrp commented on cc082e6 Apr 16, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well then thats a good thing for us right? Except for the fact, that MaNGOS is not built that way at all for clustering >.>

Strictly speaking, it would've been easier if the client had integrated support for transition between servers.

Please sign in to comment.