Thumbs upUndetected Base - SimpleWH Source

Posts 1–15 of 58 · Page 1 of 4
Undetected Base - SimpleWH Source
Code:
#include <windows.h>
#include <iostream>
#include <psapi.h>

using namespace std;
Code:
#define Wallhack 0x7480AC

typedef int (WINAPI* myMsgBox)(HWND,LPSTR,LPSTR,UINT);
typedef SHORT (WINAPI* myGetKeyState)(int);
typedef BOOL (WINAPI* myBeep)(DWORD, DWORD);
Code:
void Wait(int seconds)
{
	for(int x = 0; x < seconds * 2500;x++)
	{
	}
}

struct CDATA
{
	char msg[50];
	char title[50];
	int buttons;

	LPVOID msgbox_addr;
	LPVOID getkeystate_addr;
	LPVOID beep_addr;
};
Code:
DWORD FindCFID( DWORD processID )
{
    TCHAR szProcessName[MAX_PATH] = "n\\a";
    HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |PROCESS_VM_READ,FALSE, processID );
    if (NULL != hProcess )
    {
        HMODULE hMod;
        DWORD cbNeeded;

        if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod), 
             &cbNeeded) )
        {
            GetModuleBaseName( hProcess, hMod, szProcessName, 
                               sizeof(szProcessName)/sizeof(TCHAR) );
        }
    }
    if(strcmp(szProcessName, "crossfire.exe") == 0)
	{
		cout << "Found: " << szProcessName << endl;
		int ID = processID;
		CloseHandle( hProcess );
		return ID;
	}
	else
	{
		CloseHandle( hProcess );
		return NULL;
	}
}
Our main function that is injected into crossfire.exe and an empty function to get this functions address:

Code:
static DWORD Injected(CDATA* data)
{
	myGetKeyState keyState = (myGetKeyState)data->getkeystate_addr;
	myBeep beep = (myBeep)data->beep_addr;
	myMsgBox MsgBox = (myMsgBox)data->msgbox_addr;

	MsgBox(0,data->msg, data->title, data->buttons);
	while(TRUE)
	{
		if(keyState(VK_F10))
		{
			// Wallhack 0x74703C
			memcpy((void*)(Wallhack), (PBYTE)"\x90\x90\x90\x90", 4);
			beep(200,200);
		}
		Wait(1);
	}
	return 0;
}

static DWORD Empty(){  
	return 0;
}
The good stuff :P
Code:
void ject(DWORD procID)
{
	CDATA cdata;
	HANDLE TargetProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, false, procID);
	if(TargetProcessHandle)
	{
		cout << "Process opened: " << procID << endl;
		HMODULE user32 = LoadLibrary("User32.dll");
		HMODULE kernel = LoadLibrary("Kernel32.dll");
		if(!user32 || !kernel) return;
		cout << "Kernel.dll loaded..." << endl;
		cout << "User32.dll loaded..." << endl;

		cdata.buttons = MB_OK;
		strcpy_s(cdata.msg, "Press F10 ingame to activate wallhack!");
		strcpy_s(cdata.title, "Crossfire Hooked!");
		
		cdata.msgbox_addr = GetProcAddress(user32, "MessageBoxA");
		cdata.getkeystate_addr = GetProcAddress(user32, "GetAsyncKeyState");
		cdata.beep_addr = GetProcAddress(kernel, "Beep");

		cout << " " << endl;
		cout << "------------ADDYS------------" << endl;
		cout << "MsgBox: " << cdata.msgbox_addr << endl;
		cout << "KeyState: " << cdata.getkeystate_addr << endl;
		cout <<"Beep: " << cdata.beep_addr << endl;
		cout << "------------END ADDYS------------" << endl;
		cout << " " << endl;

		int szFunctionSize = (DWORD)Empty - (DWORD)Injected;
		cout << "Function Size: " << szFunctionSize << endl;

		LPVOID szFunctionAddress = VirtualAllocEx(TargetProcessHandle,0,szFunctionSize,MEM_RESERVE|MEM_COMMIT,PAGE_EXECUTE_READWRITE);
		cout << "Function addr: " << szFunctionAddress << endl;

		int num2 = WriteProcessMemory(TargetProcessHandle,szFunctionAddress,(VOID*)Injected, szFunctionSize,0);
		cout << "WriteProcessMemory returned: " << num2 << endl;
		if(num2 == 0)
		{
			DWORD errCode = GetLastError();
			char *err;
			if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,NULL,errCode,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR)&err,0,NULL))
				return;
			cout << "------> Error: " << err << endl;
			return;
		}

		LPVOID szDataAdress = VirtualAllocEx(TargetProcessHandle,0,sizeof(CDATA),MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE);
		cout << "Data addr: " << szDataAdress << endl;

		num2 = WriteProcessMemory(TargetProcessHandle,szDataAdress,&cdata,sizeof(CDATA),0);
		cout << "WriteProcessMemory returned: " << num2 << endl;
		if(num2 == 0)
		{
			DWORD errCode = GetLastError();
			char *err;
			if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,NULL,errCode,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR)&err,0,NULL))
				return;
			cout << "------> Error: " << err << endl;
			return;
		}
		DWORD lpNumberOfBytesWritten = 0;
		HANDLE hand = CreateRemoteThread(TargetProcessHandle, 0, 0, (LPTHREAD_START_ROUTINE)szFunctionAddress, szDataAdress, 0, (SIZE_T*)&lpNumberOfBytesWritten);
		if(hand != NULL)
		{
			WaitForSingleObject(TargetProcessHandle, 2000);
			VirtualFree(szFunctionAddress, 0, MEM_RELEASE);
			VirtualFree(szDataAdress, 0, MEM_RELEASE);
			CloseHandle(TargetProcessHandle);
			CloseHandle(hand);
			cout << "Successfully Injected... Byteswritten: " << lpNumberOfBytesWritten << endl;
		}
		else
			cout << "Error creating remote thread..." << endl;
	}
	else
		cout << "Error opening process for injection..." << endl;
}
Code:
int privileges()
{
	HANDLE Token;
	TOKEN_PRIVILEGES tp;
	if(OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,&Token))
	{
		LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tp.Privileges[0].Luid);
		tp.PrivilegeCount = 1;
		tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
		if (AdjustTokenPrivileges(Token, 0, &tp, sizeof(tp), NULL, NULL)==0)
			return 1; 
		else
			return 0; 
   }	  
   return 1;
}
Program entry point:
Code:
void main()
{
	if(privileges() != 0) 
	{
		cout << "Some kind of priviledge error..." << endl;
		return;
	}
	while(1)
	{
		DWORD aProcesses[1024], cbNeeded, cProcesses;
		unsigned int i;

		if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
		{
			cout << "Error reading process list..." << endl;
			return;
		}
		cProcesses = cbNeeded / sizeof(DWORD);

		DWORD procID = NULL;
		bool found = false;
		for ( i = 0; i < cProcesses; i++ )
		{
			if( aProcesses[i] != 0 )
			{
				procID = FindCFID( aProcesses[i] );
				if(procID != NULL)
				{
					found = true;
					break;
				}
			}
		}
		if(!found)
			cout << "waiting for crossfire.exe" << endl;
		else
		{
			cout << "crossfire.exe found! Injecting..." << endl;
			ject(procID);
			break;
		}
		Sleep(1000);
	}
}
Give me credits if you use! Thanks
Why?

But, GJ!
Quote Originally Posted by 6ixth View Post
Why?

But, GJ!
why what? lol
Quote Originally Posted by leech1122 View Post
why what? lol
Why u posted? .-.
Quote Originally Posted by 6ixth View Post


Why u posted? .-.
I released my hack, it can easily be disassembled, so I figured why not! Maybe help some others
Quote Originally Posted by leech1122 View Post
I released my hack, it can easily be dissembled, so I figured why not! Maybe help some others
Ok, np dude.
Quote Originally Posted by I2espect View Post
Good Job
Thanks a lot!
Okay guys.
How the hell can i use it ?!
I watched now tutorials on youtube from c++...
But i dont understand how i can use the source codes...
Please help anyone
Quote Originally Posted by LiviusLP View Post
Okay guys.
How the hell can i use it ?!
I watched now tutorials on youtube from c++...
But i dont understand how i can use the source codes...
Please help anyone
if you don't even know how to plug and play I say you give up now and find something else to do on this forum.
Quote Originally Posted by AxiomFlux View Post
if you don't even know how to plug and play I say you give up now and find something else to do on this forum.
I agree! This code is copy n paste friendly! You could just add it to an empty project and build it and it should have no errors at all.
Quote Originally Posted by leech1122 View Post
I agree! This code is copy n paste friendly! You could just add it to an empty project and build it and it should have no errors at all.
Need help here.. I've got these errors.

Code:
1>------ Build started: Project: CFHackTest, Configuration: Release Win32 ------
1>  CFHackTest.cpp
1>CFHackTest.cpp(33): error C2440: 'initializing' : cannot convert from 'const char [4]' to 'TCHAR [260]'
1>          There is no context in which this conversion is possible
1>CFHackTest.cpp(47): error C2664: 'strcmp' : cannot convert parameter 1 from 'TCHAR [260]' to 'const char *'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>CFHackTest.cpp(92): error C2664: 'LoadLibraryW' : cannot convert parameter 1 from 'const char [11]' to 'LPCWSTR'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>CFHackTest.cpp(93): error C2664: 'LoadLibraryW' : cannot convert parameter 1 from 'const char [13]' to 'LPCWSTR'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Quote Originally Posted by XxJuggernauTxX View Post
Need help here.. I've got these errors.

Code:
1>------ Build started: Project: CFHackTest, Configuration: Release Win32 ------
1>  CFHackTest.cpp
1>CFHackTest.cpp(33): error C2440: 'initializing' : cannot convert from 'const char [4]' to 'TCHAR [260]'
1>          There is no context in which this conversion is possible
1>CFHackTest.cpp(47): error C2664: 'strcmp' : cannot convert parameter 1 from 'TCHAR [260]' to 'const char *'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>CFHackTest.cpp(92): error C2664: 'LoadLibraryW' : cannot convert parameter 1 from 'const char [11]' to 'LPCWSTR'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>CFHackTest.cpp(93): error C2664: 'LoadLibraryW' : cannot convert parameter 1 from 'const char [13]' to 'LPCWSTR'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Make sure your project setting is set to use Multi Byte Character Set... And remove anything unicode related. I think that should fix that for you.
Quote Originally Posted by leech1122 View Post
Make sure your project setting is set to use Multi Byte Character Set... And remove anything unicode related. I think that should fix that for you.
I've already fix the previous problem but there's another problem

Code:
1>------ Build started: Project: CFHackTest, Configuration: Release Win32 ------
1>CFHackTest.obj : error LNK2001: unresolved external symbol _EnumProcesses@12
1>CFHackTest.obj : error LNK2001: unresolved external symbol _GetModuleBaseNameA@16
1>CFHackTest.obj : error LNK2001: unresolved external symbol _EnumProcessModules@16
1>F:\My Documents\Visual Studio 2010\Projects\CFHackTest\Release\CFHackTest.dll : fatal error LNK1120: 3 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I've already fixed the problem. Thank you so much @leech1122

OMG! It's detected by xTrap.
Posts 1–15 of 58 · Page 1 of 4

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?