diff options
Diffstat (limited to 'server/client.cpp')
| -rw-r--r-- | server/client.cpp | 62 |
1 files changed, 50 insertions, 12 deletions
diff --git a/server/client.cpp b/server/client.cpp index 2a0bfb7..22aa053 100644 --- a/server/client.cpp +++ b/server/client.cpp @@ -90,7 +90,6 @@ bool server::c_client::send_msg( byte* msg, size_t length ) { bool server::c_client::send_msg( const char* msg ) { auto length = strlen( msg ); - printf( "%d\n", length ); auto buffer = std::make_unique< uint8_t[ ] >( length + 1 ); auto key = util::random_number( 0, 255 ) & 0xff; @@ -127,27 +126,21 @@ bool server::c_client::handle( ) { auto hello_msg = get_msg( ); printf( "%s\n", hello_msg.c_str( ) ); - if ( hello_msg != "hello" ) { - kill( ); + if ( hello_msg != "hello" ) return false; - } auto username = get_msg( ); - if ( username != "friendly" ) { - kill( ); + if ( username != "friendly" ) return false; - } - printf( "correct username" ); + printf( "correct username\n" ); send_msg( "correct username" ); auto password = get_msg( ); - if ( password != "nigger" ) { - kill( ); + if ( password != "nigger" ) return false; - } - printf( "correct password" ); + printf( "correct password\n" ); send_msg( "correct password" ); const char* games_list = @@ -159,5 +152,50 @@ R"(games: send_msg( games_list ); + auto game_id = get_msg( ); + + if ( game_id== "1" ) { + printf( "csgo\n" ); + send_msg( "csgo.exe" ); + } + else if ( game_id == "2" ) { + printf( "csgo test\n" ); + send_msg( "csgo.exe" ); + } + else if ( game_id == "3" ) { + printf( "gmod\n" ); + send_msg( "hl2.exe" ); + } + else { + printf( "invalid\n" ); + return false; + } + + auto found = get_msg( ); + if ( found != "found" ) + return false; + + printf( "process found\n" ); + + if ( game_id == "3" ) { + // test. make sure the file is in ur directory + auto file = std::ifstream( "gmod.dll", std::ifstream::binary ); + if ( file.is_open( ) ) { + file.seekg( 0, file.end ); + + auto size = ( int )file.tellg( );
+ auto buffer = std::make_unique< char[ ] >( size );
+
+ memset( buffer.get( ), 0, size );
+
+ file.seekg( 0, file.beg );
+ file.read( buffer.get( ), size );
+ + send_msg( ( byte* )buffer.get( ), size ); + + file.close( ); + } + } + return true; } |
