Advertisement
yonidrori

Untitled

Oct 4th, 2015
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.64 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS //msvc doesn't like freopen
  2. #include <Windows.h>
  3. #include <iostream>
  4. #include <string> //for std::string
  5. #include <VMProtectSDK.h>
  6.  
  7. typedef void(__thiscall *changeprop)(void* self, DWORD descriptor);
  8. changeprop change_prop = (changeprop)0x511B60; //this func calls Changed events and replicates
  9.  
  10. typedef void(__thiscall *changename)(void* self, std::string* name);
  11. changename change_name = (changename)0x512EC0; //function which changes "Name" of an instance
  12.  
  13. typedef void(__thiscall *executescript)(void* self, std::string script);
  14. executescript exec_script = (executescript)0x831EF0; //LogService:ExecuteScript C function
  15.  
  16. using namespace std;
  17.  
  18. DWORD logservice; //global pointer to LogService
  19.  
  20.  
  21. //--------------------------------------------------------------------------------
  22. // Functions
  23.  
  24. HWND MainWindowHWND;
  25. HMENU hMenu;
  26. HMENU hMenuPopupFile;
  27. HMENU hMenuPopupAbout;
  28. HMODULE hInstance;
  29. HWND ScriptTextBoxHWND;
  30. LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
  31.  
  32. #define MYMENU_EXIT (WM_APP + 101)
  33. #define MYMENU_ABOUTMB (WM_APP + 102)
  34. #define MYMENU_EXECUTECODE (WM_APP + 103)
  35. #define MYMENU_SCRIPTTEXTBOX (WM_APP + 104)
  36. #define MYMENU_CLEARSCRIPT (WM_APP + 105)
  37. #define MYMENU_MINIMIZE (WM_APP + 109)
  38.  
  39. LRESULT CALLBACK DLLWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  40. {
  41. switch (message)
  42. {
  43. case WM_COMMAND:
  44. switch (wParam)
  45. {
  46. case MYMENU_EXIT:
  47. if (MessageBox(0, "Are you sure you want to close stigma?", "wtf r u doin", MB_YESNO) == IDYES)
  48. SendMessage(hwnd, WM_CLOSE, 0, 0);
  49. break;
  50. case MYMENU_MINIMIZE:
  51. ShowWindow(hwnd, SW_MINIMIZE);
  52. break;
  53. case MYMENU_ABOUTMB:
  54. MessageBox(hwnd, "Original script by Sliver Game Support\nProgram by [FaZe] Sliver Gaming Support (aka Asymmetry)", "About", MB_OK);
  55. break;
  56. case MYMENU_CLEARSCRIPT:
  57. SetDlgItemText(hwnd, MYMENU_SCRIPTTEXTBOX, "");
  58. break;
  59. case MYMENU_EXECUTECODE:
  60. int length;
  61. length = SendMessage(ScriptTextBoxHWND, WM_GETTEXTLENGTH, 0, 0);
  62. if (length == -1)
  63. break;
  64. char buff[80896]; // = 1024 * 79
  65. char len[255];
  66. _itoa_s(length, len, 10);
  67. GetDlgItemText(hwnd, MYMENU_SCRIPTTEXTBOX, buff, length + 1);
  68.  
  69. exec_script((void*)logservice, buff); //call LogService:ExecuteScript
  70. break;
  71. }
  72. break;
  73. case WM_DESTROY:
  74. PostQuitMessage(0);
  75. break;
  76. default:
  77. return DefWindowProc(hwnd, message, wParam, lParam);
  78. }
  79. return 0;
  80. }
  81.  
  82. BOOL RegisterDLLWindowClass(char *szClassName)
  83. {
  84. WNDCLASSEX wc;
  85. wc.hInstance = GetModuleHandle(NULL);
  86. wc.lpszClassName = szClassName;
  87. wc.lpfnWndProc = DLLWindowProc;
  88. wc.style = CS_DBLCLKS;
  89. wc.cbSize = sizeof(WNDCLASSEX);
  90. wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  91. wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
  92. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  93. wc.lpszMenuName = "Test";
  94. wc.cbClsExtra = 0;
  95. wc.cbWndExtra = 0;
  96. wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
  97. if (!RegisterClassEx(&wc))
  98. return 0;
  99. return 1;
  100. }
  101.  
  102. void RefreshContextMenu(HMENU hhMenu)
  103. {
  104. hMenuPopupFile = CreatePopupMenu();
  105. AppendMenu(hMenuPopupFile, MF_STRING, MYMENU_MINIMIZE, TEXT("Minimize"));
  106. AppendMenu(hMenuPopupFile, MF_STRING, MYMENU_EXIT, TEXT("Exit"));
  107. AppendMenu(hhMenu, MF_POPUP, (UINT_PTR)hMenuPopupFile, TEXT("File"));
  108.  
  109. hMenuPopupAbout = CreatePopupMenu();
  110. AppendMenu(hMenuPopupAbout, MF_STRING, MYMENU_ABOUTMB, TEXT("About"));
  111. AppendMenu(hhMenu, MF_POPUP, (UINT_PTR)hMenuPopupAbout, TEXT("Help"));
  112. }
  113.  
  114. HMENU CreateDLLWindowMenu()
  115. {
  116. HMENU heyMenu;
  117. heyMenu = CreateMenu();
  118.  
  119. if (heyMenu == NULL)
  120. return FALSE;
  121.  
  122. RefreshContextMenu(heyMenu);
  123. return heyMenu;
  124. }
  125.  
  126. void CreateFWindows()
  127. {
  128. CreateWindow("BUTTON", "EXE", WS_CHILD | WS_VISIBLE, 350, 0, 45, 150, MainWindowHWND, (HMENU)MYMENU_EXECUTECODE, hInstance, NULL);
  129. CreateWindow("BUTTON", "CLEAR", WS_CHILD | WS_VISIBLE, 350, 100, 45, 150, MainWindowHWND, (HMENU)MYMENU_CLEARSCRIPT, hInstance, NULL);
  130. ScriptTextBoxHWND = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_BORDER | WS_VSCROLL, 0, 0, 350, 250, MainWindowHWND, (HMENU)MYMENU_SCRIPTTEXTBOX, hInstance, 0);
  131. SendMessage(ScriptTextBoxHWND, EM_SETLIMITTEXT, 0x7FFFFFFE, 0);
  132. }
  133.  
  134. void ShowForm()
  135. {
  136. hInstance = GetModuleHandle(NULL);
  137. hMenu = CreateDLLWindowMenu();
  138. RegisterDLLWindowClass("DLLWindowClass");
  139. MainWindowHWND = CreateWindowEx(WS_EX_TOPMOST, "DLLWindowClass", "STIGMA V4", WS_EX_PALETTEWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 400, 300, NULL, hMenu, hInstance, NULL);
  140. CreateFWindows();
  141. ShowWindow(MainWindowHWND, SW_SHOWNORMAL);
  142.  
  143. MSG messages;
  144. while (GetMessage(&messages, NULL, 0, 0))
  145. {
  146. TranslateMessage(&messages);
  147. DispatchMessage(&messages);
  148. }
  149. }
  150.  
  151. //--------------------------------------------------------------------------------
  152. //MY CODE
  153.  
  154. {
  155. string *classname;
  156. __asm //disgusting
  157. {
  158. mov ecx, pInstance
  159. mov eax, [ecx + 0x1C]
  160. add ecx, 0x1C
  161. call dword ptr [eax + 4] //call the function to get classname
  162. add eax, 4 //offset by -4 for some reason
  163. mov classname, eax
  164. }
  165. return classname->c_str();
  166. }
  167.  
  168. //Returns a pointer to the first child of pInstance (a pointer to a RBX::Instance) who's classname == name
  169. DWORD getChildByClassName(DWORD pInstance, char *name)
  170. {
  171. VMProtectBeginMutation("gc");
  172.  
  173. int len = strlen(name);
  174. DWORD childrenptr = *(DWORD*)(pInstance + 0x44); //childrenptr is std::vector<boost::shared_ptr<RBX::Instance*>> *
  175. DWORD end = *(DWORD*)(childrenptr + 4); //pointer to the end of the vector
  176.  
  177. /*
  178.  
  179. int i is set to *(childrenptr), which is the start of the vector, basically an array of boost::shared_ptr<RBX::Instance*>
  180. This makes 'int i' a boost::shared_ptr<RBX::Instance*> *
  181. *(childrenptr+4) is a ptr to the end of the vector
  182.  
  183. boost::shared_ptr<RBX::Instance*> is a simple struct:
  184. struct shit
  185. {
  186. RBX::Instance *pInstance;
  187. void *ptr_to_some_internal_boost_class;
  188. }
  189.  
  190. So to get pInstance, I can do *(int*)i
  191.  
  192. Since the struct's size is 8 so I add 8 to i each loop
  193. I'm too lazy to define structs so I search the vector manually
  194.  
  195. */
  196.  
  197. for (int i = *(int*)childrenptr; i != end; i += 8)
  198. {
  199. if (memcmp(getclassname(*(int*)i), name, len) == 0)
  200. {
  201. VMProtectEnd();
  202. return *(int*)i; //return the pointer to the instance
  203. }
  204. }
  205. return 0;
  206. }
  207.  
  208. void init()
  209. {
  210. VMProtectBeginUltra("init");
  211.  
  212. AllocConsole();//create console
  213. freopen("CONOUT$", "w", stdout);
  214. freopen("CONIN$", "r", stdin);
  215.  
  216. cout << "Initializing... ";
  217.  
  218. DWORD game = *(DWORD*)(0x130186C);
  219. game = *(DWORD*)(game + 0x5C);
  220. game = *(DWORD*)(game + 4);
  221. game = *(DWORD*)(game + 4);
  222. //Gets the active DataModel 0x130186C] + 0x5C] + 0x4] + 0x4]
  223.  
  224. DWORD plyrs = getChildByClassName(game, "Players");
  225. //lua equivalent: local plyrs = game:GetService("Players")
  226.  
  227. DWORD localplayer = *(DWORD*)(plyrs + 0x180);
  228. //Players + 0x180 is the LocalPlayer
  229. //lua equivalent: local localplayer = plyrs.LocalPlayer
  230.  
  231. DWORD creatorid = *(DWORD*)(game + 0xE5C) ^ *(DWORD*)(*(DWORD*)(game + 0xE5C));
  232. //game + 0xE5C is obfuscated creatorid: xor obfuscation (ptrtovalue XOR *ptrtovalue = actualvalue) where ptrtovalue = *(game+0xE5C)
  233. //lua equivalent: local creatorid = game.CreatorId
  234.  
  235. *(DWORD*)(localplayer + 0x94) = creatorid;
  236. //Player + 0x94 is userId
  237.  
  238. change_prop((void*)localplayer, 0x1692DE4);
  239. //replicate the changed userId, 0x1692DE4 = global propertydescriptor for Player.userId
  240. //lua equivalent: localplayer.userId = creatorid
  241.  
  242. logservice = getChildByClassName(game, "LogService");
  243. //lua equivalent: logservice = game:GetService("LogService")
  244.  
  245. cout << "done" << endl;
  246.  
  247. ShowForm(); //show the GUI
  248.  
  249. VMProtectEnd();
  250. }
  251.  
  252. BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
  253. {
  254. if (fdwReason == DLL_PROCESS_ATTACH)
  255. {
  256. DisableThreadLibraryCalls(hinstDLL);
  257. CreateThread(0, 0, (LPTHREAD_START_ROUTINE)init, 0, 0, 0); //lets go
  258. }
  259. return 1;
  260. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement