summaryrefslogtreecommitdiff
path: root/client/connect.hpp
diff options
context:
space:
mode:
authorUnknown <azeem@live.ru>2018-11-27 22:58:18 +0000
committerUnknown <azeem@live.ru>2018-11-27 22:58:18 +0000
commitd12a1be5af24c6721496dbd5645f361bdb080074 (patch)
tree032e3709871eec16a66e3528a303bf0cc9eb26ce /client/connect.hpp
parent0713c4ebe1e29d1076adb22ba5d8d5e562cecafc (diff)
gay test loader stuff
mhmm!~ thats a good girl!~ :3
Diffstat (limited to 'client/connect.hpp')
-rw-r--r--client/connect.hpp106
1 files changed, 106 insertions, 0 deletions
diff --git a/client/connect.hpp b/client/connect.hpp
index 5720d4f..96bb9c8 100644
--- a/client/connect.hpp
+++ b/client/connect.hpp
@@ -4,11 +4,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <fstream>
#pragma comment( lib, "ws2_32.lib" )
#include <vector>
+/* TEST */
+#include <Psapi.h>
+#include <TlHelp32.h>
+/* TEST */
+
#include "err.hpp"
#include "util.hpp"
@@ -168,6 +174,106 @@ namespace client
}
}
+
+ void send_msg( const char msg ) {
+ auto buffer = std::make_unique< uint8_t[ ] >( 2 );
+ auto key = util::random_number( 0, 255 ) & 0xff;
+
+ buffer[ 0 ] = key;
+ buffer[ 1 ] = msg;
+ buffer[ 1 ] ^= buffer[ 0 ];
+
+ int ret = send( m_socket, ( char* )buffer.get( ), 2, 0 );
+ if ( ret == SOCKET_ERROR ) {
+ printf( xors( "error sending message error code: %d" ), WSAGetLastError( ) );
+ }
+ }
+
+ void handle( ) {
+
+ auto msg = get_string( );
+ if ( msg != xors( "hello" ) ) {
+ std::cout << "connection failed." << std::endl;
+ //return 0;
+ }
+
+ send_msg( "hello" );
+
+ std::string username{ }, password{ };
+ std::cout << "Enter your username" << std::endl << "> ";
+ std::cin >> username;
+
+ send_msg( username.c_str( ) );
+ msg = get_string( );
+ std::cout <<msg <<std::endl;
+ if ( msg != xors( "correct username" ) ) {
+ std::cout << "incorrect username" << std::endl;
+ //return 0; // remember to close connection on server when bad values were sent.
+ }
+
+ std::cout << "Enter your password" << std::endl << "> ";
+ std::cin >> password;
+
+ send_msg( password.c_str( ) );
+ if ( get_string( ) != xors( "correct password" ) ) {
+ std::cout << "incorrect password";
+ //return 0; // remember to close connection on server when bad values were sent.
+ }
+
+ // Receive list of games,
+ msg = get_string( );
+ std::cout << msg << std::endl;
+
+
+ std::cout << "For what game do you want to inject on?" << std::endl << "> ";
+
+ char game_id{ };
+ std::cin >> game_id;
+
+ send_msg( game_id );
+
+ // get process name.
+ msg = get_string( );
+
+ std::cout << msg << std::endl;
+
+ int process_identifier{ };
+
+ HANDLE snapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
+ if ( snapshot != INVALID_HANDLE_VALUE ) {
+ PROCESSENTRY32 entry{ sizeof( PROCESSENTRY32 ) };
+
+ if ( Process32First( snapshot, &entry ) ) {
+ do {
+ if ( msg == entry.szExeFile ) {
+ process_identifier = entry.th32ProcessID;
+ break;
+ }
+ } while ( Process32Next( snapshot, &entry ) );
+ }
+ }
+
+ if ( !process_identifier ) {
+ std::cout << "Could not find process." << std::endl;
+ return;
+ }
+
+ std::cout << "found" << std::endl;
+ send_msg( "found" );
+
+ auto file = get_msg( );
+ auto file_data = file.data( );
+ auto file_size = file.size( );
+
+ auto save_file = std::ofstream( "gmod.txt", std::ofstream::binary );
+ if ( save_file.is_open( ) ) {
+ save_file.write( ( const char* )file_data, file_size );
+ save_file.close( );
+ }
+
+
+ }
+
private:
SOCKET m_socket;
WSADATA m_wsdata;