Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
9.1 kB
0
Indexable
Never
#include "Includes.h"

using namespace std;

using namespace hazedumper::netvars;
using namespace hazedumper::signatures;

DWORD procId;
uintptr_t BaseEngine;
uintptr_t BaseDLL;
HWND hwnd;
HANDLE hProcess;



LPCSTR GetActiveWindowTitle()
{
    char wnd_title[256];
    HWND hwnd=GetForegroundWindow(); // get handle of currently active window
    GetWindowTextA(hwnd,wnd_title,sizeof(wnd_title));

    return wnd_title;
    
    
    
}
LPCSTR name = "Counter-Strike: Global Offensive - Direct3D 9";


string strwindow()
{
    char wnd_title[256];
    HWND hwnd = GetForegroundWindow(); // get handle of currently active window
    GetWindowTextA(hwnd, wnd_title, sizeof(wnd_title));

    return wnd_title;



}

string RandomString()
{
    int length = 64;

	string r;
	static const char bet[] = { "#$!%&?}{][ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" };
	srand((unsigned)time(NULL) * 5);
	for (int i = 0; i < length; ++i)
		r += bet[rand() % (sizeof(bet) - 1)];
	return r;
}


DWORD GetProcIDofProcess()
{

    HWND hwnd = FindWindowA(NULL, name);
    if (!hwnd){
        return false;
    }
    DWORD returnValue;
    GetWindowThreadProcessId(hwnd,&returnValue);
    return returnValue;
    
}


constexpr Vector3 CalculateAngle(
    const Vector3& localPosition,
    const Vector3& enemyPosition,
    const Vector3& viewAngles) noexcept
{
    return ((enemyPosition - localPosition).ToAngle() - viewAngles);
}


uintptr_t GetBaseDLLAddress(const char* modName) {
    HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, procId);
    if (hSnap != INVALID_HANDLE_VALUE) {
        MODULEENTRY32 modEntry;
        modEntry.dwSize = sizeof(modEntry);
        if (Module32First(hSnap, &modEntry)) {
            do {
                if (!strcmp(modEntry.szModule, modName)) {
                    CloseHandle(hSnap);
                    return (uintptr_t)modEntry.modBaseAddr;
                }
            } while (Module32Next(hSnap, &modEntry));
        }
    }
}
template<typename T> T RPM(SIZE_T address) { // Read Proces Memory
	T buffer;
	ReadProcessMemory(hProcess, (LPCVOID)address, &buffer, sizeof(T), NULL);
	return buffer;
}

template<typename T> void WPM(SIZE_T address, T buffer) { // Write Process Memory
	WriteProcessMemory(hProcess, (LPVOID)address, &buffer, sizeof(buffer), NULL);
}


uintptr_t entlist(int length) // entity list
{

    return RPM<uintptr_t>(BaseDLL + dwEntityList + length * 0x10);



}




uintptr_t getlocalplayer() { //This will get the address to localplayer. 
    return RPM< uintptr_t>(BaseDLL + dwLocalPlayer);
}

uintptr_t getPlayer(int index) {  //Each player in the game has an index.
    return RPM< uintptr_t>(BaseDLL + dwEntityList + index * 0x10); //We use index times 0x10 because the distance between each player 0x10.
}

int getTeam(uintptr_t player) {
    return RPM<int>(player + m_iTeamNum);
}

int getCrosshairID(uintptr_t player) {
    return RPM<int>(player + m_iCrosshairId);
}


void getit()
{
    DWORD pid = GetProcIDofProcess();
    string curtitlename = GetActiveWindowTitle();
    cout << "pid -> " << pid << endl;
    cout << "current window name -> "<< curtitlename << endl;
    cout << "client.dll -> " << BaseDLL << endl;
    cout << "engine.dll -> " << BaseEngine << endl;
    cout << "HWND -> " << hwnd << endl;
    cout << "localplayer -> " << getlocalplayer() << endl;
}


bool checkname()
{
    size_t pos;
    bool val;
    string search = "Counter";
    pos = strwindow().find(search);
    if (pos != string::npos)
    {
        val = true;

    }
    else {
        val = false;
    }

    return val ;
    

    
}



void Kanot()
{
    cout << " -> WORKS !" << endl;

    while (!GetAsyncKeyState(VK_END)) // end key for kill proc
    {

        if (checkname() != true)
        {
            static string paste = " <=> cooldown <=>";
            Sleep(1000);

            cout << paste << endl;
            continue;
        }

        const auto localplayer = RPM<uintptr_t>(BaseDLL + dwLocalPlayer);

        const auto glowobj = RPM<uintptr_t>(BaseDLL + dwGlowObjectManager);

        const auto locHP = RPM<int>(localplayer + m_iHealth);



        if (locHP != 0) {

            const auto stay_low = RPM<bool>(localplayer + m_fFlags);
            if (GetAsyncKeyState(VK_SPACE) && stay_low & (1 << 0))
            {
                WPM<DWORD>(BaseDLL + dwForceJump, 6);

            }
            else {
                WPM<DWORD>(BaseDLL + dwForceJump, 4);

            }
        }

        for (auto i = 0; i < 64; i++)
        {
            const auto ent = entlist(i);

            //cout << typeid(ent).name() << endl;
            //Sleep(500);

            //Glow
            const auto glowi = RPM<int32_t>(ent + m_iGlowIndex);

            const auto detectGlows = RPM<uintptr_t>(ent + m_iTeamNum) != RPM<uintptr_t>(localplayer + m_iTeamNum);

            if (detectGlows)
            {
                WPM<float>(glowobj + (glowi * 0x38) + 0x8, 1.f); // r
                WPM<float>(glowobj + (glowi * 0x38) + 0xC, 0.f); // g
                WPM<float>(glowobj + (glowi * 0x38) + 0x10, 0.f); // b
                WPM<float>(glowobj + (glowi * 0x38) + 0x14, 1.f); // a

                WPM<bool>(glowobj + (glowi * 0x38) + 0x27, true);
                WPM<bool>(glowobj + (glowi * 0x38) + 0x28, true);
            }



            // radar

            if (ent) {
                WPM<bool>(ent + m_bSpotted, true);
            }



            //no flash


            WPM<float>(localplayer + m_flFlashDuration, 0.f);
            WPM<float>(localplayer + m_flFlashMaxAlpha, 0.f);





        }
        // aimbot key
        
        
        
        if (!GetAsyncKeyState(0x43)) // c key
            continue;
            
        


        


            // get local TEAM
     
            const auto localTeam = RPM<int>(localplayer + m_iTeamNum);
            // eye position = origin + viewOffset
            const auto localEyePosition = RPM<Vector3>(localplayer +m_vecOrigin) +
                RPM<Vector3>(localplayer +m_vecViewOffset);

            const auto clientState = RPM<uintptr_t>(BaseEngine +dwClientState);

            const auto viewAngles = RPM<Vector3>(clientState +dwClientState_ViewAngles);
            const auto aimPunch = RPM<Vector3>(localplayer +m_aimPunchAngle) * 2;

            // aimbot fov
            auto bestFov = 30.f;
            auto bestAngle = Vector3{ };

            for (auto i = 1; i <= 64; ++i)
            {
                const auto player = RPM<uintptr_t>(BaseDLL +dwEntityList + i * 0x10);

                if (RPM<int>(player +m_iTeamNum) == localTeam )
                    continue;

                if (RPM<bool>(player +m_bDormant))
                    continue;

                if (!RPM<int>(player +m_iHealth))
                    continue;

                if (!RPM<bool>(player +m_bSpottedByMask))
                    continue;

                const auto boneMatrix = RPM<uintptr_t>(player +m_dwBoneMatrix);

                // pof of player head in 3d space
                const auto playerHeadPosition = Vector3{
                    RPM<float>(boneMatrix + 0x30 * 8 + 0x0C),
                    RPM<float>(boneMatrix + 0x30 * 8 + 0x1C),
                    RPM<float>(boneMatrix + 0x30 * 8 + 0x2C)
                };

                const auto angle = CalculateAngle(
                    localEyePosition,
                    playerHeadPosition,
                    viewAngles + aimPunch
                );

                const auto fov = hypot(angle.x, angle.y);

                if (fov < bestFov)
                {
                    bestFov = fov;
                    bestAngle = angle;
                }
            }

            // if we have a best angle, do aimbot
            if (!bestAngle.IsZero())
               WPM<Vector3>(clientState +dwClientState_ViewAngles, viewAngles + bestAngle / 1.f); // smoothing
    
         


        









        

    }

    
}

int main(int argc, char * argv[]) 
{
    SetConsoleTitleA(RandomString().c_str());

    hwnd = FindWindowA(NULL, name);
    GetWindowThreadProcessId(hwnd, &procId);
    BaseDLL = GetBaseDLLAddress("client.dll");
    BaseEngine = GetBaseDLLAddress("engine.dll");

    hProcess = OpenProcess(PROCESS_ALL_ACCESS, NULL, procId);
    while(true)
    {
        Sleep(1000);

        if(checkname() == true)
        {
            getit();
            break;

        }

        else
        {
            system("cls");
            cout << "<->Go to CSGO window please <->" << endl;
        }
    }
    
    system("color a");
    cout << "\nactive" << endl;

    Kanot();

    return 0;

}