diff options
| author | boris <wzn@moneybot.cc> | 2018-12-19 00:13:24 +1300 |
|---|---|---|
| committer | boris <wzn@moneybot.cc> | 2018-12-19 00:13:24 +1300 |
| commit | 77b52da44b263df4884be2f35f885d8edccbb6fa (patch) | |
| tree | 54a9a07c67d507cb5120ae7e4ee86669dfec7c6b /csgo-loader/csgo-server | |
| parent | 1270999026bd77165edfffebfce277a34761710c (diff) | |
added new loader project :)
merry christmas
Diffstat (limited to 'csgo-loader/csgo-server')
| -rw-r--r-- | csgo-loader/csgo-server/Login/RemoteLogin.cpp | 51 | ||||
| -rw-r--r-- | csgo-loader/csgo-server/Login/RemoteLogin.hpp | 61 | ||||
| -rw-r--r-- | csgo-loader/csgo-server/Networking/TCPServer.cpp | 124 | ||||
| -rw-r--r-- | csgo-loader/csgo-server/Networking/TCPServer.hpp | 87 | ||||
| -rw-r--r-- | csgo-loader/csgo-server/Networking/WebSocket.cpp | 44 | ||||
| -rw-r--r-- | csgo-loader/csgo-server/Networking/WebSocket.hpp | 37 | ||||
| -rw-r--r-- | csgo-loader/csgo-server/RemoteCode/FileReader.cpp | 0 | ||||
| -rw-r--r-- | csgo-loader/csgo-server/RemoteCode/FileReader.hpp | 1 | ||||
| -rw-r--r-- | csgo-loader/csgo-server/Security/Encryption.cpp | 581 | ||||
| -rw-r--r-- | csgo-loader/csgo-server/Security/Encryption.hpp | 89 | ||||
| -rw-r--r-- | csgo-loader/csgo-server/Server.cpp | 33 | ||||
| -rw-r--r-- | csgo-loader/csgo-server/csgo-server.vcxproj | 152 | ||||
| -rw-r--r-- | csgo-loader/csgo-server/csgo-server.vcxproj.filters | 52 |
13 files changed, 1312 insertions, 0 deletions
diff --git a/csgo-loader/csgo-server/Login/RemoteLogin.cpp b/csgo-loader/csgo-server/Login/RemoteLogin.cpp new file mode 100644 index 0000000..880c072 --- /dev/null +++ b/csgo-loader/csgo-server/Login/RemoteLogin.cpp @@ -0,0 +1,51 @@ +#include <Login/RemoteLogin.hpp>
+
+#define EXPECTED_CLIENT_HEADER 0xDEADBEEF
+
+namespace Login {
+ bool RemoteLoginServer::Start(ByteArray &RawLoginHeader) {
+ if(RawLoginHeader.empty())
+ return false;
+
+ // Epic direct casts :---DDDD
+ m_Header = *reinterpret_cast<RemoteLoginHeader *>(&RawLoginHeader[0]);
+ return true;
+ }
+
+ RemoteLoginResponse RemoteLoginServer::GetLoginResponse() {
+ // The header seems to be wrong, tell the client to update.
+ if(m_Header.m_ClientHeader != EXPECTED_CLIENT_HEADER)
+ return RemoteLoginResponse::OUTDATED_CLIENT;
+
+ // TODO: Check login, HWID, bans with websockets.
+
+ // User failed to obtain HWID?
+ if(!m_Header.m_HardwareId) {
+ // TODO: Shadow ban the user.
+
+ //return RemoteLoginResponse::INVALID_HARDWARE;
+ }
+
+ // Checksum validation.
+ uint8_t Checksum = m_Header.m_IntegrityBit1
+ | m_Header.m_IntegrityBit2
+ | m_Header.m_IntegrityBit3;
+
+ if(Checksum || Checksum != m_Header.m_IntegrityBit4) {
+ // TODO: Shadow ban the user.
+ return RemoteLoginResponse::INTEGRITY_FAILURE;
+ }
+
+ // Assume that they are authorised to use the cheat.
+ return RemoteLoginResponse::ACCESS_SPECIAL_USER;
+ }
+
+ ByteArray RemoteLoginServer::GetResponse() {
+ // The way the server handles data transmission is homosexual.
+ // That is the only reason this autism is here.
+ ByteArray Response;
+ Response.push_back(GetLoginResponse());
+
+ return Response;
+ }
+}
\ No newline at end of file diff --git a/csgo-loader/csgo-server/Login/RemoteLogin.hpp b/csgo-loader/csgo-server/Login/RemoteLogin.hpp new file mode 100644 index 0000000..36b7252 --- /dev/null +++ b/csgo-loader/csgo-server/Login/RemoteLogin.hpp @@ -0,0 +1,61 @@ +#pragma once
+
+#include <cstdint>
+#include <algorithm>
+#include <vector>
+
+using ByteArray = std::vector<uint8_t>;
+
+namespace Login {
+ // Login header that is sent over to the server
+ struct RemoteLoginHeader {
+ // The first four bytes are encoded by the client.
+ // This will carry the client version which can be checked.
+ uint32_t m_ClientHeader;
+
+ // The username is raw text.
+ // TODO: Hash the password client-side.
+ char m_Username[128];
+ char m_Password[128];
+
+ // This will provide the hardware ID of the machine.
+ uint32_t m_HardwareId;
+
+ // These fields will be set according
+ // to security check results.
+ uint8_t m_IntegrityBit1; // Detour detected on NTDLL function
+ uint8_t m_IntegrityBit2; // Detour detected on dummy function
+ uint8_t m_IntegrityBit3; // Virtual machine/Debugger detected
+ uint8_t m_IntegrityBit4; // m_IntegrityBit1 | m_IntegrityBit2 | m_IntegrityBit3 (checksum)
+ };
+
+ // Possible server responses
+ // The hardware ID is encoded (XORed with the message ID) within the message for
+ // shadow ban/forum ban purposes. :)
+ enum RemoteLoginResponse : uint8_t {
+ OUTDATED_CLIENT = 'A', // '[000A:{HWID}] Your client is outdated. Please download the latest client at 'moneybot.cc'.'
+ ACCESS_AUTHORISED = 'B', // Allows the user to continue with injection.
+ INVALID_CREDENTIALS = 'C', // '[000C:{HWID}] Your credentials are invalid. Please check your spelling and try again.'
+ USER_BANNED = 'D', // '[000D:{HWID}] Your account is banned. Please contact 'admin@moneybot.cc' for additional information.'
+ INVALID_HARDWARE = 'E', // '[000E:{HWID}] Please contact an administrator to request a hardware ID reset.'
+ INTEGRITY_FAILURE = 'F', // '[000F:{HWID}] Failed to verify session. Please contact an administrator.' AKA the 'shadow ban', blacklists user from loader but not from forums.
+ NO_SUBSCRIPTION = 'G', // '[000G:{HWID}] No active subscription.'
+ ACCESS_SPECIAL_USER = 'H', // Allows the user to continue, sets the m_SpecialAccess var
+ };
+ // Implementation of the server (handles login bullshit).
+ class RemoteLoginServer {
+ RemoteLoginHeader m_Header;
+
+ // Polls the server for data, responds with whether or not the client
+ // is allowed to use the cheat.
+ RemoteLoginResponse GetLoginResponse();
+
+ public:
+ // Initialises the login header.
+ bool Start(ByteArray &RawLoginHeader);
+
+ ByteArray GetResponse();
+
+ // TODO: Implement shadow banning based on IP and HWID.
+ };
+}
\ No newline at end of file diff --git a/csgo-loader/csgo-server/Networking/TCPServer.cpp b/csgo-loader/csgo-server/Networking/TCPServer.cpp new file mode 100644 index 0000000..725bf1a --- /dev/null +++ b/csgo-loader/csgo-server/Networking/TCPServer.cpp @@ -0,0 +1,124 @@ +#include <Networking/TCPServer.hpp>
+
+namespace Networking {
+ void TCPConnection::Close() {
+ printf("[<=] %s disconnected!\n", m_IpAddress);
+
+ if(m_Socket)
+ closesocket(m_Socket);
+ }
+
+ // We will only receive up to 256 bytes per cycle.
+ constexpr int BufferSize = 256;
+
+ void TCPConnection::SendRawBytes(ByteArray &Bytes) {
+ // Send data.
+ int32_t Result = send(m_Socket, (char *)Bytes.data(), (int)Bytes.size(), 0);
+
+ printf("[=>] Sending %zd bytes to %s.\n", Bytes.size(), m_IpAddress);
+
+ if(Result == -1)
+ printf("[=>] Failed to send %zd bytes to %s. (Socket %04Ix)\n", Bytes.size(), m_IpAddress, m_Socket);
+ }
+
+ ByteArray TCPConnection::ReceiveRawBytes() {
+ ByteArray ReceivedBytes;
+ uint8_t RecvBuffer[BufferSize];
+
+ // Attempt to receive a packet.
+ while(true) {
+ int32_t Received = recv(m_Socket, (char*)RecvBuffer, BufferSize, 0);
+
+ // No more bytes left to receive.
+ if(Received < 0)
+ break;
+
+ // Emplace all received bytes.
+ for(int n = 0; n < Received; ++n) {
+ ReceivedBytes.push_back(RecvBuffer[n]);
+ }
+
+ // No more bytes left to receive.
+ if(Received < BufferSize)
+ break;
+ }
+
+ printf("[<=] Received %zd bytes from %s.\n", ReceivedBytes.size(), m_IpAddress);
+
+ return ReceivedBytes;
+ }
+
+ void TCPConnection::SendBytes(ByteArray &Bytes) {
+ // Encrypt outgoing data.
+ ByteArray Encrypted = m_Encryption.Encrypt(Bytes);
+
+ SendRawBytes(Encrypted);
+ }
+
+ ByteArray TCPConnection::ReceiveBytes() {
+ ByteArray ReceivedBytes = ReceiveRawBytes();
+
+ // Decrypt incoming data.
+ ByteArray Decrypted = m_Encryption.Decrypt(ReceivedBytes);
+
+ return Decrypted;
+ }
+
+ bool TCPServer::Start(uint16_t ServerPort) {
+ const int32_t version = 0x101;
+
+ // Initialise WinSocks.
+ if(WSAStartup(version, &m_WinSocks))
+ return false;
+
+ // Create an IPv4 socket.
+ m_Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+
+ if(m_Socket == INVALID_SOCKET)
+ return false;
+
+ // Set up server context.
+ m_Context.sin_addr.s_addr = INADDR_ANY;
+ m_Context.sin_family = AF_INET;
+ m_Context.sin_port = htons(ServerPort);
+
+ int32_t Bind = bind(m_Socket, (sockaddr *)&m_Context, sizeof sockaddr_in);
+
+ if(Bind == INVALID_SOCKET)
+ return false;
+
+ // Start listening.
+ printf("[INFO] Server listening on port %d.\n", ServerPort);
+ listen(m_Socket, 1);
+
+ return true;
+ }
+
+ void TCPServer::AcceptConnection() {
+ sockaddr_in IncomingConnection;
+ int32_t AddressLength = sizeof IncomingConnection;
+
+ // Accept the incoming connection.
+ SOCKET IncomingSocket = accept(m_Socket, (sockaddr *)&IncomingConnection, &AddressLength);
+
+ if(IncomingSocket != INVALID_SOCKET) {
+ Wrapper::Encryption Encryption;
+
+ // Initialise encryption context.
+ Encryption.Start();
+
+ // Attempt handshake with client.
+ TCPConnection Connection(IncomingSocket, inet_ntoa(IncomingConnection.sin_addr), Encryption);
+
+ ByteArray EncryptionKey = Connection.GetEncryptionKey();
+ Connection.SendRawBytes(EncryptionKey);
+
+ // Detach a thread to handle the connection.
+ std::thread thread([&] {
+ m_ConnectionHandler(Connection);
+ Connection.Close();
+ });
+ thread.detach();
+ }
+ }
+}
\ No newline at end of file diff --git a/csgo-loader/csgo-server/Networking/TCPServer.hpp b/csgo-loader/csgo-server/Networking/TCPServer.hpp new file mode 100644 index 0000000..adb6e7c --- /dev/null +++ b/csgo-loader/csgo-server/Networking/TCPServer.hpp @@ -0,0 +1,87 @@ +#pragma once
+
+// For encryption wrappers.
+#include <Security/Encryption.hpp>
+
+// WinSocks
+#include <winsock2.h>
+#pragma comment(lib, "ws2_32.lib")
+
+// std::function
+#include <functional>
+
+// std::min
+#include <algorithm>
+
+// std::thread
+#include <thread>
+
+namespace Networking {
+ // Base connection class, used to handle multiple connections in a thread-based model.
+ class TCPConnection {
+ SOCKET m_Socket;
+ Wrapper::Encryption m_Encryption;
+ const char *m_IpAddress;
+ public:
+ // Initialiser for TCPConnection class.
+ TCPConnection(SOCKET Connection, const char *IpAddress, Wrapper::Encryption &RSA) :
+ m_Encryption(RSA), m_Socket(Connection), m_IpAddress(IpAddress) {
+ printf("[=>] %s connected!\n", IpAddress);
+ }
+
+ // Release the connection once it goes out of scope.
+ void Close();
+
+ // Wrappers for sending/receiving data.
+ void SendRawBytes(ByteArray &Bytes);
+ ByteArray ReceiveRawBytes();
+
+ void SendBytes(ByteArray &Bytes);
+ ByteArray ReceiveBytes();
+
+ // Overload for getting the socket, in case we need to expose it.
+ SOCKET operator()() {
+ return m_Socket;
+ }
+
+ // Expose the encryption key for the connection.
+ ByteArray GetEncryptionKey() {
+ return m_Encryption.GetKey();
+ }
+ };
+
+ // Basic TCP server. Supports custom connection handling (pass a lambda to the handler list).
+ using ConnectionHandler = std::function<void(TCPConnection &)>;
+
+ class TCPServer {
+ WSADATA m_WinSocks;
+ SOCKET m_Socket;
+ sockaddr_in m_Context;
+
+ // Connection handlers, will be called sequentially upon connection.
+ ConnectionHandler m_ConnectionHandler;
+
+ public:
+ // Default constructor, nothing needed for now.
+ TCPServer() = default;
+
+ // Handle destruction of server once it goes out of scope.
+ ~TCPServer() {
+ // If we have a socket, close it.
+ if(m_Socket)
+ closesocket(m_Socket);
+
+ // Close WSA context.
+ WSACleanup();
+ }
+
+ // Handle the creation and handling of TCPServer connections.
+ bool Start(uint16_t ServerPort);
+ void AcceptConnection();
+
+ // Overload for adding connection handlers, C# style support for events.
+ void operator+=(std::function<void(TCPConnection &)> Function) {
+ m_ConnectionHandler = Function;
+ }
+ };
+}
\ No newline at end of file diff --git a/csgo-loader/csgo-server/Networking/WebSocket.cpp b/csgo-loader/csgo-server/Networking/WebSocket.cpp new file mode 100644 index 0000000..755e89b --- /dev/null +++ b/csgo-loader/csgo-server/Networking/WebSocket.cpp @@ -0,0 +1,44 @@ +#include <Networking/WebSocket.hpp>
+
+namespace Networking {
+ // Initialises a basic HTTP socket.
+ bool WebSocket::Start(const char *Address, const char *Username, const char *Password) {
+ m_Internet = InternetOpenA("none", INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, 0);
+
+ if(!m_Internet)
+ return false;
+
+ m_Address = InternetConnectA(m_Internet, Address, INTERNET_DEFAULT_HTTPS_PORT, Username, Password, INTERNET_SERVICE_HTTP, 0, 0);
+
+ if(!m_Address)
+ return false;
+
+ return true;
+ }
+
+ // Receives a response from a request.
+ ByteArray WebSocket::Request(const char *File, const char *Header, ByteArray &Data) {
+ ByteArray Response;
+ InternetHandle WebRequest = HttpOpenRequestA(m_Address, "POST", File, 0, 0, 0, INTERNET_FLAG_SECURE | INTERNET_FLAG_KEEP_CONNECTION, 0);
+
+ // Make connection request.
+ bool Sent = HttpSendRequestA(WebRequest, Header, (DWORD)strlen(Header), Data.data(), (DWORD)Data.size());
+
+ if(Sent) {
+ DWORD ReceivedSize{};
+
+ uint8_t *Block = (uint8_t *)malloc(4096);
+
+ // Read response.
+ while(InternetReadFile(WebRequest, Block, 4096, &ReceivedSize)) {
+ for(size_t n{}; n < std::min< int >(4096, ReceivedSize); ++n) {
+ Response.push_back(Block[n]);
+ }
+ }
+
+ free(Block);
+ }
+
+ return Response;
+ }
+}
\ No newline at end of file diff --git a/csgo-loader/csgo-server/Networking/WebSocket.hpp b/csgo-loader/csgo-server/Networking/WebSocket.hpp new file mode 100644 index 0000000..f503913 --- /dev/null +++ b/csgo-loader/csgo-server/Networking/WebSocket.hpp @@ -0,0 +1,37 @@ +#pragma once
+
+#include <windows.h>
+#include <wininet.h>
+#include <vector>
+#include <algorithm>
+#include <cstdint>
+
+#pragma comment(lib, "wininet.lib")
+
+using ByteArray = std::vector<uint8_t>;
+
+namespace Networking {
+ // Whenever the handle goes out of scope, it will automatically be released.
+ class InternetHandle {
+ HINTERNET m_Internet;
+ public:
+ InternetHandle() = default;
+ InternetHandle(HINTERNET Internet) :
+ m_Internet(Internet) { }
+
+ ~InternetHandle() {
+ InternetCloseHandle(m_Internet);
+ }
+
+ operator HINTERNET() { return m_Internet; };
+ };
+
+ class WebSocket {
+ InternetHandle m_Internet;
+ InternetHandle m_Address;
+
+ public:
+ bool Start(const char *Address, const char *Username, const char *Password);
+ ByteArray Request(const char *File, const char *Header, ByteArray &Data);
+ };
+}
\ No newline at end of file diff --git a/csgo-loader/csgo-server/RemoteCode/FileReader.cpp b/csgo-loader/csgo-server/RemoteCode/FileReader.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/csgo-loader/csgo-server/RemoteCode/FileReader.cpp diff --git a/csgo-loader/csgo-server/RemoteCode/FileReader.hpp b/csgo-loader/csgo-server/RemoteCode/FileReader.hpp new file mode 100644 index 0000000..50e9667 --- /dev/null +++ b/csgo-loader/csgo-server/RemoteCode/FileReader.hpp @@ -0,0 +1 @@ +#pragma once
diff --git a/csgo-loader/csgo-server/Security/Encryption.cpp b/csgo-loader/csgo-server/Security/Encryption.cpp new file mode 100644 index 0000000..94b9ee7 --- /dev/null +++ b/csgo-loader/csgo-server/Security/Encryption.cpp @@ -0,0 +1,581 @@ +#include <Security/Encryption.hpp>
+
+#define FE(x) (((x) << 1) ^ ((((x)>>7) & 1) * 0x1b))
+#define FD(x) (((x) >> 1) ^ (((x) & 1) ? 0x8d : 0))
+
+#define KEY_SIZE 32
+#define NUM_ROUNDS 14
+
+namespace Wrapper {
+ // Constants used for the AES256 algorithm.
+ uint8_t sbox[256] = {
+ 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5,
+ 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
+ 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0,
+ 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
+ 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc,
+ 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
+ 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a,
+ 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
+ 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0,
+ 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
+ 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b,
+ 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
+ 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85,
+ 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
+ 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5,
+ 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
+ 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17,
+ 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
+ 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88,
+ 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
+ 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c,
+ 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
+ 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9,
+ 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
+ 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6,
+ 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
+ 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e,
+ 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
+ 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94,
+ 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
+ 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68,
+ 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
+ };
+
+ uint8_t sboxinv[256] = {
+ 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38,
+ 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb,
+ 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87,
+ 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb,
+ 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d,
+ 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,
+ 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2,
+ 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25,
+ 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16,
+ 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92,
+ 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda,
+ 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,
+ 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a,
+ 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06,
+ 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02,
+ 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b,
+ 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea,
+ 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,
+ 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85,
+ 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e,
+ 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89,
+ 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b,
+ 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20,
+ 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,
+ 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31,
+ 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f,
+ 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d,
+ 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef,
+ 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0,
+ 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61,
+ 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26,
+ 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d
+ };
+
+ // Implementation of the AES256 encryption algorithm.
+ unsigned char rj_xtime(unsigned char x);
+
+ Aes256::Aes256(const ByteArray& key)
+ : m_key(ByteArray(key.size() > KEY_SIZE ? KEY_SIZE : key.size(), 0))
+ , m_salt(ByteArray(KEY_SIZE - m_key.size(), 0))
+ , m_rkey(ByteArray(KEY_SIZE, 0))
+ , m_buffer_pos(0)
+ , m_remainingLength(0)
+ , m_decryptInitialized(false) {
+ for(ByteArray::size_type i = 0; i < m_key.size(); ++i)
+ m_key[i] = key[i];
+ }
+
+ Aes256::~Aes256() {
+ }
+
+ ByteArray::size_type Aes256::encrypt(const ByteArray& key, const ByteArray& plain, ByteArray& encrypted) {
+ Aes256 aes(key);
+
+ aes.encrypt_start(plain.size(), encrypted);
+ aes.encrypt_continue(plain, encrypted);
+ aes.encrypt_end(encrypted);
+
+ return encrypted.size();
+ }
+
+ ByteArray::size_type Aes256::encrypt(const ByteArray& key, const unsigned char* plain, const ByteArray::size_type plain_length, ByteArray& encrypted) {
+ Aes256 aes(key);
+
+ aes.encrypt_start(plain_length, encrypted);
+ aes.encrypt_continue(plain, plain_length, encrypted);
+ aes.encrypt_end(encrypted);
+
+ return encrypted.size();
+ }
+
+ ByteArray::size_type Aes256::decrypt(const ByteArray& key, const ByteArray& encrypted, ByteArray& plain) {
+ Aes256 aes(key);
+
+ aes.decrypt_start(encrypted.size());
+ aes.decrypt_continue(encrypted, plain);
+ aes.decrypt_end(plain);
+
+ return plain.size();
+ }
+
+ ByteArray::size_type Aes256::decrypt(const ByteArray& key, const unsigned char* encrypted, const ByteArray::size_type encrypted_length, ByteArray& plain) {
+ Aes256 aes(key);
+
+ aes.decrypt_start(encrypted_length);
+ aes.decrypt_continue(encrypted, encrypted_length, plain);
+ aes.decrypt_end(plain);
+
+ return plain.size();
+ }
+
+ ByteArray::size_type Aes256::encrypt_start(const ByteArray::size_type plain_length, ByteArray& encrypted) {
+ m_remainingLength = plain_length;
+
+ // Generate salt
+ ByteArray::iterator it = m_salt.begin(), itEnd = m_salt.end();
+ while(it != itEnd)
+ *(it++) = (rand() & 0xFF);
+
+ // Calculate padding
+ ByteArray::size_type padding = 0;
+ if(m_remainingLength % BLOCK_SIZE != 0)
+ padding = (BLOCK_SIZE - (m_remainingLength % BLOCK_SIZE));
+ m_remainingLength += padding;
+
+ // Add salt
+ encrypted.insert(encrypted.end(), m_salt.begin(), m_salt.end());
+ m_remainingLength += m_salt.size();
+
+ // Add 1 bytes for padding size
+ encrypted.push_back(padding & 0xFF);
+ ++m_remainingLength;
+
+ // Reset buffer
+ m_buffer_pos = 0;
+
+ return encrypted.size();
+ }
+
+ ByteArray::size_type Aes256::encrypt_continue(const ByteArray& plain, ByteArray& encrypted) {
+ ByteArray::const_iterator it = plain.begin(), itEnd = plain.end();
+
+ while(it != itEnd) {
+ m_buffer[m_buffer_pos++] = *(it++);
+
+ check_and_encrypt_buffer(encrypted);
+ }
+
+ return encrypted.size();
+ }
+
+ ByteArray::size_type Aes256::encrypt_continue(const unsigned char* plain, const ByteArray::size_type plain_length, ByteArray& encrypted) {
+ ByteArray::size_type i = 0;
+
+ while(i < plain_length) {
+ m_buffer[m_buffer_pos++] = plain[i++];
+
+ check_and_encrypt_buffer(encrypted);
+ }
+
+ return encrypted.size();
+ }
+
+ void Aes256::check_and_encrypt_buffer(ByteArray& encrypted) {
+ if(m_buffer_pos == BLOCK_SIZE) {
+ encrypt(m_buffer);
+
+ for(m_buffer_pos = 0; m_buffer_pos < BLOCK_SIZE; ++m_buffer_pos) {
+ encrypted.push_back(m_buffer[m_buffer_pos]);
+ --m_remainingLength;
+ }
+
+ m_buffer_pos = 0;
+ }
+ }
+
+ ByteArray::size_type Aes256::encrypt_end(ByteArray& encrypted) {
+ if(m_buffer_pos > 0) {
+ while(m_buffer_pos < BLOCK_SIZE)
+ m_buffer[m_buffer_pos++] = 0;
+
+ encrypt(m_buffer);
+
+ for(m_buffer_pos = 0; m_buffer_pos < BLOCK_SIZE; ++m_buffer_pos) {
+ encrypted.push_back(m_buffer[m_buffer_pos]);
+ --m_remainingLength;
+ }
+
+ m_buffer_pos = 0;
+ }
+
+ return encrypted.size();
+ }
+
+ void Aes256::encrypt(unsigned char* buffer) {
+ unsigned char i, rcon;
+
+ copy_key();
+ add_round_key(buffer, 0);
+ for(i = 1, rcon = 1; i < NUM_ROUNDS; ++i) {
+ sub_bytes(buffer);
+ shift_rows(buffer);
+ mix_columns(buffer);
+ if(!(i & 1))
+ expand_enc_key(&rcon);
+ add_round_key(buffer, i);
+ }
+ sub_bytes(buffer);
+ shift_rows(buffer);
+ expand_enc_key(&rcon);
+ add_round_key(buffer, i);
+ }
+
+ ByteArray::size_type Aes256::decrypt_start(const ByteArray::size_type encrypted_length) {
+ register unsigned char j;
+
+ m_remainingLength = encrypted_length;
+
+ // Reset salt
+ for(j = 0; j < m_salt.size(); ++j)
+ m_salt[j] = 0;
+ m_remainingLength -= m_salt.size();
+
+ // Reset buffer
+ m_buffer_pos = 0;
+
+ m_decryptInitialized = false;
+
+ return m_remainingLength;
+ }
+
+ ByteArray::size_type Aes256::decrypt_continue(const ByteArray& encrypted, ByteArray& plain) {
+ ByteArray::const_iterator it = encrypted.begin(), itEnd = encrypted.end();
+
+ while(it != itEnd) {
+ m_buffer[m_buffer_pos++] = *(it++);
+
+ check_and_decrypt_buffer(plain);
+ }
+
+ return plain.size();
+ }
+
+ ByteArray::size_type Aes256::decrypt_continue(const unsigned char* encrypted, const ByteArray::size_type encrypted_length, ByteArray& plain) {
+ ByteArray::size_type i = 0;
+
+ while(i < encrypted_length) {
+ m_buffer[m_buffer_pos++] = encrypted[i++];
+
+ check_and_decrypt_buffer(plain);
+ }
+
+ return plain.size();
+ }
+
+ void Aes256::check_and_decrypt_buffer(ByteArray& plain) {
+ if(!m_decryptInitialized && m_buffer_pos == m_salt.size() + 1) {
+ register unsigned char j;
+ ByteArray::size_type padding;
+
+ // Get salt
+ for(j = 0; j < m_salt.size(); ++j)
+ m_salt[j] = m_buffer[j];
+
+ // Get padding
+ padding = (m_buffer[j] & 0xFF);
+ m_remainingLength -= padding + 1;
+
+ // Start decrypting
+ m_buffer_pos = 0;
+
+ m_decryptInitialized = true;
+ }
+ else if(m_decryptInitialized && m_buffer_pos == BLOCK_SIZE) {
+ decrypt(m_buffer);
+
+ for(m_buffer_pos = 0; m_buffer_pos < BLOCK_SIZE; ++m_buffer_pos)
+ if(m_remainingLength > 0) {
+ plain.push_back(m_buffer[m_buffer_pos]);
+ --m_remainingLength;
+ }
+
+ m_buffer_pos = 0;
+ }
+ }
+
+ ByteArray::size_type Aes256::decrypt_end(ByteArray& plain) {
+ return plain.size();
+ }
+
+ void Aes256::decrypt(unsigned char* buffer) {
+ unsigned char i, rcon = 1;
+
+ copy_key();
+ for(i = NUM_ROUNDS / 2; i > 0; --i)
+ expand_enc_key(&rcon);
+
+ add_round_key(buffer, NUM_ROUNDS);
+ shift_rows_inv(buffer);
+ sub_bytes_inv(buffer);
+
+ for(i = NUM_ROUNDS, rcon = 0x80; --i;) {
+ if((i & 1))
+ expand_dec_key(&rcon);
+ add_round_key(buffer, i);
+ mix_columns_inv(buffer);
+ shift_rows_inv(buffer);
+ sub_bytes_inv(buffer);
+ }
+ add_round_key(buffer, i);
+ }
+
+ void Aes256::expand_enc_key(unsigned char* rc) {
+ register unsigned char i;
+
+ m_rkey[0] = m_rkey[0] ^ sbox[m_rkey[29]] ^ (*rc);
+ m_rkey[1] = m_rkey[1] ^ sbox[m_rkey[30]];
+ m_rkey[2] = m_rkey[2] ^ sbox[m_rkey[31]];
+ m_rkey[3] = m_rkey[3] ^ sbox[m_rkey[28]];
+ *rc = FE(*rc);
+
+ for(i = 4; i < 16; i += 4) {
+ m_rkey[i] = m_rkey[i] ^ m_rkey[i - 4];
+ m_rkey[i + 1] = m_rkey[i + 1] ^ m_rkey[i - 3];
+ m_rkey[i + 2] = m_rkey[i + 2] ^ m_rkey[i - 2];
+ m_rkey[i + 3] = m_rkey[i + 3] ^ m_rkey[i - 1];
+ }
+ m_rkey[16] = m_rkey[16] ^ sbox[m_rkey[12]];
+ m_rkey[17] = m_rkey[17] ^ sbox[m_rkey[13]];
+ m_rkey[18] = m_rkey[18] ^ sbox[m_rkey[14]];
+ m_rkey[19] = m_rkey[19] ^ sbox[m_rkey[15]];
+
+ for(i = 20; i < 32; i += 4) {
+ m_rkey[i] = m_rkey[i] ^ m_rkey[i - 4];
+ m_rkey[i + 1] = m_rkey[i + 1] ^ m_rkey[i - 3];
+ m_rkey[i + 2] = m_rkey[i + 2] ^ m_rkey[i - 2];
+ m_rkey[i + 3] = m_rkey[i + 3] ^ m_rkey[i - 1];
+ }
+ }
+
+ void Aes256::expand_dec_key(unsigned char* rc) {
+ unsigned char i;
+
+ for(i = 28; i > 16; i -= 4) {
+ m_rkey[i + 0] = m_rkey[i + 0] ^ m_rkey[i - 4];
+ m_rkey[i + 1] = m_rkey[i + 1] ^ m_rkey[i - 3];
+ m_rkey[i + 2] = m_rkey[i + 2] ^ m_rkey[i - 2];
+ m_rkey[i + 3] = m_rkey[i + 3] ^ m_rkey[i - 1];
+ }
+
+ m_rkey[16] = m_rkey[16] ^ sbox[m_rkey[12]];
+ m_rkey[17] = m_rkey[17] ^ sbox[m_rkey[13]];
+ m_rkey[18] = m_rkey[18] ^ sbox[m_rkey[14]];
+ m_rkey[19] = m_rkey[19] ^ sbox[m_rkey[15]];
+
+ for(i = 12; i > 0; i -= 4) {
+ m_rkey[i + 0] = m_rkey[i + 0] ^ m_rkey[i - 4];
+ m_rkey[i + 1] = m_rkey[i + 1] ^ m_rkey[i - 3];
+ m_rkey[i + 2] = m_rkey[i + 2] ^ m_rkey[i - 2];
+ m_rkey[i + 3] = m_rkey[i + 3] ^ m_rkey[i - 1];
+ }
+
+ *rc = FD(*rc);
+ m_rkey[0] = m_rkey[0] ^ sbox[m_rkey[29]] ^ (*rc);
+ m_rkey[1] = m_rkey[1] ^ sbox[m_rkey[30]];
+ m_rkey[2] = m_rkey[2] ^ sbox[m_rkey[31]];
+ m_rkey[3] = m_rkey[3] ^ sbox[m_rkey[28]];
+ }
+
+ void Aes256::sub_bytes(unsigned char* buffer) {
+ register unsigned char i = KEY_SIZE / 2;
+
+ while(i--)
+ buffer[i] = sbox[buffer[i]];
+ }
+
+ void Aes256::sub_bytes_inv(unsigned char* buffer) {
+ register unsigned char i = KEY_SIZE / 2;
+
+ while(i--)
+ buffer[i] = sboxinv[buffer[i]];
+ }
+
+ void Aes256::copy_key() {
+ ByteArray::size_type i;
+
+ for(i = 0; i < m_key.size(); ++i)
+ m_rkey[i] = m_key[i];
+ for(i = 0; i < m_salt.size(); ++i)
+ m_rkey[i + m_key.size()] = m_salt[i];
+ }
+
+ void Aes256::add_round_key(unsigned char* buffer, const unsigned char round) {
+ register unsigned char i = KEY_SIZE / 2;
+
+ while(i--)
+ buffer[i] ^= m_rkey[(round & 1) ? i + 16 : i];
+ }
+
+ void Aes256::shift_rows(unsigned char* buffer) {
+ register unsigned char i, j, k, l; /* to make it potentially parallelable :) */
+
+ i = buffer[1];
+ buffer[1] = buffer[5];
+ buffer[5] = buffer[9];
+ buffer[9] = buffer[13];
+ buffer[13] = i;
+
+ j = buffer[10];
+ buffer[10] = buffer[2];
+ buffer[2] = j;
+
+ k = buffer[3];
+ buffer[3] = buffer[15];
+ buffer[15] = buffer[11];
+ buffer[11] = buffer[7];
+ buffer[7] = k;
+
+ l = buffer[14];
+ buffer[14] = buffer[6];
+ buffer[6] = l;
+ }
+
+ void Aes256::shift_rows_inv(unsigned char* buffer) {
+ register unsigned char i, j, k, l; /* same as above :) */
+
+ i = buffer[1];
+ buffer[1] = buffer[13];
+ buffer[13] = buffer[9];
+ buffer[9] = buffer[5];
+ buffer[5] = i;
+
+ j = buffer[2];
+ buffer[2] = buffer[10];
+ buffer[10] = j;
+
+ k = buffer[3];
+ buffer[3] = buffer[7];
+ buffer[7] = buffer[11];
+ buffer[11] = buffer[15];
+ buffer[15] = k;
+
+ l = buffer[6];
+ buffer[6] = buffer[14];
+ buffer[14] = l;
+ }
+
+ void Aes256::mix_columns(unsigned char* buffer) {
+ register unsigned char i, a, b, c, d, e;
+
+ for(i = 0; i < 16; i += 4) {
+ a = buffer[i];
+ b = buffer[i + 1];
+ c = buffer[i + 2];
+ d = buffer[i + 3];
+
+ e = a ^ b ^ c ^ d;
+
+ buffer[i] ^= e ^ rj_xtime(a^b);
+ buffer[i + 1] ^= e ^ rj_xtime(b^c);
+ buffer[i + 2] ^= e ^ rj_xtime(c^d);
+ buffer[i + 3] ^= e ^ rj_xtime(d^a);
+ }
+ }
+
+ void Aes256::mix_columns_inv(unsigned char* buffer) {
+ register unsigned char i, a, b, c, d, e, x, y, z;
+
+ for(i = 0; i < 16; i += 4) {
+ a = buffer[i];
+ b = buffer[i + 1];
+ c = buffer[i + 2];
+ d = buffer[i + 3];
+
+ e = a ^ b ^ c ^ d;
+ z = rj_xtime(e);
+ x = e ^ rj_xtime(rj_xtime(z^a^c)); y = e ^ rj_xtime(rj_xtime(z^b^d));
+
+ buffer[i] ^= x ^ rj_xtime(a^b);
+ buffer[i + 1] ^= y ^ rj_xtime(b^c);
+ buffer[i + 2] ^= x ^ rj_xtime(c^d);
+ buffer[i + 3] ^= y ^ rj_xtime(d^a);
+ }
+ }
+
+ inline unsigned char rj_xtime(unsigned char x) {
+ return (x & 0x80) ? ((x << 1) ^ 0x1b) : (x << 1);
+ }
+
+ // Wrapper for the AES256 encryption algorithm.
+ void Encryption::Start() {
+ // Create cryptographic context.
+ if(!CryptAcquireContextA(&m_CryptProvider, nullptr, nullptr, PROV_RSA_AES, 0)) {
+ if(!CryptAcquireContextA(&m_CryptProvider, nullptr, nullptr, PROV_RSA_AES, CRYPT_NEWKEYSET)) {
+ printf("Failed to initialise encryption provider.\n");
+ return;
+ }
+ }
+
+ uint8_t RandomBytes[32];
+ uint32_t RandomBytesCount = sizeof RandomBytes;
+
+ // Generate random bytes to use as encryption key.
+ if(CryptGenRandom(m_CryptProvider, RandomBytesCount, RandomBytes)) {
+ m_EncryptionKey.reserve(RandomBytesCount);
+ m_EncryptionKey.insert(
+ m_EncryptionKey.begin(),
+ RandomBytes,
+ RandomBytes + RandomBytesCount
+ );
+ }
+
+ // Release context.
+ if(m_CryptProvider)
+ CryptReleaseContext(m_CryptProvider, 0);
+ }
+
+ void Encryption::Start(ByteArray &EncryptionKey) {
+ // If an encryption key is provided, initialise the wrapper with
+ // the passed parameter.
+ if(!EncryptionKey.empty()) {
+ m_EncryptionKey.reserve(EncryptionKey.size());
+ std::copy(EncryptionKey.begin(), EncryptionKey.end(), m_EncryptionKey.begin());
+ }
+ else {
+ Start();
+ }
+ }
+
+ ByteArray Encryption::Encrypt(ByteArray &Data) {
+ // Encrypt outgoing data.
+ ByteArray Encrypted;
+
+ #ifdef DEBUG
+ Encrypted = Data;
+ #else
+ Aes256::encrypt(m_EncryptionKey, Data, Encrypted);
+ #endif
+
+ return Encrypted;
+ }
+
+ ByteArray Encryption::Decrypt(ByteArray &Data) {
+ // Decrypt incoming data.
+ ByteArray Decrypted;
+
+ #ifdef DEBUG
+ Decrypted = Data;
+ #else
+ Aes256::decrypt(m_EncryptionKey, Data, Decrypted);
+ #endif
+
+ return Decrypted;
+ }
+}
\ No newline at end of file diff --git a/csgo-loader/csgo-server/Security/Encryption.hpp b/csgo-loader/csgo-server/Security/Encryption.hpp new file mode 100644 index 0000000..d55608f --- /dev/null +++ b/csgo-loader/csgo-server/Security/Encryption.hpp @@ -0,0 +1,89 @@ +#pragma once
+
+#include <cstdint>
+#include <vector>
+#include <windows.h>
+#include <wincrypt.h>
+
+using ByteArray = std::vector<uint8_t>;
+
+#define BLOCK_SIZE 16
+
+namespace Wrapper {
+ // AES256 implementation.
+ class Aes256 {
+
+ public:
+ Aes256(const ByteArray& key);
+ ~Aes256();
+
+ static ByteArray::size_type encrypt(const ByteArray& key, const ByteArray& plain, ByteArray& encrypted);
+ static ByteArray::size_type encrypt(const ByteArray& key, const unsigned char* plain, const ByteArray::size_type plain_length, ByteArray& encrypted);
+ static ByteArray::size_type decrypt(const ByteArray& key, const ByteArray& encrypted, ByteArray& plain);
+ static ByteArray::size_type decrypt(const ByteArray& key, const unsigned char* encrypted, const ByteArray::size_type encrypted_length, ByteArray& plain);
+
+ ByteArray::size_type encrypt_start(const ByteArray::size_type plain_length, ByteArray& encrypted);
+ ByteArray::size_type encrypt_continue(const ByteArray& plain, ByteArray& encrypted);
+ ByteArray::size_type encrypt_continue(const unsigned char* plain, const ByteArray::size_type plain_length, ByteArray& encrypted);
+ ByteArray::size_type encrypt_end(ByteArray& encrypted);
+
+ ByteArray::size_type decrypt_start(const ByteArray::size_type encrypted_length);
+ ByteArray::size_type decrypt_continue(const ByteArray& encrypted, ByteArray& plain);
+ ByteArray::size_type decrypt_continue(const unsigned char* encrypted, const ByteArray::size_type encrypted_length, ByteArray& plain);
+ ByteArray::size_type decrypt_end(ByteArray& plain);
+
+ private:
+ ByteArray m_key;
+ ByteArray m_salt;
+ ByteArray m_rkey;
+
+ unsigned char m_buffer[3 * BLOCK_SIZE];
+ unsigned char m_buffer_pos;
+ ByteArray::size_type m_remainingLength;
+
+ bool m_decryptInitialized;
+
+ void check_and_encrypt_buffer(ByteArray& encrypted);
+ void check_and_decrypt_buffer(ByteArray& plain);
+
+ void encrypt(unsigned char *buffer);
+ void decrypt(unsigned char *buffer);
+
+ void expand_enc_key(unsigned char *rc);
+ void expand_dec_key(unsigned char *rc);
+
+ void sub_bytes(unsigned char *buffer);
+ void sub_bytes_inv(unsigned char *buffer);
+
+ void copy_key();
+
+ void add_round_key(unsigned char *buffer, const unsigned char round);
+
+ void shift_rows(unsigned char *buffer);
+ void shift_rows_inv(unsigned char *buffer);
+
+ void mix_columns(unsigned char *buffer);
+ void mix_columns_inv(unsigned char *buffer);
+ };
+
+ // Encryption wrapper.
+ class Encryption {
+ ByteArray m_EncryptionKey;
+ HCRYPTPROV m_CryptProvider;
+
+ public:
+ // Generate a random cryptographic key.
+ // OPTIONAL: You can pass a premade encryption key as a parameter.
+ void Start();
+ void Start(ByteArray &EncryptionKey);
+
+ // Handles encryption/decryption of data.
+ ByteArray Encrypt(ByteArray &Data);
+ ByteArray Decrypt(ByteArray &Data);
+
+ // Exposes the encryption key.
+ ByteArray GetKey() {
+ return m_EncryptionKey;
+ }
+ };
+}
\ No newline at end of file diff --git a/csgo-loader/csgo-server/Server.cpp b/csgo-loader/csgo-server/Server.cpp new file mode 100644 index 0000000..ca6deb4 --- /dev/null +++ b/csgo-loader/csgo-server/Server.cpp @@ -0,0 +1,33 @@ +#include <Networking/TCPServer.hpp>
+#include <Login/RemoteLogin.hpp>
+
+void ConnectionHandler(Networking::TCPConnection &Connection) {
+ Login::RemoteLoginServer LoginServer;
+
+ ByteArray RawLoginHeader = Connection.ReceiveBytes();
+ LoginServer.Start(RawLoginHeader);
+
+ ByteArray RawServerResponse = LoginServer.GetResponse();
+ Connection.SendBytes(RawServerResponse);
+}
+
+int main() {
+ Networking::TCPServer Server;
+
+ // Create an instance of the TCP server.
+ if(!Server.Start(3884)) {
+ printf("[FAIL] Failed to initialise server. (%08lx)\n", WSAGetLastError());
+ system("pause");
+ return 1;
+ }
+
+ // Add a connection handler to the server.
+ Server += ConnectionHandler;
+
+ // Accept incoming connections.
+ while(true) {
+ Server.AcceptConnection();
+ }
+
+ return 0;
+}
\ No newline at end of file diff --git a/csgo-loader/csgo-server/csgo-server.vcxproj b/csgo-loader/csgo-server/csgo-server.vcxproj new file mode 100644 index 0000000..c0fcbca --- /dev/null +++ b/csgo-loader/csgo-server/csgo-server.vcxproj @@ -0,0 +1,152 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="Login\RemoteLogin.cpp" />
+ <ClCompile Include="Networking\TCPServer.cpp" />
+ <ClCompile Include="Networking\WebSocket.cpp" />
+ <ClCompile Include="RemoteCode\FileReader.cpp" />
+ <ClCompile Include="Security\Encryption.cpp" />
+ <ClCompile Include="Server.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="Login\RemoteLogin.hpp" />
+ <ClInclude Include="Networking\TCPServer.hpp" />
+ <ClInclude Include="Networking\WebSocket.hpp" />
+ <ClInclude Include="RemoteCode\FileReader.hpp" />
+ <ClInclude Include="Security\Encryption.hpp" />
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <VCProjectVersion>15.0</VCProjectVersion>
+ <ProjectGuid>{97FAC435-B009-4571-AE91-31DC52D47598}</ProjectGuid>
+ <RootNamespace>csgoserver</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
+ <IntDir>$(SolutionDir)build\$(Configuration)\Server\</IntDir>
+ <ExecutablePath>$(ExecutablePath)</ExecutablePath>
+ <IncludePath>$(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
+ <IntDir>$(SolutionDir)build\$(Configuration)\Server\</IntDir>
+ <ExecutablePath>$(ExecutablePath)</ExecutablePath>
+ <IncludePath>$(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level4</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ <PreprocessorDefinitions>_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32_LEAN_AND_MEAN;NOMINMAX;DEBUG;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ <Link>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level4</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ <PreprocessorDefinitions>_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32_LEAN_AND_MEAN;NOMINMAX;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
+ </Link>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/csgo-loader/csgo-server/csgo-server.vcxproj.filters b/csgo-loader/csgo-server/csgo-server.vcxproj.filters new file mode 100644 index 0000000..bc0886a --- /dev/null +++ b/csgo-loader/csgo-server/csgo-server.vcxproj.filters @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Networking">
+ <UniqueIdentifier>{6fc0b232-87f4-4bf9-97d9-d5ee1ffb9b0b}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Security">
+ <UniqueIdentifier>{46b100eb-f5b1-44c7-9641-582e95387060}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Login">
+ <UniqueIdentifier>{b75e08e0-f7fb-4fc5-971f-31573fd5f41a}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="RemoteCode">
+ <UniqueIdentifier>{bdd26646-f9bb-42f8-8ba3-f9ab232e1d9d}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="Server.cpp" />
+ <ClCompile Include="Security\Encryption.cpp">
+ <Filter>Security</Filter>
+ </ClCompile>
+ <ClCompile Include="Networking\TCPServer.cpp">
+ <Filter>Networking</Filter>
+ </ClCompile>
+ <ClCompile Include="Login\RemoteLogin.cpp">
+ <Filter>Login</Filter>
+ </ClCompile>
+ <ClCompile Include="Networking\WebSocket.cpp">
+ <Filter>Networking</Filter>
+ </ClCompile>
+ <ClCompile Include="RemoteCode\FileReader.cpp">
+ <Filter>RemoteCode</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="Security\Encryption.hpp">
+ <Filter>Security</Filter>
+ </ClInclude>
+ <ClInclude Include="Networking\TCPServer.hpp">
+ <Filter>Networking</Filter>
+ </ClInclude>
+ <ClInclude Include="Login\RemoteLogin.hpp">
+ <Filter>Login</Filter>
+ </ClInclude>
+ <ClInclude Include="Networking\WebSocket.hpp">
+ <Filter>Networking</Filter>
+ </ClInclude>
+ <ClInclude Include="RemoteCode\FileReader.hpp">
+ <Filter>RemoteCode</Filter>
+ </ClInclude>
+ </ItemGroup>
+</Project>
\ No newline at end of file |
