summaryrefslogtreecommitdiff
path: root/csgo-loader/csgo-server
diff options
context:
space:
mode:
Diffstat (limited to 'csgo-loader/csgo-server')
-rw-r--r--csgo-loader/csgo-server/Networking/TCPServer.cpp8
-rw-r--r--csgo-loader/csgo-server/Security/Encryption.cpp22
-rw-r--r--csgo-loader/csgo-server/Security/Encryption.hpp12
-rw-r--r--csgo-loader/csgo-server/Server.cpp5
4 files changed, 22 insertions, 25 deletions
diff --git a/csgo-loader/csgo-server/Networking/TCPServer.cpp b/csgo-loader/csgo-server/Networking/TCPServer.cpp
index d93a710..37a21bc 100644
--- a/csgo-loader/csgo-server/Networking/TCPServer.cpp
+++ b/csgo-loader/csgo-server/Networking/TCPServer.cpp
@@ -22,6 +22,12 @@ namespace Networking
if(Result == -1)
printf("[ E! ] Failed to send %zd bytes to %s. (Socket %04Ix)\n", Bytes.size(), m_IpAddress, m_Socket);
+
+ // Stay in sync with client.
+ ByteArray Array = ReceiveRawBytes();
+
+ if(Array.empty())
+ printf("[ E! ] No client reply.\n");
}
ByteArray TCPConnection::ReceiveRawBytes()
@@ -49,8 +55,6 @@ namespace Networking
break;
}
- printf("[ <= ] Received %zd bytes from %s.\n", ReceivedBytes.size(), m_IpAddress);
-
return ReceivedBytes;
}
diff --git a/csgo-loader/csgo-server/Security/Encryption.cpp b/csgo-loader/csgo-server/Security/Encryption.cpp
index f4681b8..b42b4ab 100644
--- a/csgo-loader/csgo-server/Security/Encryption.cpp
+++ b/csgo-loader/csgo-server/Security/Encryption.cpp
@@ -580,13 +580,7 @@ namespace Wrapper
// Generate random bytes to use as encryption key.
if(CryptGenRandom(m_CryptProvider, RandomBytesCount, RandomBytes))
- {
- m_EncryptionKey.insert(
- m_EncryptionKey.begin(),
- RandomBytes,
- RandomBytes + RandomBytesCount
- );
- }
+ std::memcpy(m_EncryptionKey, RandomBytes, RandomBytesCount);
// Release context.
if(m_CryptProvider)
@@ -597,7 +591,7 @@ namespace Wrapper
{
// If an encryption key is provided, initialise the wrapper with
// the passed parameter.
- std::copy(EncryptionKey.begin(), EncryptionKey.end(), m_EncryptionKey.begin());
+ std::copy(EncryptionKey.begin(), EncryptionKey.end(), m_EncryptionKey);
if(EncryptionKey.empty())
Start();
@@ -608,11 +602,7 @@ namespace Wrapper
// Encrypt outgoing data.
ByteArray Encrypted;
- #ifdef DEBUG
- Encrypted = Data;
- #else
- Aes256::encrypt(m_EncryptionKey, Data, Encrypted);
- #endif
+ Aes256::encrypt(GetKey(), Data, Encrypted);
return Encrypted;
}
@@ -622,11 +612,7 @@ namespace Wrapper
// Decrypt incoming data.
ByteArray Decrypted;
- #ifdef DEBUG
- Decrypted = Data;
- #else
- Aes256::decrypt(m_EncryptionKey, Data, Decrypted);
- #endif
+ Aes256::decrypt(GetKey(), Data, Decrypted);
return Decrypted;
}
diff --git a/csgo-loader/csgo-server/Security/Encryption.hpp b/csgo-loader/csgo-server/Security/Encryption.hpp
index b1c49dc..a69b349 100644
--- a/csgo-loader/csgo-server/Security/Encryption.hpp
+++ b/csgo-loader/csgo-server/Security/Encryption.hpp
@@ -71,7 +71,7 @@ namespace Wrapper
// Encryption wrapper.
class Encryption
{
- ByteArray m_EncryptionKey;
+ uint8_t m_EncryptionKey[32];
HCRYPTPROV m_CryptProvider;
public:
@@ -87,7 +87,15 @@ namespace Wrapper
// Exposes the encryption key.
ByteArray GetKey()
{
- return m_EncryptionKey;
+ ByteArray TemporaryKey;
+
+ TemporaryKey.insert(
+ TemporaryKey.begin(),
+ m_EncryptionKey,
+ m_EncryptionKey + sizeof m_EncryptionKey
+ );
+
+ return TemporaryKey;
}
};
} \ No newline at end of file
diff --git a/csgo-loader/csgo-server/Server.cpp b/csgo-loader/csgo-server/Server.cpp
index 2f3f913..eeeb2b3 100644
--- a/csgo-loader/csgo-server/Server.cpp
+++ b/csgo-loader/csgo-server/Server.cpp
@@ -1,6 +1,6 @@
#include <Server.hpp>
-void ConnectionHandler(Networking::TCPConnection &)
+void ConnectionHandler(Networking::TCPConnection &Connection)
{
}
@@ -9,8 +9,7 @@ int __stdcall WinMain(HINSTANCE, HINSTANCE, char*, int)
{
// Open a debugging console.
Utils::OpenConsole();
-
-
+
// Create an instance of the TCP server.
Networking::TCPServer Server;