From 4db29589a61f2e7cb663c5734f911c02206c7997 Mon Sep 17 00:00:00 2001 From: boris Date: Wed, 9 Jan 2019 20:51:16 +1300 Subject: whole buncha shit FIXME: loader currently corrupts heap on injection because i am retarded --- csgo-loader/csgo-server/Server.cpp | 99 ++++++++++++++++++++++++++++++++++---- 1 file changed, 90 insertions(+), 9 deletions(-) (limited to 'csgo-loader/csgo-server/Server.cpp') diff --git a/csgo-loader/csgo-server/Server.cpp b/csgo-loader/csgo-server/Server.cpp index f822753..e0f1455 100644 --- a/csgo-loader/csgo-server/Server.cpp +++ b/csgo-loader/csgo-server/Server.cpp @@ -1,15 +1,96 @@ #include -void ConnectionHandler(Networking::TCPConnection &Connection) { - Login::RemoteLoginServer LoginServer; +// 'M1' -> cl request +// 'M2' -> mod request +// 'M3' -> ban request - ByteArray LoginHeader = Connection.ReceiveBytes(); - - if(!LoginServer.Start(LoginHeader)) - return; +namespace Handler +{ + void OnClientConnection(Networking::TCPConnection &Connection) + { + printf("[ !! ] Client at %s requested connection!\n", Connection.GetIpAddress()); + + // Initialize login server for the client. + Login::RemoteLoginServer LoginServer; + + ByteArray LoginHeader = Connection.ReceiveBytes(); + + // Invalid login header. + if(!LoginServer.Start(LoginHeader)) + return; + + printf("[ !! ] Received login header from %s!\n", Connection.GetIpAddress()); + + // Reply with server header. + ByteArray LoginReply = LoginServer.GetResponse(); + Connection.SendBytes(LoginReply); - ByteArray LoginReply = LoginServer.GetResponse(); - Connection.SendBytes(LoginReply); + ByteArray LoginReplyEcho = Connection.ReceiveBytes(); + + if(LoginReply.size() != LoginReplyEcho.size()) + { + printf("[ !! ] Echo from %s invalid, dropping connection!", Connection.GetIpAddress()); + return; + } + + RemoteCode::FileReader File; + + if(!File.Start("csgo-module.dll")) + return; + + // Send them the loader module to inject the cheat. + printf("[ !! ] Sending latest loader module!\n"); + + ByteArray RawLdrModule; + RawLdrModule.insert( + RawLdrModule.begin(), + (uint8_t *)File, + (uint8_t *)(File + File.GetFileLength()) + ); + + Connection.SendBytes(RawLdrModule); + } + + void OnModuleConnection(Networking::TCPConnection &Connection) + { + // The output of this function will be verbose by default. + printf("[ !! ] Module hello from %s!\n", Connection.GetIpAddress()); + } + + void OnBanReqConnection(Networking::TCPConnection &Connection) + { + // Use for forum IP-ban purposes or whatever.. + printf("[ !! ] Client at %s requested ban!\n", Connection.GetIpAddress()); + + // TODO: Ban user? + } + + void OnReceiveConnection(Networking::TCPConnection &Connection) + { + ByteArray Header = Connection.ReceiveRawBytes(); + + if(Header.empty()) + { + printf("[ !! ] Client at %s sent malformed request!\n", Connection.GetIpAddress()); + return; + } + + uint32_t HeaderCode = *(uint32_t *)&Header[0]; + + switch(HeaderCode) + { + case CLIENT_HEADER: // "MB1" + OnClientConnection(Connection); break; + case MODULE_HEADER: // "MB2" + OnModuleConnection(Connection); break; + case BANREQ_HEADER: // "MB3"; + OnBanReqConnection(Connection); break; + + // Drop any malformed clients. + default: + printf("[ !! ] Client at %s sent malformed request!\n", Connection.GetIpAddress()); + } + } } int __stdcall WinMain(HINSTANCE, HINSTANCE, char*, int) @@ -25,7 +106,7 @@ int __stdcall WinMain(HINSTANCE, HINSTANCE, char*, int) if(Result) { // Attach our connection handler. - Server += ConnectionHandler; + Server += Handler::OnReceiveConnection; // Accept any incoming connections. for(;;) -- cgit v1.2.3