Share Pastebin
Guest
Public paste!

VCK Color Randomizer

By: a guest | Jun 23rd, 2010 | Syntax: C++ | Size: 5.46 KB | Hits: 112 | Expires: Never
Copy text to clipboard
  1. #include <windows.h>
  2. #include <Tlhelp32.h>
  3. #include <iostream>
  4. #include <cstdlib>
  5.  
  6. using namespace std;
  7.  
  8. char botNames[12][16];
  9.  
  10. DWORD GetPIDForProcess (char* process);
  11. void EnableDebugPriv();
  12. DWORD GetDLLBase(char* DllName, DWORD tPid);
  13. void SetRandomBotName(int botNum);
  14.  
  15. #define PATCH(i, w, l) WriteProcessMemory(hProc, reinterpret_cast<LPVOID>(processBase+i), w, l, &dSize)
  16.  
  17. void main() {
  18.        
  19.     cout << "VCK Random Colors by Silencer loaded!" << endl << endl;
  20.        
  21.     cout << "Searching VisualCustomKick.exe..." << endl;
  22.    
  23.     if(GetPIDForProcess("VisualCustomKick.exe") == 0) {
  24.    
  25.         cout << "VisualCustomKick.exe was not found..." << endl;
  26.         system("Pause");
  27.         exit(0);
  28.        
  29.     } else {
  30.    
  31.         cout << "Getting debug privileges..." << endl;
  32.         EnableDebugPriv();
  33.         cout << "Automatically randomizing now. Just close the program anytime to stop." << endl << endl;
  34.        
  35.         long counter = 1;
  36.         int i = 0;
  37.        
  38.         while(true) {
  39.                        
  40.                         static int refreshDelay;
  41.                         refreshDelay = 1000;
  42.                        
  43.                         for(i = 0; i < 12; i++) {
  44.                                 SetRandomBotName(i);
  45.                         }
  46.                        
  47.                         static HANDLE hProc;
  48.                         hProc = OpenProcess(PROCESS_ALL_ACCESS, false, GetPIDForProcess("VisualCustomKick.exe"));
  49.                        
  50.                         if(hProc) {
  51.                                
  52.                                 cout << "Process opened. ";
  53.                                
  54.                                 static DWORD processBase;
  55.                                 processBase = GetDLLBase("VisualCustomKick.dll", GetPIDForProcess("VisualCustomKick.exe"));
  56.                                
  57.                                 static DWORD dSize;
  58.                                 dSize = 0;
  59.                                
  60.                                 // Bot 1
  61.                                 PATCH(0x00427EC8, botNames[0], 16);
  62.                                 PATCH(0x004F56CC, botNames[0], 16);
  63.                    
  64.                                 // Bot 2
  65.                                 PATCH(0x00427FC7, botNames[1], 16);
  66.                                 PATCH(0x004F57CB, botNames[1], 16);
  67.                    
  68.                                 // Bot 3
  69.                                 PATCH(0x004280C6, botNames[2], 16);
  70.                                 PATCH(0x004F58CA, botNames[2], 16);
  71.                                
  72.                                 // Bot 4
  73.                                 PATCH(0x004281C5, botNames[3], 16);
  74.                                 PATCH(0x004F59C9, botNames[3], 16);
  75.                                
  76.                                 // Bot 5
  77.                                 PATCH(0x004282C4, botNames[4], 16);
  78.                                 PATCH(0x004F5AC8, botNames[4], 16);
  79.                                
  80.                                 // Bot 6
  81.                                 PATCH(0x004283C3, botNames[5], 16);
  82.                                 PATCH(0x004F5BC7, botNames[5], 16);
  83.                                
  84.                                 // Bot 7
  85.                                 PATCH(0x004284C2, botNames[6], 16);
  86.                                 PATCH(0x004F5CC6, botNames[6], 16);
  87.                                
  88.                                 // Bot 8
  89.                                 PATCH(0x004285C1, botNames[7], 16);
  90.                                 PATCH(0x004F5DC5, botNames[7], 16);
  91.                                
  92.                                 // Bot 9
  93.                                 PATCH(0x004286C0, botNames[8], 16);
  94.                                 PATCH(0x004F5EC4, botNames[8], 16);
  95.                                
  96.                                 // Bot 10
  97.                                 PATCH(0x004287BF, botNames[9], 16);
  98.                                 PATCH(0x004F5FC3, botNames[9], 16);
  99.                                
  100.                                 // Bot 11
  101.                                 PATCH(0x004288BE, botNames[10], 16);
  102.                                 PATCH(0x004F60C2, botNames[10], 16);
  103.                                
  104.                                 // Bot 12
  105.                                 PATCH(0x004289BD, botNames[11], 16);
  106.                                 PATCH(0x004F61C1, botNames[11], 16);
  107.                                
  108.                                 cout << "Randomized. (" << counter << ") " << endl;
  109.                                 counter++;
  110.                                
  111.                                 ReadProcessMemory(hProc, reinterpret_cast<LPCVOID>(0x004F62F4), &refreshDelay, 2, &dSize);
  112.                                
  113.                                 CloseHandle(hProc);
  114.                                 cout << "Closed process. Next in " << (refreshDelay / 2) << " milliseconds." << endl << endl;
  115.                                
  116.                         } else {
  117.                                
  118.                                 cout << "VCK could not be opened..." << endl;
  119.                                 system("Pause");
  120.                                 exit(0);
  121.                                
  122.                         }
  123.                        
  124.                         Sleep(refreshDelay / 2);
  125.                        
  126.                 }
  127.     }
  128.    
  129.     exit(1);
  130.    
  131. }
  132.  
  133. void SetRandomBotName(int botNum) {
  134.        
  135.         static int i;
  136.        
  137.         botNames[botNum][0] = '|';
  138.         botNames[botNum][1] = 'c';
  139.         botNames[botNum][2] = 'f';
  140.         botNames[botNum][3] = 'f';
  141.        
  142.         for(i = 4; i < 10; i++) {
  143.                 static int randomnum;
  144.                 randomnum = rand() % 16;
  145.                 if(randomnum < 10) {
  146.                         botNames[botNum][i] = '0' + randomnum;
  147.                 } else {
  148.                         botNames[botNum][i] = 'a' - 10 + randomnum;
  149.                 }
  150.         }
  151.        
  152.         botNames[botNum][10] = 'A';
  153.         botNames[botNum][11] = 'R';
  154.         botNames[botNum][12] = '-';
  155.         botNames[botNum][13] = (botNum < 10) ? '0' : '1';
  156.         botNames[botNum][14] = '0' + (botNum % 10);
  157.         botNames[botNum][15] = '\0';
  158.        
  159. }
  160.  
  161. // Queries the ProcessId of a certain process
  162. DWORD GetPIDForProcess (char* process) {
  163.         BOOL            working = 0;
  164.         PROCESSENTRY32  lppe = {0};
  165.         DWORD           targetPid = 0;
  166.        
  167.         HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  168.         if(hSnapshot) {
  169.                 lppe.dwSize = sizeof(lppe);
  170.                 working=Process32First(hSnapshot, &lppe);
  171.                 while(working) {
  172.                         if(_stricmp(lppe.szExeFile, process) == 0) {
  173.                                 targetPid=lppe.th32ProcessID;
  174.                                 break;
  175.                         }
  176.                 working = Process32Next(hSnapshot, &lppe);
  177.                 }
  178.         }
  179.        
  180.         CloseHandle(hSnapshot);
  181.         return targetPid;
  182. }
  183.  
  184. // Enables to open other processes
  185. void EnableDebugPriv() {
  186.         HANDLE hToken;
  187.         LUID sedebugnameValue;
  188.         TOKEN_PRIVILEGES tkp;
  189.        
  190.         if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
  191.                 return;
  192.         }
  193.        
  194.         if(!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &sedebugnameValue)) {
  195.                 CloseHandle(hToken);
  196.                 return;
  197.         }
  198.         tkp.PrivilegeCount = 1;
  199.         tkp.Privileges[0].Luid = sedebugnameValue;
  200.         tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
  201.         if(!AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof tkp, NULL, NULL)) {
  202.                 CloseHandle(hToken);
  203.         }
  204. }
  205.  
  206. // Gets the base of a dll
  207. DWORD GetDLLBase(char* DllName, DWORD tPid) {
  208.         HANDLE snapMod;
  209.         MODULEENTRY32 me32;
  210.        
  211.         if(tPid == 0) {
  212.                 return 0;
  213.         }
  214.        
  215.         snapMod = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, tPid);
  216.         me32.dwSize = sizeof(MODULEENTRY32);
  217.         if (Module32First(snapMod, &me32)) {
  218.                 do {
  219.                         if (strcmp(DllName, me32.szModule) == 0) {
  220.                                 CloseHandle(snapMod);
  221.                                 return (DWORD) me32.modBaseAddr;
  222.                         }
  223.                 } while(Module32Next(snapMod, &me32));
  224.         }
  225.        
  226.         CloseHandle(snapMod);
  227.         return 0;
  228. }