diff --git a/src/game/World.cpp b/src/game/World.cpp index ada384d59..853a7a4ae 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -725,6 +725,8 @@ void World::LoadConfigSettings(bool reload) setConfig(CONFIG_BOOL_OFFHAND_CHECK_AT_TALENTS_RESET, "OffhandCheckAtTalentsReset", false); + setConfig(CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET, "Network.KickOnBadPacket", false); + if(int clientCacheId = sConfig.GetIntDefault("ClientCacheVersion", 0)) { // overwrite DB/old value diff --git a/src/game/World.h b/src/game/World.h index 72642d34d..c3f1d213c 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -301,6 +301,7 @@ enum eConfigBoolValues CONFIG_BOOL_ARENA_AUTO_DISTRIBUTE_POINTS, CONFIG_BOOL_ARENA_QUEUE_ANNOUNCER_JOIN, CONFIG_BOOL_ARENA_QUEUE_ANNOUNCER_EXIT, + CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET, CONFIG_BOOL_VALUE_COUNT }; diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 846332c5a..4b3919f34 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -248,15 +248,23 @@ bool WorldSession::Update(uint32 /*diff*/) break; } } - catch(ByteBufferException &) + catch (ByteBufferException &) { - sLog.outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i. Skipped packet.", + sLog.outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i.", packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId()); if(sLog.IsOutDebug()) { sLog.outDebug("Dumping error causing packet:"); packet->hexlike(); } + + if (sWorld.getConfig(CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET)) + { + sLog.outDetail("Disconnecting session [account id %u / address %s] for badly formatted packet.", + GetAccountId(), GetRemoteAddress().c_str()); + + KickPlayer(); + } } delete packet; diff --git a/src/game/WorldSocket.cpp b/src/game/WorldSocket.cpp index acc4faf9e..c181c8d82 100644 --- a/src/game/WorldSocket.cpp +++ b/src/game/WorldSocket.cpp @@ -713,7 +713,7 @@ int WorldSocket::ProcessIncoming (WorldPacket* new_pct) } catch (ByteBufferException &) { - sLog.outError("WorldSocket::ProcessIncoming ByteBufferException occured while parsing an instant handled packet (opcode: %u) from client %s, accountid=%i. Disconnected client.", + sLog.outError("WorldSocket::ProcessIncoming ByteBufferException occured while parsing an instant handled packet (opcode: %u) from client %s, accountid=%i.", opcode, GetRemoteAddress().c_str(), m_Session?m_Session->GetAccountId():-1); if(sLog.IsOutDebug()) { @@ -721,7 +721,15 @@ int WorldSocket::ProcessIncoming (WorldPacket* new_pct) new_pct->hexlike(); } - return -1; + if (sWorld.getConfig(CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET)) + { + sLog.outDetail("Disconnecting session [account id %i / address %s] for badly formatted packet.", + m_Session?m_Session->GetAccountId():-1, GetRemoteAddress().c_str()); + + return -1; + } + else + return 0; } ACE_NOTREACHED (return 0); diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in index 43e415994..f4abaa1a7 100644 --- a/src/mangosd/mangosd.conf.dist.in +++ b/src/mangosd/mangosd.conf.dist.in @@ -1348,12 +1348,18 @@ Arena.ArenaSeason.InProgress = 1 # Default: 0 (enable Nagle algorithm, less traffic, more latency) # 1 (TCP_NO_DELAY, disable Nagle algorithm, more traffic but less latency) # +# Network.KickOnBadPacket +# Kick player on bad packet format. +# Default: 0 - do not kick +# 1 - kick +# ################################################################################################################### Network.Threads = 1 Network.OutKBuff = -1 Network.OutUBuff = 65536 Network.TcpNodelay = 1 +Network.KickOnBadPacket = 0 ################################################################################################################### # CONSOLE, REMOTE ACCESS AND SOAP diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 7dd63a40a..49b2f3e48 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9572" + #define REVISION_NR "9573" #endif // __REVISION_NR_H__