From ce327351a910dbc7f899aabac2e08cad0a2102e9 Mon Sep 17 00:00:00 2001 From: navewindre Date: Sun, 2 Sep 2018 16:03:51 +0200 Subject: ahh --- internal_rewrite/Source.cpp | 4 + internal_rewrite/interface.cpp | 8 + internal_rewrite/internal_rewrite.vcxproj | 1 + internal_rewrite/internal_rewrite.vcxproj.filters | 3 + internal_rewrite/settings.hpp | 20 +- internal_rewrite/simple_settings.hpp | 462 +++++++++++----------- internal_rewrite/wipe.hpp | 70 ++++ 7 files changed, 328 insertions(+), 240 deletions(-) create mode 100644 internal_rewrite/wipe.hpp diff --git a/internal_rewrite/Source.cpp b/internal_rewrite/Source.cpp index 2894211..0b63051 100644 --- a/internal_rewrite/Source.cpp +++ b/internal_rewrite/Source.cpp @@ -7,6 +7,7 @@ #include "console.hpp" #include "input_system.hpp" #include "mem.hpp" +#include "wipe.hpp" HMODULE g_dll; header_t g_header; @@ -56,6 +57,9 @@ int __stdcall DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) { //SetUnhandledExceptionFilter( exception_handler ); DisableThreadLibraryCalls( inst ); +#ifdef HEADER_MODULE + antidebug::fuck_skids( ); +#endif thread = CreateThread( nullptr, 0, ( LPTHREAD_START_ROUTINE )( main_thread ), diff --git a/internal_rewrite/interface.cpp b/internal_rewrite/interface.cpp index e90cf25..fb01dd9 100644 --- a/internal_rewrite/interface.cpp +++ b/internal_rewrite/interface.cpp @@ -10,6 +10,7 @@ #include "settings.hpp" #include "context.hpp" #include "modules.hpp" +#include "wipe.hpp" using namespace factory; @@ -17,6 +18,8 @@ interfaces::c_interface_manager g_factory; factory::c_csgo g_csgo; bool factory::create_interfaces( c_csgo* instance, header_t* header ) { + DELETE_START( 0 ); + #ifndef HEADER_MODULE header->client_panorama = ( uintptr_t )GetModuleHandleA( "client_panorama.dll" ); @@ -124,6 +127,7 @@ bool factory::create_interfaces( c_csgo* instance, header_t* header ) { instance->listeners.weapon_fire.init( ); instance->listeners.player_death.init( ); + DELETE_END( 0 ); return true; } @@ -198,6 +202,8 @@ con_fn unload_fn{ fnv( "unload" ), };*/ void factory::c_csgo::initialize( ) { + DELETE_START( 0 ) + m_panic = false; g_con->create( ); @@ -236,6 +242,8 @@ void factory::c_csgo::initialize( ) { // open the menu so people actually know when the cheat loaded g_settings.menu.open = true; + + DELETE_END( 0 ); } void factory::c_csgo::uninitialize( ) { diff --git a/internal_rewrite/internal_rewrite.vcxproj b/internal_rewrite/internal_rewrite.vcxproj index 5834dca..995987b 100644 --- a/internal_rewrite/internal_rewrite.vcxproj +++ b/internal_rewrite/internal_rewrite.vcxproj @@ -561,6 +561,7 @@ + diff --git a/internal_rewrite/internal_rewrite.vcxproj.filters b/internal_rewrite/internal_rewrite.vcxproj.filters index d8e21ec..be58e72 100644 --- a/internal_rewrite/internal_rewrite.vcxproj.filters +++ b/internal_rewrite/internal_rewrite.vcxproj.filters @@ -573,5 +573,8 @@ factory + + utility + \ No newline at end of file diff --git a/internal_rewrite/settings.hpp b/internal_rewrite/settings.hpp index cb3307f..5f38c8b 100644 --- a/internal_rewrite/settings.hpp +++ b/internal_rewrite/settings.hpp @@ -69,19 +69,19 @@ namespace data __declspec( noinline ) void load( ) { switch( menu.cur_setting ) { case 0: - holder_.load( "", xors( "./csgo/cfg/money_legit.cfg" ) ); + holder_.load( "", xors( "money_legit.cfg" ) ); break; case 1: - holder_.load( "", xors( "./csgo/cfg/money_closet.cfg" ) ); + holder_.load( "", xors( "money_closet.cfg" ) ); break; case 2: - holder_.load( "", xors( "./csgo/cfg/money_rage1.cfg" ) ); + holder_.load( "", xors( "money_rage1.cfg" ) ); break; case 3: - holder_.load( "", xors( "./csgo/cfg/money_rage2.cfg" ) ); + holder_.load( "", xors( "money_rage2.cfg" ) ); break; case 4: - holder_.load( "", xors( "./csgo/cfg/money_test.cfg" ) ); + holder_.load( "", xors( "money_test.cfg" ) ); break; } @@ -92,19 +92,19 @@ namespace data __declspec( noinline ) void save( ) { switch( menu.cur_setting ) { case 0: - holder_.save( "", xors( "./csgo/cfg/money_legit.cfg" ) ); + holder_.save( "", xors( "money_legit.cfg" ) ); break; case 1: - holder_.save( "", xors( "./csgo/cfg/money_closet.cfg" ) ); + holder_.save( "", xors( "money_closet.cfg" ) ); break; case 2: - holder_.save( "", xors( "./csgo/cfg/money_rage1.cfg" ) ); + holder_.save( "", xors( "money_rage1.cfg" ) ); break; case 3: - holder_.save( "", xors( "./csgo/cfg/money_rage2.cfg" ) ); + holder_.save( "", xors( "money_rage2.cfg" ) ); break; case 4: - holder_.save( "", xors( "./csgo/cfg/money_test.cfg" ) ); + holder_.save( "", xors( "money_test.cfg" ) ); break; } } diff --git a/internal_rewrite/simple_settings.hpp b/internal_rewrite/simple_settings.hpp index 74b4d43..5d5636e 100644 --- a/internal_rewrite/simple_settings.hpp +++ b/internal_rewrite/simple_settings.hpp @@ -1,54 +1,54 @@ -#pragma once -#include -#include -#include -#include -#include - -#include "util.hpp" -#include "fnv.hpp" - -#pragma comment( lib, "Shlwapi.lib" ) - -//nama stuff -extern void simple_save( const char* path, const char* name, const void* src, size_t size, const char* filename ); -extern void simple_load( const char* path, const char* name, void* dest, size_t size, const char* filename ); - -class ISettingNode { -public: - virtual ~ISettingNode( ) = default; - - virtual void load( const char* path, const char* file ) = 0; - virtual void save( const char* path, const char* file ) const = 0; - virtual void register_( ISettingNode* node_ptr ) = 0; - virtual bool has_nodes( ) { return false; } - virtual hash_t get_hash( ) { return 0; } -}; - -class SettingHolder : public ISettingNode { -public: - __forceinline SettingHolder( const char* name ) : name_( name ) {} - __forceinline SettingHolder( SettingHolder* holder_ptr, const char* name ) : name_( name ) { holder_ptr->register_( this ); } - - void register_( ISettingNode* node_ptr ) override { - setting_nodes_.push_back( node_ptr ); - } - - __declspec( noinline ) void load( const char* path, const char* file ) override - { +#pragma once +#include +#include +#include +#include +#include + +#include "util.hpp" +#include "fnv.hpp" + +#pragma comment( lib, "Shlwapi.lib" ) + +//nama stuff +extern void simple_save( const char* path, const char* name, const void* src, size_t size, const char* filename ); +extern void simple_load( const char* path, const char* name, void* dest, size_t size, const char* filename ); + +class ISettingNode { +public: + virtual ~ISettingNode( ) = default; + + virtual void load( const char* path, const char* file ) = 0; + virtual void save( const char* path, const char* file ) const = 0; + virtual void register_( ISettingNode* node_ptr ) = 0; + virtual bool has_nodes( ) { return false; } + virtual hash_t get_hash( ) { return 0; } +}; + +class SettingHolder : public ISettingNode { +public: + __forceinline SettingHolder( const char* name ) : name_( name ) {} + __forceinline SettingHolder( SettingHolder* holder_ptr, const char* name ) : name_( name ) { holder_ptr->register_( this ); } + + void register_( ISettingNode* node_ptr ) override { + setting_nodes_.push_back( node_ptr ); + } + + __declspec( noinline ) void load( const char* path, const char* file ) override + { static char full_path[1024]; - memset( full_path, 0, 1024 ); + memset( full_path, 0, 1024 ); strcpy_s( full_path, path ); strcat_s( full_path, "_" ); - strcat_s( full_path, name_.c_str( ) ); + strcat_s( full_path, name_.c_str( ) ); for ( auto x : setting_nodes_ ) - x->load( full_path, file ); - } - - __declspec( noinline ) void save( const char* path, const char* file ) const override - { + x->load( full_path, file ); + } + + __declspec( noinline ) void save( const char* path, const char* file ) const override + { static char full_path[1024]; memset( full_path, 0, 1024 ); @@ -56,189 +56,191 @@ public: strcat_s( full_path, "_" ); strcat_s( full_path, name_.c_str( ) ); for ( auto x : setting_nodes_ ) - x->save( full_path, file ); - } - - auto& get_nodes( ) { - return setting_nodes_; - } - - virtual bool has_nodes( ) { - return true; - } - -private: - std::string name_; - bool has_nodes_; - std::vector setting_nodes_; -}; - -class ISetting : public ISettingNode { - void register_( ISettingNode* node_ptr ) override {} -public: - virtual void set( float value ) = 0; - virtual void set( int value ) = 0; - virtual void set( ulong_t value ) = 0; - virtual std::string get_string( ) = 0; - virtual hash_t get_hash( ) = 0; - virtual std::string get_data_string( ) = 0; - virtual void load_from_string( const std::string& ) = 0; -}; - -template < size_t L > -class SettingString : ISetting { -public: - __forceinline SettingString( SettingHolder* holder_ptr, hash_t hash ) : - m_name( name ), m_value( "" ) { - holder_ptr->register_( this ); - }; - - __declspec( noinline ) void load( const char* path, const char* file ) override { - static char str[ MAX_PATH ]; - - GetModuleFileNameA( nullptr, str, MAX_PATH - 1 ); - PathRemoveFileSpecA( str ); - strcat_s< MAX_PATH >( str, path ); - strcat_s< MAX_PATH >( str, "\\" ); - - GetPrivateProfileStringA( path, std::to_string( m_name ).c_str( ), "", m_value, L, file ); - } - - __declspec( noinline ) void save( const char* path, const char* file ) const override { - static char str[ MAX_PATH ]; - - GetModuleFileNameA( nullptr, str, MAX_PATH - 1 ); - PathRemoveFileSpecA( str ); - strcat_s< MAX_PATH >( str, path ); - strcat_s< MAX_PATH >( str, "\\" ); - - WritePrivateProfileStringA( path, std::to_string( m_name ).c_str( ), m_value, file ); - } - - char* get( ) { - return m_value; - } - -private: - char m_value[ L ]; - hash_t m_name; -}; - -template < typename T > -class con_var : public ISetting { -public: - __declspec( noinline ) con_var( SettingHolder* holder_ptr, hash_t name ) : - name_( name ), - is_float_( std::is_floating_point_v< T > ), - is_integral_( std::is_integral_v< T > ) { - holder_ptr->register_( this ); - } - __declspec( noinline ) con_var( SettingHolder* holder_ptr, hash_t name , const T& rhs ) : - value_( rhs ), - name_( name ), - is_float_( std::is_floating_point_v< T > ), - is_integral_( std::is_integral_v< T > ) { - holder_ptr->register_( this ); - } - - __declspec( noinline ) void load( const char* path, const char* file ) override { - static char str[ MAX_PATH ]; - - GetModuleFileNameA( nullptr, str, MAX_PATH - 1 ); - PathRemoveFileSpecA( str ); - strcat_s< MAX_PATH >( str, "\\" ); - - simple_load( str, std::to_string( name_ ).c_str( ), &value_, sizeof( value_ ), file ); - } - - __declspec( noinline ) void save( const char* path, const char* file ) const override { - static char str[ MAX_PATH ]; - - GetModuleFileNameA( nullptr, str, MAX_PATH - 1 ); - PathRemoveFileSpecA( str ); - strcat_s< MAX_PATH >( str, "\\" ); - - simple_save( str, std::to_string( name_ ).c_str( ), &value_, sizeof( value_ ), file ); - } - - __forceinline operator T&( ) { return value_; } - __forceinline T* operator &( ) { return &value_; } - - __forceinline T& operator ()( ) { return value_; } - - virtual std::string get_string( ) { - if constexpr( std::is_arithmetic_v< T > ) { - return std::to_string( value_ ); - } - else { - return util::to_hex_str( *( ulong_t* )( &value_ ) ); - } - } - - virtual void set( float value ) { - if constexpr( std::is_arithmetic_v< T > ) { - value_ = ( T )( value ); - } - } - - virtual void set( int value ) { - if constexpr( std::is_arithmetic_v< T > ) { - value_ = ( T )( value ); - } - else { - value_ = *( T* )( &value ); - } - } - - virtual void set( ulong_t value ) { - if constexpr( sizeof( T ) == sizeof( ulong_t ) ) { - *( ulong_t* )( &value_ ) = value; - return; - } - - memcpy( &value_, &value, sizeof( value_ ) ); - } - - virtual hash_t get_hash( ) { - return name_; - } - - __forceinline bool is_floating_point( ) { - return is_float_; - } - - __forceinline bool is_integral( ) { - return is_integral_; - } - - virtual std::string get_data_string( ) override { - auto buffer = reinterpret_cast< char* >( _alloca( sizeof( T ) * 2 + 1 ) ); - auto data = reinterpret_cast< const uint8_t* >( &value_ ); - - for( size_t i = 0; i < sizeof( T ); i++ ) - sprintf( &buffer[ 2 * i ], "%02X", data[ i ] ); - - return buffer; - } - - virtual void load_from_string( const std::string& str ) override { - auto data = reinterpret_cast< uint8_t* >( &value_ ); - auto buffer = str.data( ); - - if( *buffer == 0 ) - return; - - for( size_t i = 0; i < sizeof( T ); i++ ) { - unsigned temp; - sscanf( &buffer[ 2 * i ], "%02X", &temp ); - data[ i ] = temp; - } - } - - -private: - hash_t name_; - bool is_float_; - bool is_integral_; - T value_; + x->save( full_path, file ); + } + + auto& get_nodes( ) { + return setting_nodes_; + } + + virtual bool has_nodes( ) { + return true; + } + +private: + std::string name_; + bool has_nodes_; + std::vector setting_nodes_; +}; + +class ISetting : public ISettingNode { + void register_( ISettingNode* node_ptr ) override {} +public: + virtual void set( float value ) = 0; + virtual void set( int value ) = 0; + virtual void set( ulong_t value ) = 0; + virtual std::string get_string( ) = 0; + virtual hash_t get_hash( ) = 0; + virtual std::string get_data_string( ) = 0; + virtual void load_from_string( const std::string& ) = 0; +}; + +template < size_t L > +class SettingString : ISetting { +public: + __forceinline SettingString( SettingHolder* holder_ptr, hash_t hash ) : + m_name( name ), m_value( "" ) { + holder_ptr->register_( this ); + }; + + __declspec( noinline ) void load( const char* path, const char* file ) override { + static char str[ MAX_PATH ]; + + GetModuleFileNameA( nullptr, str, MAX_PATH - 1 ); + PathRemoveFileSpecA( str ); + strcat_s< MAX_PATH >( str, path ); + strcat_s< MAX_PATH >( str, "\\" ); + + GetPrivateProfileStringA( path, std::to_string( m_name ).c_str( ), "", m_value, L, file ); + } + + __declspec( noinline ) void save( const char* path, const char* file ) const override { + static char str[ MAX_PATH ]; + + GetModuleFileNameA( nullptr, str, MAX_PATH - 1 ); + PathRemoveFileSpecA( str ); + strcat_s< MAX_PATH >( str, path ); + strcat_s< MAX_PATH >( str, "\\" ); + + WritePrivateProfileStringA( path, std::to_string( m_name ).c_str( ), m_value, file ); + } + + char* get( ) { + return m_value; + } + +private: + char m_value[ L ]; + hash_t m_name; +}; + +template < typename T > +class con_var : public ISetting { +public: + __declspec( noinline ) con_var( SettingHolder* holder_ptr, hash_t name ) : + name_( name ), + is_float_( std::is_floating_point_v< T > ), + is_integral_( std::is_integral_v< T > ) { + holder_ptr->register_( this ); + } + __declspec( noinline ) con_var( SettingHolder* holder_ptr, hash_t name , const T& rhs ) : + value_( rhs ), + name_( name ), + is_float_( std::is_floating_point_v< T > ), + is_integral_( std::is_integral_v< T > ) { + holder_ptr->register_( this ); + } + + __declspec( noinline ) void load( const char* path, const char* file ) override { + static char str[ MAX_PATH ]; + + GetModuleFileNameA( nullptr, str, MAX_PATH - 1 ); + PathRemoveFileSpecA( str ); + strcat_s< MAX_PATH >( str, "\\csgo\\cfg\\" ); + strcat_s< MAX_PATH >( str, file ); + + simple_load( path, std::to_string( name_ ).c_str( ), &value_, sizeof( value_ ), str ); + } + + __declspec( noinline ) void save( const char* path, const char* file ) const override { + static char str[ MAX_PATH ]; + + GetModuleFileNameA( nullptr, str, MAX_PATH - 1 ); + PathRemoveFileSpecA( str ); + strcat_s< MAX_PATH >( str, "\\csgo\\cfg\\" ); + strcat_s< MAX_PATH >( str, file ); + + simple_save( path, std::to_string( name_ ).c_str( ), &value_, sizeof( value_ ), str ); + } + + __forceinline operator T&( ) { return value_; } + __forceinline T* operator &( ) { return &value_; } + + __forceinline T& operator ()( ) { return value_; } + + virtual std::string get_string( ) { + if constexpr( std::is_arithmetic_v< T > ) { + return std::to_string( value_ ); + } + else { + return util::to_hex_str( *( ulong_t* )( &value_ ) ); + } + } + + virtual void set( float value ) { + if constexpr( std::is_arithmetic_v< T > ) { + value_ = ( T )( value ); + } + } + + virtual void set( int value ) { + if constexpr( std::is_arithmetic_v< T > ) { + value_ = ( T )( value ); + } + else { + value_ = *( T* )( &value ); + } + } + + virtual void set( ulong_t value ) { + if constexpr( sizeof( T ) == sizeof( ulong_t ) ) { + *( ulong_t* )( &value_ ) = value; + return; + } + + memcpy( &value_, &value, sizeof( value_ ) ); + } + + virtual hash_t get_hash( ) { + return name_; + } + + __forceinline bool is_floating_point( ) { + return is_float_; + } + + __forceinline bool is_integral( ) { + return is_integral_; + } + + virtual std::string get_data_string( ) override { + auto buffer = reinterpret_cast< char* >( _alloca( sizeof( T ) * 2 + 1 ) ); + auto data = reinterpret_cast< const uint8_t* >( &value_ ); + + for( size_t i = 0; i < sizeof( T ); i++ ) + sprintf( &buffer[ 2 * i ], "%02X", data[ i ] ); + + return buffer; + } + + virtual void load_from_string( const std::string& str ) override { + auto data = reinterpret_cast< uint8_t* >( &value_ ); + auto buffer = str.data( ); + + if( *buffer == 0 ) + return; + + for( size_t i = 0; i < sizeof( T ); i++ ) { + unsigned temp; + sscanf( &buffer[ 2 * i ], "%02X", &temp ); + data[ i ] = temp; + } + } + + +private: + hash_t name_; + bool is_float_; + bool is_integral_; + T value_; }; \ No newline at end of file diff --git a/internal_rewrite/wipe.hpp b/internal_rewrite/wipe.hpp new file mode 100644 index 0000000..dfb72a8 --- /dev/null +++ b/internal_rewrite/wipe.hpp @@ -0,0 +1,70 @@ +#pragma once + +#include "util.hpp" +#include + +#ifdef HEADER_MODULE + #define EXPAND( x,y )x##y + + #define BEGIN___( MARKER_BEGIN )MARKER_BEGIN: + + #define DEL_END___( MARKER_BEGIN, MARKER_END )__asm { __asm PUSH MARKER_END __asm PUSH MARKER_BEGIN __asm CALL antidebug::erase } \ + MARKER_END: + + #define BEGIN__( x, y ) BEGIN___( EXPAND2( MARKER_BEGIN_, x, y ) ) + #define END__( x, y ) DEL_END___( EXPAND2( MARKER_BEGIN_, x, y ), EXPAND2( MARKER_END_, x, y ) ) + + #define DELETE_START( x ) BEGIN___( EXPAND( MARKER_BEGIN_, x ) ) + #define DELETE_END( x ) DEL_END___( EXPAND( MARKER_BEGIN_, x ), EXPAND( MARKER_END_, x ) ) +#else + #define DELETE_START( x ) + #define DELETE_END( x ) +#endif + +namespace antidebug +{ + static void __stdcall erase( uintptr_t start, uintptr_t end ) { + uintptr_t size = end - start; + + DWORD protection_flag{ }; + VirtualProtect( ( void* )start, size, PAGE_EXECUTE_READWRITE, &protection_flag ); + + for( unsigned int i = 0; i < size; i++ ) { + int random = rand( ) % 0x90; + memset( ( void* )( start + i ), random, 1 ); + } + + VirtualProtect( ( void* )start, size, protection_flag, &protection_flag ); + } + + static void fuck_skids( ) { + DELETE_START( 0 ); + // stop most debuggers from working as breakpoint is patched to exit process call + + ulong_t old_protection = 0; + + uintptr_t exit_process = ( uintptr_t )GetProcAddress( GetModuleHandleA( xors( "kernel32.dll" ) ), xors( "ExitProcess" ) ); + uintptr_t dbg_ui_remote_breakin = ( uintptr_t )GetProcAddress( GetModuleHandleA( xors( "ntdll.dll" ) ), xors( "DbgUiRemoteBreakin" ) ); + uintptr_t dbg_break_point = ( uintptr_t )GetProcAddress( GetModuleHandleA( xors( "ntdll.dll" ) ), xors( "DbgBreakPoint" ) ); + + // fuck DbgUiRemoteBreakin + VirtualProtect( ( void* )dbg_ui_remote_breakin, 6, PAGE_EXECUTE_READWRITE, &old_protection ); + + *( uint8_t* )( dbg_ui_remote_breakin ) = 0x68; // push + *( uintptr_t* )( dbg_ui_remote_breakin + 1 ) = exit_process; + *( uint8_t* )( dbg_ui_remote_breakin + 5 ) = 0xC3; // ret + + VirtualProtect( ( void* )dbg_ui_remote_breakin, 6, old_protection, &old_protection ); + + // fuck DbgBreakPoint + VirtualProtect( ( void* )dbg_break_point, 6, PAGE_EXECUTE_READWRITE, &old_protection ); + + *( uint8_t* )( dbg_break_point ) = 0x68; // push + *( uintptr_t* )( dbg_break_point + 1 ) = exit_process; + *( uint8_t* )( dbg_break_point + 5 ) = 0xC3; // ret + + VirtualProtect( ( void* )dbg_break_point, 6, old_protection, &old_protection ); + + DELETE_END( 0 ); + } +} \ No newline at end of file -- cgit v1.2.3