From 449afa850e78874c5a5669bcda82da83f25d0b90 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Apr 2014 18:24:44 +0200 Subject: ProtoProxy: Added 1.7.9 compatibility. --- Tools/ProtoProxy/Connection.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'Tools/ProtoProxy') diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp index d9b8e3dd1..8dc82157a 100644 --- a/Tools/ProtoProxy/Connection.cpp +++ b/Tools/ProtoProxy/Connection.cpp @@ -2202,6 +2202,28 @@ bool cConnection::HandleServerSpawnNamedEntity(void) HANDLE_SERVER_PACKET_READ(ReadVarInt, UInt32, EntityID); HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, EntityUUID); HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, EntityName); + HANDLE_SERVER_PACKET_READ(ReadVarInt, UInt32, DataCount); + struct sData + { + AString m_Name; + AString m_Value; + AString m_Signature; + sData(const AString & a_Name, const AString & a_Value, const AString & a_Signature) : + m_Name(a_Name), + m_Value(a_Value), + m_Signature(a_Signature) + { + } + }; + typedef std::vector sDataVec; + sDataVec Data; + for (UInt32 i = 0; i < DataCount; i++) + { + HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, Name) + HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, Value) + HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, Signature) + Data.push_back(sData(Name, Value, Signature)); + } HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosX); HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosY); HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosZ); @@ -2219,6 +2241,13 @@ bool cConnection::HandleServerSpawnNamedEntity(void) Log(" EntityID = %u (0x%x)", EntityID, EntityID); Log(" UUID = \"%s\"", EntityUUID.c_str()); Log(" Name = \"%s\"", EntityName.c_str()); + Log(" NumData = %u", DataCount); + for (sDataVec::const_iterator itr = Data.begin(), end = Data.end(); itr != end; ++itr) + { + Log(" Name = \"%s\", Value = \"%s\", Signature = \"%s\"", + itr->m_Name.c_str(), itr->m_Value.c_str(), itr->m_Signature.c_str() + ); + } // for itr - Data[] Log(" Pos = %s", PrintableAbsIntTriplet(PosX, PosY, PosZ).c_str()); Log(" Rotation = ", Yaw, Pitch); Log(" CurrentItem = %d", CurrentItem); -- cgit v1.2.3 From 21e569081148c098c043cc2665b8384cceb5e3d5 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Apr 2014 18:50:44 +0200 Subject: ProtoProxy: Fixed weird gcc compilation errors. --- Tools/ProtoProxy/Connection.cpp | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'Tools/ProtoProxy') diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp index 8dc82157a..b21d2ae59 100644 --- a/Tools/ProtoProxy/Connection.cpp +++ b/Tools/ProtoProxy/Connection.cpp @@ -2197,32 +2197,38 @@ bool cConnection::HandleServerSpawnMob(void) +struct sSpawnData +{ + AString m_Name; + AString m_Value; + AString m_Signature; + sSpawnData(const AString & a_Name, const AString & a_Value, const AString & a_Signature) : + m_Name(a_Name), + m_Value(a_Value), + m_Signature(a_Signature) + { + } +}; + +typedef std::vector sSpawnDatas; + + + + + bool cConnection::HandleServerSpawnNamedEntity(void) { HANDLE_SERVER_PACKET_READ(ReadVarInt, UInt32, EntityID); HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, EntityUUID); HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, EntityName); HANDLE_SERVER_PACKET_READ(ReadVarInt, UInt32, DataCount); - struct sData - { - AString m_Name; - AString m_Value; - AString m_Signature; - sData(const AString & a_Name, const AString & a_Value, const AString & a_Signature) : - m_Name(a_Name), - m_Value(a_Value), - m_Signature(a_Signature) - { - } - }; - typedef std::vector sDataVec; - sDataVec Data; + sSpawnDatas Data; for (UInt32 i = 0; i < DataCount; i++) { HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, Name) HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, Value) HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, Signature) - Data.push_back(sData(Name, Value, Signature)); + Data.push_back(sSpawnData(Name, Value, Signature)); } HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosX); HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosY); @@ -2242,7 +2248,7 @@ bool cConnection::HandleServerSpawnNamedEntity(void) Log(" UUID = \"%s\"", EntityUUID.c_str()); Log(" Name = \"%s\"", EntityName.c_str()); Log(" NumData = %u", DataCount); - for (sDataVec::const_iterator itr = Data.begin(), end = Data.end(); itr != end; ++itr) + for (sSpawnDatas::const_iterator itr = Data.begin(), end = Data.end(); itr != end; ++itr) { Log(" Name = \"%s\", Value = \"%s\", Signature = \"%s\"", itr->m_Name.c_str(), itr->m_Value.c_str(), itr->m_Signature.c_str() -- cgit v1.2.3 From e39f2a21d550626b962a342b23e0adfb491e6e48 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 29 Apr 2014 11:48:57 +0200 Subject: Fixed ProtoProxy. --- Tools/ProtoProxy/CMakeLists.txt | 6 ++++++ Tools/ProtoProxy/Globals.h | 14 ++++++++++++++ Tools/ProtoProxy/ProtoProxy.txt | 2 +- Tools/ProtoProxy/Server.h | 6 ++++-- 4 files changed, 25 insertions(+), 3 deletions(-) (limited to 'Tools/ProtoProxy') diff --git a/Tools/ProtoProxy/CMakeLists.txt b/Tools/ProtoProxy/CMakeLists.txt index 01f1e88ad..a94df0e24 100644 --- a/Tools/ProtoProxy/CMakeLists.txt +++ b/Tools/ProtoProxy/CMakeLists.txt @@ -37,6 +37,9 @@ set(SHARED_SRC ../../src/Log.cpp ../../src/MCLogger.cpp ../../src/Crypto.cpp + ../../src/PolarSSL++/CtrDrbgContext.cpp + ../../src/PolarSSL++/EntropyContext.cpp + ../../src/PolarSSL++/RsaPrivateKey.cpp ) set(SHARED_HDR ../../src/ByteBuffer.h @@ -44,6 +47,9 @@ set(SHARED_HDR ../../src/Log.h ../../src/MCLogger.h ../../src/Crypto.h + ../../src/PolarSSL++/CtrDrbgContext.h + ../../src/PolarSSL++/EntropyContext.h + ../../src/PolarSSL++/RsaPrivateKey.h ) set(SHARED_OSS_SRC ../../src/OSSupport/CriticalSection.cpp diff --git a/Tools/ProtoProxy/Globals.h b/Tools/ProtoProxy/Globals.h index e2f5aa860..186efa611 100644 --- a/Tools/ProtoProxy/Globals.h +++ b/Tools/ProtoProxy/Globals.h @@ -216,6 +216,20 @@ typedef unsigned char Byte; // Pretty much the same as ASSERT() but stays in Release builds #define VERIFY( x ) ( !!(x) || ( LOGERROR("Verification failed: %s, file %s, line %i", #x, __FILE__, __LINE__ ), exit(1), 0 ) ) +// Allow both Older versions of MSVC and newer versions of everything use a shared_ptr: +// Note that we cannot typedef, because C++ doesn't allow (partial) templates to be typedeffed. +#if (defined(_MSC_VER) && (_MSC_VER < 1600)) + // MSVC before 2010 doesn't have std::shared_ptr, but has std::tr1::shared_ptr, defined in included earlier + #define SharedPtr std::tr1::shared_ptr +#elif (__cplusplus >= 201103L) + // C++11 has std::shared_ptr in , included earlier + #define SharedPtr std::shared_ptr +#else + // C++03 has std::tr1::shared_ptr in + #include + #define SharedPtr std::tr1::shared_ptr +#endif + diff --git a/Tools/ProtoProxy/ProtoProxy.txt b/Tools/ProtoProxy/ProtoProxy.txt index e25d513f3..ee52f393e 100644 --- a/Tools/ProtoProxy/ProtoProxy.txt +++ b/Tools/ProtoProxy/ProtoProxy.txt @@ -20,7 +20,7 @@ You need to set the server *not* to verify usernames ("online-mode=false" in ser ProtoProxy is not much dependent on the protocol - it will work with unknown packets, it just won't parse them into human-readable format. -The latest protocol which has been tested is 1.6.1 (#73). +The latest protocol which has been tested is 1.7.9 (#5). */ diff --git a/Tools/ProtoProxy/Server.h b/Tools/ProtoProxy/Server.h index 85f817a4d..8adc7093d 100644 --- a/Tools/ProtoProxy/Server.h +++ b/Tools/ProtoProxy/Server.h @@ -9,6 +9,8 @@ #pragma once +#include "PolarSSL++/RsaPrivateKey.h" + @@ -17,7 +19,7 @@ class cServer { SOCKET m_ListenSocket; - cRSAPrivateKey m_PrivateKey; + cRsaPrivateKey m_PrivateKey; AString m_PublicKeyDER; short m_ConnectPort; @@ -27,7 +29,7 @@ public: int Init(short a_ListenPort, short a_ConnectPort); void Run(void); - cRSAPrivateKey & GetPrivateKey(void) { return m_PrivateKey; } + cRsaPrivateKey & GetPrivateKey(void) { return m_PrivateKey; } const AString & GetPublicKeyDER (void) { return m_PublicKeyDER; } short GetConnectPort(void) const { return m_ConnectPort; } -- cgit v1.2.3 From d9f7ae6a4d0895752c1a62657c36433e92104346 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 29 Apr 2014 17:13:08 +0200 Subject: Moved cPublicKey to its separate file in PolarSSL++. --- Tools/ProtoProxy/CMakeLists.txt | 2 ++ Tools/ProtoProxy/Connection.cpp | 1 + 2 files changed, 3 insertions(+) (limited to 'Tools/ProtoProxy') diff --git a/Tools/ProtoProxy/CMakeLists.txt b/Tools/ProtoProxy/CMakeLists.txt index a94df0e24..a2241f355 100644 --- a/Tools/ProtoProxy/CMakeLists.txt +++ b/Tools/ProtoProxy/CMakeLists.txt @@ -39,6 +39,7 @@ set(SHARED_SRC ../../src/Crypto.cpp ../../src/PolarSSL++/CtrDrbgContext.cpp ../../src/PolarSSL++/EntropyContext.cpp + ../../src/PolarSSL++/PublicKey.cpp ../../src/PolarSSL++/RsaPrivateKey.cpp ) set(SHARED_HDR @@ -49,6 +50,7 @@ set(SHARED_HDR ../../src/Crypto.h ../../src/PolarSSL++/CtrDrbgContext.h ../../src/PolarSSL++/EntropyContext.h + ../../src/PolarSSL++/PublicKey.h ../../src/PolarSSL++/RsaPrivateKey.h ) set(SHARED_OSS_SRC diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp index b21d2ae59..fcbd9190c 100644 --- a/Tools/ProtoProxy/Connection.cpp +++ b/Tools/ProtoProxy/Connection.cpp @@ -7,6 +7,7 @@ #include "Connection.h" #include "Server.h" #include +#include "PolarSSL++/PublicKey.h" #ifdef _WIN32 #include // For _mkdir() -- cgit v1.2.3 From 6cb2d2461f869d5c9d986cccec5edf1021878df2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 29 Apr 2014 17:37:15 +0200 Subject: Moved the rest of the Crypto objects into their own respective files. --- Tools/ProtoProxy/CMakeLists.txt | 6 ++++-- Tools/ProtoProxy/Connection.cpp | 4 ++-- Tools/ProtoProxy/Connection.h | 10 ++++++---- Tools/ProtoProxy/Globals.h | 6 ------ 4 files changed, 12 insertions(+), 14 deletions(-) (limited to 'Tools/ProtoProxy') diff --git a/Tools/ProtoProxy/CMakeLists.txt b/Tools/ProtoProxy/CMakeLists.txt index a2241f355..a136c95df 100644 --- a/Tools/ProtoProxy/CMakeLists.txt +++ b/Tools/ProtoProxy/CMakeLists.txt @@ -36,7 +36,8 @@ set(SHARED_SRC ../../src/StringUtils.cpp ../../src/Log.cpp ../../src/MCLogger.cpp - ../../src/Crypto.cpp + ../../src/PolarSSL++/AesCfb128Decryptor.cpp + ../../src/PolarSSL++/AesCfb128Encryptor.cpp ../../src/PolarSSL++/CtrDrbgContext.cpp ../../src/PolarSSL++/EntropyContext.cpp ../../src/PolarSSL++/PublicKey.cpp @@ -47,7 +48,8 @@ set(SHARED_HDR ../../src/StringUtils.h ../../src/Log.h ../../src/MCLogger.h - ../../src/Crypto.h + ../../src/PolarSSL++/AesCfb128Decryptor.h + ../../src/PolarSSL++/AesCfb128Encryptor.h ../../src/PolarSSL++/CtrDrbgContext.h ../../src/PolarSSL++/EntropyContext.h ../../src/PolarSSL++/PublicKey.h diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp index fcbd9190c..26aed2206 100644 --- a/Tools/ProtoProxy/Connection.cpp +++ b/Tools/ProtoProxy/Connection.cpp @@ -472,7 +472,7 @@ bool cConnection::SendData(SOCKET a_Socket, cByteBuffer & a_Data, const char * a -bool cConnection::SendEncryptedData(SOCKET a_Socket, cAESCFBEncryptor & a_Encryptor, const char * a_Data, size_t a_Size, const char * a_Peer) +bool cConnection::SendEncryptedData(SOCKET a_Socket, cAesCfb128Encryptor & a_Encryptor, const char * a_Data, size_t a_Size, const char * a_Peer) { DataLog(a_Data, a_Size, "Encrypting %d bytes to %s", a_Size, a_Peer); const Byte * Data = (const Byte *)a_Data; @@ -496,7 +496,7 @@ bool cConnection::SendEncryptedData(SOCKET a_Socket, cAESCFBEncryptor & a_Encryp -bool cConnection::SendEncryptedData(SOCKET a_Socket, cAESCFBEncryptor & a_Encryptor, cByteBuffer & a_Data, const char * a_Peer) +bool cConnection::SendEncryptedData(SOCKET a_Socket, cAesCfb128Encryptor & a_Encryptor, cByteBuffer & a_Data, const char * a_Peer) { AString All; a_Data.ReadAll(All); diff --git a/Tools/ProtoProxy/Connection.h b/Tools/ProtoProxy/Connection.h index 9e04994b7..1fc9536de 100644 --- a/Tools/ProtoProxy/Connection.h +++ b/Tools/ProtoProxy/Connection.h @@ -11,6 +11,8 @@ #include "ByteBuffer.h" #include "OSSupport/Timer.h" +#include "PolarSSL++/AesCfb128Decryptor.h" +#include "PolarSSL++/AesCfb128Encryptor.h" @@ -66,8 +68,8 @@ protected: cByteBuffer m_ClientBuffer; cByteBuffer m_ServerBuffer; - cAESCFBDecryptor m_ServerDecryptor; - cAESCFBEncryptor m_ServerEncryptor; + cAesCfb128Decryptor m_ServerDecryptor; + cAesCfb128Encryptor m_ServerEncryptor; AString m_ServerEncryptionBuffer; // Buffer for the data to be sent to the server once encryption is established @@ -109,10 +111,10 @@ protected: bool SendData(SOCKET a_Socket, cByteBuffer & a_Data, const char * a_Peer); /// Sends data to the specfied socket, after encrypting it using a_Encryptor. If sending fails, prints a fail message using a_Peer and returns false - bool SendEncryptedData(SOCKET a_Socket, cAESCFBEncryptor & a_Encryptor, const char * a_Data, size_t a_Size, const char * a_Peer); + bool SendEncryptedData(SOCKET a_Socket, cAesCfb128Encryptor & a_Encryptor, const char * a_Data, size_t a_Size, const char * a_Peer); /// Sends data to the specfied socket, after encrypting it using a_Encryptor. If sending fails, prints a fail message using a_Peer and returns false - bool SendEncryptedData(SOCKET a_Socket, cAESCFBEncryptor & a_Encryptor, cByteBuffer & a_Data, const char * a_Peer); + bool SendEncryptedData(SOCKET a_Socket, cAesCfb128Encryptor & a_Encryptor, cByteBuffer & a_Data, const char * a_Peer); /// Decodes packets coming from the client, sends appropriate counterparts to the server; returns false if the connection is to be dropped bool DecodeClientsPackets(const char * a_Data, int a_Size); diff --git a/Tools/ProtoProxy/Globals.h b/Tools/ProtoProxy/Globals.h index 186efa611..54e7e9251 100644 --- a/Tools/ProtoProxy/Globals.h +++ b/Tools/ProtoProxy/Globals.h @@ -246,12 +246,6 @@ public: -#include "../../src/Crypto.h" - - - - - #define LOGERROR printf #define LOGINFO printf #define LOGWARNING printf -- cgit v1.2.3 From e88811e58960d2622a58b6c6f776bd917e0a233d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 4 May 2014 14:39:21 +0200 Subject: Fixed ProtoProxy compilation in MSVC2013. Fixes #983. --- Tools/ProtoProxy/Globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Tools/ProtoProxy') diff --git a/Tools/ProtoProxy/Globals.h b/Tools/ProtoProxy/Globals.h index 54e7e9251..a9b5aa1b1 100644 --- a/Tools/ProtoProxy/Globals.h +++ b/Tools/ProtoProxy/Globals.h @@ -221,7 +221,7 @@ typedef unsigned char Byte; #if (defined(_MSC_VER) && (_MSC_VER < 1600)) // MSVC before 2010 doesn't have std::shared_ptr, but has std::tr1::shared_ptr, defined in included earlier #define SharedPtr std::tr1::shared_ptr -#elif (__cplusplus >= 201103L) +#elif (defined(_MSC_VER) || (__cplusplus >= 201103L)) // C++11 has std::shared_ptr in , included earlier #define SharedPtr std::shared_ptr #else -- cgit v1.2.3