当前位置:   article > 正文

植物大战僵尸外挂源码

外挂源码
  1. #include"stdafx.h"
  2. #include<iostream>
  3. #include<windows.h>
  4. #include <assert.h>
  5. #include<TlHelp32.h>
  6. #include <string.h>
  7. #include "stdio.h"
  8. #include "Shlwapi.h"
  9. #include "tlhelp32.h"
  10. #include "Psapi.h"
  11. #include <TChar.h> 
  12. #pragma comment(lib,"Psapi.lib")
  13. #pragma comment(lib,"Shlwapi.lib")
  14. //参数结构 ;
  15. typedef struct _RemotePara
  16. {
  17. UINT y;
  18. UINT x;
  19. UINT id;
  20. }RemotePara;
  21. using namespace std;
  22. HWND hwnd_Game;
  23. DWORD ProcessID;
  24. HANDLE h_process;
  25. int Base;
  26. int Offset[10];
  27. HANDLE hToken, hThread;
  28. RemotePara myRemotePara;
  29. HINSTANCE hUser32;
  30. void *pRemoteThread;
  31. DWORD byte_write;
  32. RemotePara *pRemotePara;
  33. const DWORD THREADSIZE = 1024 * 4;
  34. // 远程线程执行体
  35. DWORD __stdcall ThreadProc(RemotePara *Para) {
  36. typedef void(__stdcall *pExitProcess) (UINT);
  37. pExitProcess y = (pExitProcess)Para->y;
  38. pExitProcess x = (pExitProcess)Para->x;
  39. pExitProcess id = (pExitProcess)Para->id;
  40. __asm {
  41. pushad
  42. push - 1
  43. push id
  44. mov eax, y
  45. push x
  46. mov edi, dword ptr ds : [0x755E0C]
  47. mov edi, dword ptr ds : [edi + 0x868]
  48. push edi
  49. mov edx, 0x418D70
  50. call edx
  51. popad
  52. }
  53. return 0;
  54. }
  55. BOOL EnablePrivilege(HANDLE hToken, LPCTSTR szPrivName, BOOL fEnable)
  56. {
  57. TOKEN_PRIVILEGES tp;
  58. tp.PrivilegeCount = 1;
  59. LookupPrivilegeValue(NULL, szPrivName, &tp.Privileges[0].Luid);
  60. tp.Privileges[0].Attributes = fEnable ? SE_PRIVILEGE_ENABLED : 0;
  61. AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(tp), NULL, NULL);
  62. return((GetLastError() == ERROR_SUCCESS));
  63. }
  64. HANDLE GetPidByName(char *szName)
  65. {
  66. HWND hwnd_Game = FindWindow(NULL, L"Plants vs. Zombies");
  67. GetWindowThreadProcessId(hwnd_Game, &ProcessID);
  68. return OpenProcess(PROCESS_ALL_ACCESS, false, ProcessID);
  69. }
  70. int callPlant()
  71. {
  72. // 启动线程
  73. if (!WriteProcessMemory(h_process, pRemotePara, &myRemotePara, sizeof myRemotePara, 0))
  74. {
  75. return 0;
  76. }
  77. hThread = CreateRemoteThread(h_process, 0, 0, (DWORD(__stdcall *)(void *))pRemoteThread, pRemotePara, 0, &byte_write);
  78. return 1;
  79. }
  80. void GetGameInfo()
  81. {
  82. hwnd_Game = FindWindow(NULL, L"Plants vs. Zombies");
  83. GetWindowThreadProcessId(hwnd_Game, &ProcessID);
  84. h_process = OpenProcess(PROCESS_ALL_ACCESS, false, ProcessID);
  85. Base = 0x00755E0C;
  86. Offset[0] = 0x868;
  87. Offset[1] = 0x5578;
  88. }
  89. //通过基址加偏移得到动态地址
  90. int GetDymThroughBase(int Base, int Offset[], int len)
  91. {
  92. int Dym_temp;
  93. ReadProcessMemory(h_process, (LPVOID)Base, &Dym_temp, 4, NULL);
  94. for (int i = 0; i < len; i++)
  95. {
  96. if (i == len - 1)
  97. Dym_temp += Offset[i];
  98. else
  99. ReadProcessMemory(h_process, (LPVOID)(Dym_temp + Offset[i]), &Dym_temp, 4, NULL);
  100. }
  101. return Dym_temp;
  102. }
  103. //修改阳光
  104. void ChangeSunshine(int num)
  105. {
  106. int DymnamicAddress = GetDymThroughBase(Base, Offset, 2);
  107. int ret = WriteProcessMemory(h_process, (LPVOID)DymnamicAddress, &num, 4, NULL);
  108. if (ret == 0)
  109. {
  110. cout << "修改失败!" << endl;
  111. }
  112. else
  113. {
  114. cout << "修改成功!" << endl;
  115. }
  116. }
  117. //免CD
  118. void DisableCoolDown()
  119. {
  120. int num = 0x1477;
  121. int ret = WriteProcessMemory(h_process, (LPVOID)0x0049CE02, &num, 2, NULL);
  122. if (ret)
  123. {
  124. cout << "免冷却成功!" << endl;
  125. }
  126. else
  127. {
  128. cout << "免冷却失败!" << endl;
  129. }
  130. }
  131. int in()
  132. {
  133. // 在远程进程地址空间分配虚拟内存
  134. pRemoteThread = VirtualAllocEx(h_process, 0, THREADSIZE, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
  135. if (!pRemoteThread)
  136. return 0;
  137. // 将线程执行体ThreadProc写入远程进程
  138. if (!WriteProcessMemory(h_process, pRemoteThread, &ThreadProc, THREADSIZE, 0))
  139. return 0;
  140. ZeroMemory(&myRemotePara, sizeof(RemotePara));
  141. hUser32 = LoadLibrary((LPCWSTR)"kernel32.dll");
  142. //写进目标进程
  143. pRemotePara = (RemotePara *)VirtualAllocEx(h_process, 0, sizeof(RemotePara), MEM_COMMIT, PAGE_READWRITE);
  144. if (pRemotePara)
  145. {
  146. return 1;
  147. }
  148. else
  149. return 0;
  150. }
  151. int main()
  152. {
  153. int n_sunshine_change;
  154. int n_choice = 99;
  155. GetGameInfo();
  156. DWORD pID;
  157. char szSafePath[MAX_PATH] = { "C://Program Files//Safe Office//oem//BioFileLogOp.dll" };
  158. char szKxPath[MAX_PATH] = { "C://Program Files//KeXin WPS Office//oem//BioFileLogOp.dll" };
  159. HANDLE hSafeFind;
  160. HANDLE hKxFind;
  161. WIN32_FIND_DATA FindFileData, FindKxFileData;
  162. OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken); //打开进程
  163. EnablePrivilege(hToken, SE_DEBUG_NAME, TRUE); //提升为调试权限
  164. if (!in())
  165. {
  166. cout << "No!!!!!!!!!!!" << endl;
  167. Sleep(50000);
  168. return 0;
  169. }
  170. cout << "欢迎使用植物大战僵尸外挂,请选择你要实现的功能:\n1.修改阳光\n2.植物免冷却\n3.种植植物\n4.召唤炮兵连队\n5.召唤寒冰西瓜连队\n0.退出\n";
  171. while (n_choice)
  172. {
  173. cin >> n_choice;
  174. switch (n_choice)
  175. {
  176. case 1:
  177. cout << "请输入你要修改的阳光值:";
  178. cin >> n_sunshine_change;
  179. ChangeSunshine(n_sunshine_change);
  180. break;
  181. case 2:
  182. DisableCoolDown();
  183. break;
  184. case 3:
  185. cout << "请输入你要种植的植物ID:";
  186. cin >> myRemotePara.id;
  187. cout << "请输入你要种植的x坐标:";
  188. cin >> myRemotePara.x;
  189. cout << "请输入你要种植的y坐标:";
  190. cin >> myRemotePara.y;
  191. callPlant();
  192. break;
  193. case 4:
  194. cout << "Waiting......";
  195. myRemotePara.id = 40;
  196. myRemotePara.x = 0;
  197. for (int i = 0; i < 20; i++)
  198. {
  199. for (int j = 0; j < 6; j++)
  200. {
  201. myRemotePara.y = j;
  202. Sleep(100);
  203. callPlant();
  204. }
  205. }
  206. myRemotePara.id = 43;
  207. myRemotePara.x = 1;
  208. for (int i = 0; i < 2; i++)
  209. {
  210. for (int j = 0; j < 6; j++)
  211. {
  212. myRemotePara.y = j;
  213. Sleep(100);
  214. callPlant();
  215. }
  216. }
  217. myRemotePara.id = 22;
  218. myRemotePara.x = 2;
  219. for (int j = 0; j < 6; j++)
  220. {
  221. myRemotePara.y = j;
  222. Sleep(100);
  223. callPlant();
  224. }
  225. myRemotePara.id = 25;
  226. myRemotePara.x = 6;
  227. for (int j = 0; j < 6; j++)
  228. {
  229. myRemotePara.y = j;
  230. Sleep(100);
  231. callPlant();
  232. }
  233. cout << "OK! We have done.\n";
  234. break;
  235. case 5:
  236. cout << "Waiting......";
  237. myRemotePara.id = 44;
  238. myRemotePara.x = 0;
  239. for (int i = 0; i < 40; i++)
  240. {
  241. for (int j = 0; j < 5; j++)
  242. {
  243. myRemotePara.y = j;
  244. Sleep(100);
  245. callPlant();
  246. }
  247. }
  248. myRemotePara.id = 43;
  249. myRemotePara.x = 1;
  250. for (int i = 0; i < 1; i++)
  251. {
  252. for (int j = 1; j < 4; j++)
  253. {
  254. myRemotePara.y = j;
  255. Sleep(100);
  256. callPlant();
  257. }
  258. }
  259. cout << "OK! We have done.\n";
  260. break;
  261. case 6:
  262. cout << "Waiting......";
  263. myRemotePara.id = 0;
  264. myRemotePara.x = 4;
  265. for (int i = 0; i < 40; i++)
  266. {
  267. for (int j = 0; j < 5; j++)
  268. {
  269. myRemotePara.y = j;
  270. Sleep(100);
  271. callPlant();
  272. }
  273. }
  274. break;
  275. }
  276. }
  277. return 0;
  278. }

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/706845
推荐阅读
相关标签
  

闽ICP备14008679号