Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    Phizo's Avatar
    Join Date
    Oct 2010
    Gender
    male
    Posts
    26
    Reputation
    10
    Thanks
    1

    Executing console commands for CS:S?

    I'm making a 'Counter Strike: Source' hack in C++. I thought it would be a good start since it doesn't use DMA (Dynamic Memory Allocation) as it holds all the memory in static addresses, which are easy to find since there is no DMA.

    Anyway, I was wondering. How could I execute console commands? I heard something about PushToConsole() and SetConsoleVariable() being used for stuff like that.

    You need to execute 'sv_cheats 1' to execute other commands on other people servers, I wanted to get that as well as 'noclip' working. It doesn't have to be undetectable or anything, I just want it for LAN and stuff.

    (You will see sv_cheats in my code. I was trying to edit the memory for it, obviously it didn't work because it's local memory, it won't affect the server :\. Was worth a try anyway).

    Preview code: (I've added a lot more, just not sure if I should release it or not since it's VAC-Proof).

    Code:
    #include "stdafx.h"
    #include <iostream>
    #include <Windows.h>
    
    using namespace std;
    
    int main ()
    {
    	HWND hWnd = FindWindow(0, L"Counter-Strike Source"); // Finds the window titled "Counter-Strike Source".
    
    	if (hWnd == 0) // If it can't find the window, then:
    	{
    		cout << "I could not locate the window, either you've opened this before you opened CS:S, or this program has a bug." << endl;
    	}
    	else
    	{
    		DWORD pr0c3zz;
    		GetWindowThreadProcessId(hWnd, &pr0c3zz); // Locates the process through the window.
    		HANDLE trollpr0c3zz = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pr0c3zz); // Gives access to process.
    		if (!trollpr0c3zz) // If it can't access the process, then:
    		{
    			cout << "Could not locate CS:S process (hl2.exe)" << endl;
    		}
    		else
    		{
    			int sv_cheats = 1; // Activate cheat mode..
    			int r_drawothermodels_on = 2, r_drawothermodels_off = 1; // Wallhack on/off.
    			int r_DrawModelLightOrigin_on = 1, r_DrawModelLightOrigin_off = 0; // Light region on/off.
    			int showdata_on = 2, showdata_off = 0; // Show network data on/off.
    
    			int cheatsAddr = 0x0FD0E764; // Cheat mode.
    			int wallhackAddr = 0x243AEC3C; // Wallhack.
    			int gravityAddr = 0x0FCD81FC; // Light region.
    			int ndataAddr = 0x243EBD8C; // Show network data/usage.
    
    				bool LightRegion = false, Wallhack = false, NDATA = false;
    
    					cout << "Welcome to Phizo's Counter Strike: Source hack: Version 1.0" << endl;
    					cout << "The hotkeys toggle on and off incase you want to turn them off.\n" << endl;
    					cout << "Open console: ~" << endl;
    					cout << "Draw light region: F3" << endl;
    					cout << "Enable wallhack: F6" << endl;
    					cout << "Show network data/usage: Delete" << endl;
    
    			while(1) // Loops so the memory keeps rewriting itself if it's changed.
    				{
    					WriteProcessMemory(trollpr0c3zz, (LPVOID)cheatsAddr, &sv_cheats, sizeof(sv_cheats), NULL);
    
                    if (GetAsyncKeyState(VK_F3)&1) // If the "F3" hotkey is pressed then it will write the new data to the memory address.
    						LightRegion = !LightRegion;
    
    						if (LightRegion)
    						{
    						WriteProcessMemory(trollpr0c3zz, (LPVOID)gravityAddr, &r_DrawModelLightOrigin_on, sizeof(r_DrawModelLightOrigin_on), NULL);
    						}
    						else
    						{
    						WriteProcessMemory(trollpr0c3zz, (LPVOID)gravityAddr, &r_DrawModelLightOrigin_off, sizeof(r_DrawModelLightOrigin_off), NULL);
    						}
    
    				if (GetAsyncKeyState(VK_F6)&1)
    					Wallhack = !Wallhack;
    
    					if (Wallhack)
    					{
    					WriteProcessMemory(trollpr0c3zz, (LPVOID)wallhackAddr, &r_drawothermodels_on, sizeof(r_drawothermodels_on), NULL);
    					}
    					else
    					{
    					WriteProcessMemory(trollpr0c3zz, (LPVOID)wallhackAddr, &r_drawothermodels_off, sizeof(r_drawothermodels_off), NULL);
    					}
    
    					if (GetAsyncKeyState(VK_DELETE)&1)
    					NDATA = !NDATA;
    
    					if (NDATA)
    					{
    					WriteProcessMemory(trollpr0c3zz, (LPVOID)ndataAddr, &showdata_on, sizeof(showdata_on), NULL);
    					}
    					else
    					{
    					WriteProcessMemory(trollpr0c3zz, (LPVOID)ndataAddr, &showdata_off, sizeof(showdata_off), NULL);
    					}
    			} // End of loop.
    				
    		}
    		CloseHandle(trollpr0c3zz); // Removes access to the process when it is not needed.
    		}
    	system("pause");
    	return 0;
    }
    Thanks a lot .
    Last edited by Phizo; 09-29-2011 at 11:57 AM.

  2. #2
    ket_'s Avatar
    Join Date
    Sep 2011
    Gender
    male
    Posts
    33
    Reputation
    10
    Thanks
    2
    My Mood
    Psychedelic
    was it even possible to set sv_cheats=1 ? if your not server owner ?

  3. #3
    Phizo's Avatar
    Join Date
    Oct 2010
    Gender
    male
    Posts
    26
    Reputation
    10
    Thanks
    1
    Quote Originally Posted by ket_ View Post
    was it even possible to set sv_cheats=1 ? if your not server owner ?
    As I said in the original post. It was an unsuccessful test.

    Please read next time.

  4. #4
    ket_'s Avatar
    Join Date
    Sep 2011
    Gender
    male
    Posts
    33
    Reputation
    10
    Thanks
    2
    My Mood
    Psychedelic
    Quote Originally Posted by Phizo View Post
    As I said in the original post. It was an unsuccessful test.

    Please read next time.
    I'm not talking about your post. i'm talking in a global scope lol

    some time back i know someone was talking about this but i think all that was fake bs someone prove i'm wrong :/ .

  5. #5
    Phizo's Avatar
    Join Date
    Oct 2010
    Gender
    male
    Posts
    26
    Reputation
    10
    Thanks
    1
    Quote Originally Posted by ket_ View Post
    I'm not talking about your post. i'm talking in a global scope lol

    some time back i know someone was talking about this but i think all that was fake bs someone prove i'm wrong :/ .
    Oh, my bad .

    Yes, there was (not sure if it still works) a glitch to do it manually. You create your own server, go into console and type in "sv_cheats 329" or anything like that. Then go to Cheat Engine and type in "329" with 4 bytes selected because it's an integer. Then go back to console and type in "sv_cheats 1" and go back to Cheat Engine and search for "1" using the "Next search" button. There should be a static memory address, you double click it to put it on the cheat list and freeze the value. Then you enter a public server and it should be enabled still, since it's stuck on that value.

    Let me know if it still works .

  6. #6
    Nico's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Germany :D
    Posts
    15,918
    Reputation
    1121
    Thanks
    8,617
    Tried getting engine interfaces from engine.dll to do that?

  7. #7
    .::SCHiM::.'s Avatar
    Join Date
    Sep 2010
    Gender
    male
    Posts
    733
    Reputation
    180
    Thanks
    880
    My Mood
    Twisted
    Quote Originally Posted by Phizo View Post
    Oh, my bad .

    Yes, there was (not sure if it still works) a glitch to do it manually. You create your own server, go into console and type in "sv_cheats 329" or anything like that. Then go to Cheat Engine and type in "329" with 4 bytes selected because it's an integer. Then go back to console and type in "sv_cheats 1" and go back to Cheat Engine and search for "1" using the "Next search" button. There should be a static memory address, you double click it to put it on the cheat list and freeze the value. Then you enter a public server and it should be enabled still, since it's stuck on that value.

    Let me know if it still works .
    If you're sure the address is correct, the problem may lie in how your compiler treats sizes and signed-ness.

    More specifically, the pointer you're trying to set (sv_cheats) may not have the same size (in bytes) as your native int type (your compiler). Or perhaps the compiler treats ints as signed by default while the pointer is unsigned. You could try the following:
    Code:
    DWORD SV_CHEATS = 1;
    ...
    ...
    WriteProcessMemory(foo, bar, &SV_CHEATS , 4, bar); // sizeof( DWORD ) == 4 this sizetype should be guaranteed by your compiler/windows.h file. Since they are inherited form lower-level languages.

    I'm SCHiM

    Morals derive from the instinct to survive. Moral behavior is survival behavior above the individual level.

    Polymorphic engine
    Interprocess callback class
    SIN
    Infinite-precision arithmetic
    Hooking dynamic linkage
    (sloppy)Kernel mode Disassembler!!!

    Semi debugger




  8. #8
    Phizo's Avatar
    Join Date
    Oct 2010
    Gender
    male
    Posts
    26
    Reputation
    10
    Thanks
    1
    Quote Originally Posted by Nico View Post
    Tried getting engine interfaces from engine.dll to do that?
    Do you mean this?

    Code:
    HMODULE hClient = NULL;
    	while(hClient == NULL)
    	{
    		hClient = LoadLibraryW(L"client.dll");
    		Sleep(100);
    	}
    	HMODULE hConsole = NULL;
    	while(hConsole == NULL)
    	{
    		hConsole = LoadLibraryW(L"GameUI.dll");
    		Sleep(100);
    	}
    	HMODULE hEngine = NULL;
    	while(hEngine == NULL)
    	{
    		hEngine = LoadLibraryW(L"engine.dll");
    		Sleep(100);
    	}
    	Sleep(2000);
    
    CreateInterfaceFn GameUIInterface = (CreateInterfaceFn)GetProcAddress(hConsole, "CreateInterface");
    CreateInterfaceFn EngineInterface = (CreateInterfaceFn)GetProcAddress(hEngine, "CreateInterface");
    CreateInterfaceFn ClientInterface = (CreateInterfaceFn)GetProcAddress(hClient, "CreateInterface");
    MSysSurface = (IMatSystemSurface*)EngineInterface(MAT_SYSTEM_SURFACE_INTERFACE_VERSION, NULL);
    icvar = (ICvar*)EngineInterface(CVAR_INTERFACE_VERSION, NULL);
    pModelInfoClient = ( IVModelInfoClient* )ClientInterface( VMODELINFO_CLIENT_INTERFACE_VERSION, NULL );
    pGameConsole = (IGameConsole *)GameUIInterface(GAMECONSOLE_INTERFACE_VERSION, NULL);
    I did not write this code. Just wondering, it seems valid.

  9. #9
    Nico's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Germany :D
    Posts
    15,918
    Reputation
    1121
    Thanks
    8,617
    It works like that, just with the IVEngineClient.

  10. #10
    Phizo's Avatar
    Join Date
    Oct 2010
    Gender
    male
    Posts
    26
    Reputation
    10
    Thanks
    1
    Quote Originally Posted by .::SCHiM::. View Post
    If you're sure the address is correct, the problem may lie in how your compiler treats sizes and signed-ness.

    More specifically, the pointer you're trying to set (sv_cheats) may not have the same size (in bytes) as your native int type (your compiler). Or perhaps the compiler treats ints as signed by default while the pointer is unsigned. You could try the following:
    Code:
    DWORD SV_CHEATS = 1;
    ...
    ...
    WriteProcessMemory(foo, bar, &SV_CHEATS , 4, bar); // sizeof( DWORD ) == 4 this sizetype should be guaranteed by your compiler/windows.h file. Since they are inherited form lower-level languages.
    I'm positive that it's the correct address. I recorded the address with Cheat Engine, I went back to the game console and change the value, went back to Cheat Engine and it changed the value of the memory address to the same value as I set for sv_cheats.

    Quote Originally Posted by Nico View Post
    It works like that, just with the IVEngineClient.
    Ahhh...sorry? I'm not really getting it.
    Last edited by Phizo; 09-29-2011 at 11:55 AM.

  11. #11
    kibbles18's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Location
    US
    Posts
    860
    Reputation
    5
    Thanks
    127
    tier0.msg
    --

  12. #12
    Phizo's Avatar
    Join Date
    Oct 2010
    Gender
    male
    Posts
    26
    Reputation
    10
    Thanks
    1
    Quote Originally Posted by kibbles18 View Post
    tier0.msg
    --
    Ahhh....?

    Why does everyone have to be so confusing. :\.

  13. #13
    kibbles18's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Location
    US
    Posts
    860
    Reputation
    5
    Thanks
    127
    Look in debugger

  14. #14
    Phizo's Avatar
    Join Date
    Oct 2010
    Gender
    male
    Posts
    26
    Reputation
    10
    Thanks
    1
    Quote Originally Posted by kibbles18 View Post
    Look in debugger
    I'll check it out in Ollydbg. Thanks.

  15. #15
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    Get access to the IVEngineClient in engine.dll using CreateInterface(exported from engine dll) and use ClientCmd
    Ah we-a blaze the fyah, make it bun dem!

Page 1 of 2 12 LastLast

Similar Threads

  1. what is the console command for forward in time?
    By rallos in forum Vindictus Help
    Replies: 10
    Last Post: 06-21-2011, 06:53 AM
  2. Any console command for gold?
    By Cardsben in forum Vindictus Help
    Replies: 15
    Last Post: 04-24-2011, 06:27 PM
  3. Console Commands for SP
    By Yamato in forum Call of Duty Modern Warfare 2 GSC Modding Help/Discussion
    Replies: 5
    Last Post: 10-12-2010, 06:49 AM
  4. [SOLVED] MW2 Console Command for *Temp Ban*
    By dwcusterjr in forum Call of Duty Modern Warfare 2 Help
    Replies: 2
    Last Post: 06-28-2010, 09:57 AM
  5. [REQUEST] A LIST of FUN commands for the CONSOLE
    By Waldoa93 in forum Call of Duty Modern Warfare 2 Help
    Replies: 9
    Last Post: 01-28-2010, 10:00 PM