Advertisement
chrondog

Untitled

Dec 29th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.80 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <Windows.h>
  3. #include <iostream>
  4. #include <TlHelp32.h>
  5. using namespace std;
  6.  
  7. bool GetGameAccess();
  8. void PressKey(unsigned short KeyCode);
  9. ULONG GetModuleAddress(const char *szModuleName, const ULONG dwProcessId);
  10. int IsAlive();
  11. int GetMyTeam();
  12. int GetTargetTeam(int AimTarget);
  13.  
  14. HANDLE phandle;
  15. ULONG ClientDLL;
  16. ULONG EngineDLL;
  17.  
  18. int main()
  19. {
  20.     bool Continue = GetGameAccess();
  21.     if(Continue)
  22.     {
  23.         cout << "Triggerbot loaded!" << endl;
  24.         int i = 0, AimTarget = 0; ULONG AimOffset=0;
  25.         while(1)
  26.         {
  27.             ReadProcessMemory(phandle, LPCVOID(ClientDLL+0x780CD0), &i, sizeof(i), 0); AimOffset = i + 0x14A8;
  28.             ReadProcessMemory(phandle, LPCVOID(AimOffset), &AimTarget, sizeof(AimTarget), NULL);
  29.  
  30.             int IsAlivex = 0;
  31.             ReadProcessMemory(phandle, LPCVOID(ClientDLL+0x21E010), &IsAlivex, sizeof(IsAlivex), NULL);
  32.             cout << IsAlivex << endl;
  33.             if(AimTarget != 0)
  34.             {
  35.                 int TargetTeam = GetTargetTeam(AimTarget);
  36.                 int MyTeam = GetMyTeam();
  37.                 int IsDead = IsAlive();
  38.                 if (TargetTeam != MyTeam &&
  39.                     (TargetTeam == 2 || TargetTeam == 3) &&
  40.                     (MyTeam == 2 || MyTeam == 3) &&
  41.                     IsDead == 0)
  42.                 PressKey(0x1A);
  43.             }
  44.             else
  45.                 Sleep(1);
  46.            
  47.         }
  48.     }
  49.     cin.get();
  50. }
  51.  
  52. int IsAlive()
  53. {
  54.     int Alive = 0;
  55.     ReadProcessMemory(phandle, LPCVOID(ClientDLL + 0x77C5F0), &Alive, sizeof(Alive), NULL);
  56.     return Alive;
  57. }
  58.  
  59. int GetMyTeam()
  60. {
  61.     int Value = 0, PlayerID = 0;
  62.     ReadProcessMemory(phandle, LPCVOID(EngineDLL + 0x42CAD8), &PlayerID, sizeof(PlayerID), NULL);
  63.     PlayerID = 0x6E4+(4*PlayerID);
  64.     ReadProcessMemory(phandle, LPCVOID(ClientDLL + 0x74B430), &Value, sizeof(Value), NULL);
  65.     ReadProcessMemory(phandle, LPCVOID(Value+0x26C), &Value, sizeof(Value), NULL);
  66.     ReadProcessMemory(phandle, LPCVOID(Value+PlayerID), &Value, sizeof(Value), NULL);
  67.     return Value;
  68. }
  69.  
  70. int GetTargetTeam(int AimTarget)
  71. {
  72.     int Value1 = 0, Value2 = 0;
  73.     ReadProcessMemory(phandle, LPCVOID(ClientDLL + 0x74B430), &Value1, sizeof(Value1), NULL);
  74.     ReadProcessMemory(phandle, LPCVOID(Value1 + 0x26C), &Value1, sizeof(Value1), NULL);
  75.     Value2 = 0x6E4+(4*AimTarget);
  76.     ReadProcessMemory(phandle, LPCVOID(Value1 + Value2), &Value1, sizeof(Value1), NULL);
  77.     return Value1;
  78. }
  79.  
  80. bool GetGameAccess()
  81. {
  82.     ULONG pid;
  83.     HWND hWnd;
  84.     hWnd = FindWindow(NULL, "Counter-Strike Source");
  85.     if(!hWnd)
  86.     {
  87.         cout <<"Game not found. Press enter to retry.\n";
  88.         cin.get();
  89.         main();
  90.         return false;
  91.     }
  92.     else
  93.     {
  94.         GetWindowThreadProcessId(hWnd, &pid);
  95.         phandle = OpenProcess(PROCESS_VM_READ, 0, pid);
  96.         if(!phandle)
  97.         {
  98.             cout << "Could not get handle to window. Press enter to retry.\n";
  99.             cin.get();
  100.             main();
  101.             return false;
  102.         }
  103.         else
  104.         {
  105.             ClientDLL = GetModuleAddress("client.dll", pid);
  106.             EngineDLL = GetModuleAddress("engine.dll", pid);
  107.             return true;
  108.         }
  109.     }
  110. }
  111.  
  112. ULONG GetModuleAddress(const char *szModuleName, const ULONG dwProcessId)
  113. {
  114.     if (!szModuleName || !dwProcessId)
  115.         return 0;
  116.     HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessId);
  117.     if (hSnap == INVALID_HANDLE_VALUE)
  118.         return 0;
  119.     MODULEENTRY32 me;
  120.     me.dwSize = sizeof(MODULEENTRY32);
  121.     if (Module32First(hSnap, &me))
  122.     {
  123.         while (Module32Next(hSnap, &me))
  124.         {
  125.             if (strcmp(reinterpret_cast<const char*>(me.szModule), szModuleName) == 0)
  126.             {
  127.                 CloseHandle(hSnap);
  128.                 return (ULONG)me.modBaseAddr;
  129.             }
  130.         }
  131.     }
  132.     CloseHandle(hSnap);
  133.     return 0;
  134. }
  135.  
  136. void PressKey(unsigned short KeyCode)
  137. {
  138.     INPUT InputData;
  139.     InputData.type = INPUT_KEYBOARD;
  140.     InputData.ki.wScan = KeyCode;
  141.     InputData.ki.time = (0);
  142.     InputData.ki.dwExtraInfo = 0;
  143.     InputData.ki.dwFlags = 0;
  144.     SendInput(1, &InputData, sizeof(InputData));
  145.     Sleep(10);
  146.     InputData.ki.dwFlags = KEYEVENTF_KEYUP;
  147.     SendInput(1, &InputData, sizeof(InputData));
  148.     Sleep(10);
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement