summaryrefslogtreecommitdiff
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
parent0713c4ebe1e29d1076adb22ba5d8d5e562cecafc (diff)
gay test loader stuff
mhmm!~ thats a good girl!~ :3
-rw-r--r--client/client.vcxproj2
-rw-r--r--client/client_windows.cpp62
-rw-r--r--client/connect.hpp106
-rw-r--r--server/client.cpp62
-rw-r--r--server/client.hpp2
-rw-r--r--server/server.cpp15
6 files changed, 161 insertions, 88 deletions
diff --git a/client/client.vcxproj b/client/client.vcxproj
index 5fd04ba..12d3dc8 100644
--- a/client/client.vcxproj
+++ b/client/client.vcxproj
@@ -66,7 +66,7 @@
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
+ <CharacterSet>MultiByte</CharacterSet>
<SpectreMitigation>false</SpectreMitigation>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='pHit|x64'" Label="Configuration">
diff --git a/client/client_windows.cpp b/client/client_windows.cpp
index 02bf78e..7fdd467 100644
--- a/client/client_windows.cpp
+++ b/client/client_windows.cpp
@@ -47,68 +47,10 @@ int main( ) {
if( !c.connect( ) )
return 2;
-
- auto msg = c.get_string( );
- if ( msg != xors( "hello" ) ) {
- std::cout << "connection failed." << std::endl;
- //return 0;
- }
-
- c.send_msg( "hello" );
-
- std::string username{ }, password{ };
- std::cout << "Enter your username" << std::endl << "> ";
- std::cin >> username;
-
- c.send_msg( username.c_str( ) );
- msg = c.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;
-
- c.send_msg( password.c_str( ) );
- if ( c.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 = c.get_string( );
- std::cout << msg << std::endl;
-
-
-
- /*
- const char* yes = "hello server";
- char buf[ 255 ];
- memcpy( buf, yes, strlen( yes ) );
-
- c.send_msg( ( uint8_t* )( buf ), strlen( yes ) );
- printf( "message sent\n" );
-
- auto msg = c.get_msg( );
- while( !msg.size( ) ) {
- Sleep( 1 );
- }
-
- printf( "[message received]: " );
- for( auto& it : msg )
- printf( "%c", it );
-
- printf( "\n" );
-
- c.send_msg( ( uint8_t* )( buf ), strlen( yes ) );
- */
-
- // c.~c_connect( );
-
+ c.handle( );
system( "pause" );
+
return 0;
}
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;
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;
}
diff --git a/server/client.hpp b/server/client.hpp
index fad499f..c59e116 100644
--- a/server/client.hpp
+++ b/server/client.hpp
@@ -39,7 +39,7 @@ namespace server
{ }
~c_client( ) {
- closesocket( m_socket );
+ kill( );
}
diff --git a/server/server.cpp b/server/server.cpp
index 05d011d..010ec84 100644
--- a/server/server.cpp
+++ b/server/server.cpp
@@ -43,19 +43,6 @@ void server::c_server::listen( ) {
client->send_msg( "hello" );
// surprised it even works with shared_ptr.
- std::thread thread( &c_client::handle, client );
+ std::thread thread{ &c_client::handle, client };
thread.detach( );
}
-
-void server::c_server::client_loop( ) {
- //if( m_clients.size( ) ) {
- // std::lock_guard lock( m_mutex );
- // for( auto it = m_clients.begin( ); it != m_clients.end( ); ++it ) {
- // if( !( *it )->handle( ) ) {
- // ( *it )->kill( );
- // m_clients.erase( it );
- // break;
- // }
- // }
- //}
-} \ No newline at end of file