Advertisement
Guest User

:/

a guest
Oct 17th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3. #include <stdio.h>
  4. #include <string>
  5. #include <fstream>
  6.  
  7. using namespace std;
  8.  
  9. /*Simple Injector for CS: GO*/
  10.  
  11. DWORD get_pid(LPCSTR window_name)
  12. {
  13.     HWND hwnd;
  14.     DWORD pid;
  15.     hwnd = FindWindowA(NULL, window_name);
  16.     while (hwnd == NULL)
  17.     {
  18.         hwnd = FindWindowA(NULL, window_name);
  19.         Sleep(100);
  20.     }
  21.  
  22.     GetWindowThreadProcessId(hwnd, &pid);
  23.  
  24.     if (pid == NULL)
  25.     {
  26.         return NULL;
  27.     }
  28.     else
  29.     {
  30.         return pid;
  31.     }
  32.  
  33. }
  34.  
  35. int main()
  36. {
  37.     SetConsoleTitle("CS:GO DLL Injector v1.0");
  38.     while (true)
  39.     {
  40.         cout << "Counter-Strike: Global Offensive DLL Injector.              "; cout << "Author: Michal L."; cout << "            1337" << endl;
  41.         cout << "============================================================================================================" << endl;
  42.         string path;
  43.         LPCSTR dllpath;
  44.         cout << "DLL path: (with double left slashes)!" << endl;
  45.         cout << "If you have problems with invalid path and you are sure your path is valid!" << endl;
  46.         cout << "& You have any specyfic character in your username." << endl;
  47.         cout << "Just give this dll into disk: (example) C:\\x.dll or create folder on C or another disc for less mess:" << endl;
  48.         cout << "(example!) C:\\anyfolder\\cheat.dll" << endl;
  49.         cout << "Your path to dll file: " << endl;
  50.         std::getline(std::cin, path);
  51.         dllpath = path.c_str();
  52.         cout << dllpath << endl;
  53.         fstream check;
  54.         check.open(dllpath, ios::in);
  55.         if (check.good())
  56.         {
  57.             cout << "Waiting for CS: GO..." << endl;
  58.             DWORD pid = get_pid("Counter-Strike: Global Offensive");
  59.             cout << "Ready for injection." << endl;
  60.             HANDLE hprocess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
  61.             LPVOID pdll = VirtualAllocEx(hprocess, 0, strlen(dllpath) + 1, MEM_COMMIT, PAGE_READWRITE);
  62.             WriteProcessMemory(hprocess, pdll, (LPVOID)dllpath, strlen(dllpath) + 1, 0);
  63.             HANDLE loadthread = CreateRemoteThread(hprocess, 0, 0, (LPTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandleA("Kernel32.dll"), "LoadLibraryA"), pdll, 0, 0);
  64.             WaitForSingleObject(loadthread, INFINITE);
  65.             VirtualFreeEx(hprocess, pdll, strlen(dllpath) + 1, MEM_RELEASE);
  66.             cout << "Succesfully injected!" << endl;
  67.             check.close();
  68.             Sleep(3000);
  69.             exit(0);
  70.         }
  71.         else
  72.         {
  73.             check.close();
  74.             cout << "Invalid path!" << endl;
  75.             Sleep(1500);
  76.             system("cls");
  77.         }
  78.     }
  79.     getchar();
  80.     getchar();
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement