Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.55 KB | None | 0 0
  1. // BHOP.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include <Windows.h>
  5. #include <TlHelp32.h>
  6. #include <iostream>
  7.  
  8. #define BHOP_KEY 'C'
  9.  
  10. struct module_t {
  11.     DWORD dwBase, dwSize;
  12. };
  13.  
  14. //debugger class:
  15.  
  16. class CDebugger {
  17. private:
  18.     DWORD dwPid;
  19.     HANDLE hProcess;
  20.  
  21. public:
  22.     bool attach(char* szProcess) {
  23.         HANDLE handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
  24.         PROCESSENTRY32 entry;
  25.         entry.dwSize = sizeof(entry);
  26.         do {
  27.  
  28.  
  29.             if (!wcscmp(entry.szExeFile, L"csgo.exe")) {
  30.                 dwPid = entry.th32ProcessID;
  31.                 CloseHandle(handle);
  32.                 hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, dwPid);
  33.                 return true;
  34.             }
  35.         } while (Process32Next(handle, &entry));
  36.         return false;
  37.     }
  38.  
  39.     module_t GetModule(char* szModule) {
  40.         HANDLE handle = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, NULL);
  41.         MODULEENTRY32 entry;
  42.         entry.dwSize = sizeof(entry);
  43.         do {
  44.  
  45.             if (!wcscmp(entry.szModule, L"client.dll")) {
  46.                 dwPid = entry.th32ProcessID;
  47.                 CloseHandle(handle);
  48.                 hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, dwPid);
  49.                 return{ (DWORD)entry.hModule,entry.modBaseSize };
  50.             }
  51.         } while (Module32Next(handle, &entry));
  52.         return{ (DWORD)false,(DWORD)false };
  53.     }
  54.  
  55.     template<typename T>
  56.     T ReadMemory(DWORD Adress) {
  57.         T read;
  58.         ReadProcessMemory(hProcess, (LPVOID)Adress, &read, sizeof(T), 0);
  59.         return read;
  60.     }
  61.  
  62.     template<typename T>
  63.     void WriteMemory(DWORD Adress, T value) {
  64.         WriteProcessMemory(hProcess, (LPVOID)Adress, &value, sizeof(T), 0);
  65.     }
  66. };
  67.  
  68.  
  69. //offsets
  70.  
  71. DWORD dwLocalPlayer = 0x00A6E444;
  72. DWORD dwJump = 0x04AF150C;
  73. DWORD dwFlags = 0x100;
  74.  
  75. CDebugger debugger;
  76. module_t moduleClient;
  77.  
  78. module_t* GetModuleClient() {
  79.     if (!moduleClient.dwBase && !moduleClient.dwSize) {
  80.         moduleClient = debugger.GetModule("client.dll");
  81.     }
  82.     return &moduleClient;
  83. }
  84.  
  85.  
  86. class CBunnyhop {
  87. public:
  88.     static unsigned long __stdcall ThreadRoutine(void*) {
  89.         while (true) {
  90.             DWORD dwMe = debugger.ReadMemory<DWORD>(GetModuleClient()->dwBase + dwLocalPlayer);
  91.             int CanJump = debugger.ReadMemory<DWORD>(dwMe + dwFlags);
  92.             if ((GetAsyncKeyState(VK_SPACE))) {
  93.                 debugger.WriteMemory<int>(GetModuleClient()->dwBase + dwJump, 5);
  94.                 Sleep(50);
  95.                 std::cout << "Jumping" << std::endl;
  96.                 debugger.WriteMemory<int>(GetModuleClient()->dwBase + dwJump, 4);
  97.             }
  98.  
  99.         }
  100.     }
  101. };
  102. int main()
  103. {
  104.  
  105.     while (!debugger.attach("csgo.exe")) {
  106.         Sleep(100);
  107.     }
  108.     std::cout << " Attached!" << std::endl;
  109.     CreateThread(0, 0, &CBunnyhop::ThreadRoutine, 0, 0, 0);
  110.     while (1) {
  111.         Sleep(100);
  112.     }
  113.  
  114.     return 0;
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement