NukeVsCity

functiojns fr axon __

Mar 12th, 2021
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.02 KB | None | 0 0
  1. bool CheckRobloxObject(lua_State* L, const int32_t idx) //some functions need this lol
  2. {
  3. const uint8_t Type = lua_type(L, idx);
  4. switch (Type)
  5. {
  6. case LUA_TFUNCTION:
  7. {
  8. if (reinterpret_cast<uintptr_t>(lua_tocfunction(L, idx)) == reinterpret_cast<uintptr_t>(FunctionHandling::RobloxCall))
  9. {
  10. return true;
  11. }
  12. else
  13. {
  14. return false;
  15. }
  16. }
  17. case LUA_TTABLE:
  18. {
  19. if (luaL_getmetafield(L, idx, "__key"))
  20. {
  21. lua_pop(L, 1);
  22. return true;
  23. }
  24. else
  25. {
  26. return false;
  27. }
  28. }
  29. case LUA_TUSERDATA:
  30. {
  31. uintptr_t RL = ExtraSpace::GetRoot(L)->RL;
  32. Wrapping::Wrap(L, RL, idx);
  33. if (r_luaL_getmetafield(RL, -1, "__type"))
  34. {
  35. r_lua_pop(RL, 2);
  36. return true;
  37. }
  38. else
  39. {
  40. r_lua_pop(RL, 1);
  41. return false;
  42. }
  43. }
  44. case LUA_TTHREAD:
  45. {
  46. if (ExtraSpace::GetRoot(L)->RLRef = NULL)
  47. return true;
  48. else
  49. return false;
  50. }
  51. default:
  52. {
  53. return false;
  54. }
  55. }
  56. }
  57.  
  58. }
  59.  
  60. }
  61.  
  62. uintptr_t GetAddress(uintptr_t Closure); //some functions need this lol
  63. void SetAddress(uintptr_t Closure, uintptr_t To);
  64. const char* GetName(uintptr_t Closure);
  65.  
  66. int SetFFlag(lua_State* L)
  67. {
  68. const std::string FlagName = lua_tostring(L, 1);
  69. const std::string SetTo = lua_tostring(L, 2);
  70. const bool Return = reinterpret_cast<int(__cdecl*)(const std::string&, const std::string&, int, bool)>(aslr(0x15A5DB0))(FlagName, SetTo, 1, true);//SetFFlag
  71. if (!Return)
  72. {
  73. lua_pushfstring(L, "%s FFlag does not exist!", FlagName.c_str());
  74. return lua_error(L);
  75. }
  76. return 0;
  77. }
  78.  
  79. int HookFunction(lua_State* L)
  80. {
  81.  
  82. const bool IsR = RobloxFunc::CheckRobloxObject(L, 1);
  83. if (IsR)
  84. {
  85. auto Space = ExtraSpace::GetRoot(L);
  86. uintptr_t RL = Space->RL;
  87. r_lua_settop(RL, 0);
  88. const uintptr_t Key = reinterpret_cast<uintptr_t>(lua_topointer(L, 2));
  89. Wrapping::Wrap(L, RL, 1);
  90. Wrapping::Wrap(L, RL, 2);
  91. if (r_lua_iscfunction(RL, 1))
  92. {
  93. const uintptr_t Replacement = GetAddress(reinterpret_cast<uintptr_t>(r_lua_topointer(RL, 2)));
  94.  
  95. uintptr_t Closure2 = reinterpret_cast<uintptr_t>(r_lua_topointer(RL, 1));
  96. uintptr_t Index2Adr = reinterpret_cast<uintptr_t>(r_index2adr(RL, -2));
  97. uintptr_t Old = GetAddress(Closure2);
  98. uint8_t nupvals = *reinterpret_cast<uint8_t*>(Closure2 + x_closurenups);
  99.  
  100. for (int i = 1; i <= nupvals; ++i)
  101. RobloxFunc::r2_lua_getupvalue(RL, -2 + ((i - 1) * -1), i);
  102. r_lua_pushcclosure(RL, Old, reinterpret_cast<int>(GetName(Closure2)), nupvals, NULL);
  103. Wrapping::Wrap(RL, L, -1);
  104. r_lua_pop(RL, 1);
  105.  
  106. SetAddress(Closure2, Replacement);
  107.  
  108. r_lua_newtable(RL);
  109. r_lua_pushstring(RL, "__func");
  110. r_lua_pushnumber(RL, Key);
  111. r_lua_settable(RL, -3);
  112. r_lua_pushstring(RL, "__thread");
  113. r_lua_pushlightuserdata(RL, Space->Main);
  114. r_lua_settable(RL, -3);
  115. r_lua_setfenv(RL, -3);
  116. r_lua_pop(RL, 2);
  117. return 1;
  118. }
  119. return luaL_error(L, "LClosure support not added");
  120. }
  121. else
  122. {
  123. return luaL_error(L, "Vanilla Closures support not added");
  124. }
  125. }
  126.  
  127. int getconnections(lua_State* L) {
  128.  
  129. if (!lua_isuserdata(L, 1) || !checksignal(L, 1))
  130. return luaL_argerror(L, 1, "signal expected");
  131. const auto EventInstance = *reinterpret_cast<std::uintptr_t*>(lua_touserdata(L, 1));
  132. const auto Source = reinterpret_cast<std::weak_ptr<uintptr_t>*>(EventInstance + 4)->lock();
  133. const auto Signal = reinterpret_cast<uintptr_t(__thiscall*)(uintptr_t*, bool)>(*reinterpret_cast<std::uintptr_t*>(EventInstance + 48))(Source.get(), true);
  134. return 1;
  135. }
  136.  
  137. int getconnectionfunc(lua_State* L) {
  138. if (!lua_isuserdata(L, 1))
  139. return luaL_argerror(L, 1, "signal expected");
  140. DWORD Conn = (DWORD)lua_touserdata(L, 1);
  141. DWORD TR = GetConnectionTR(L, Conn);
  142. DWORD NRL = *(DWORD*)(*(DWORD*)(TR + 0x38) + 0x8);
  143. DWORD Idx = *(DWORD*)(TR + 0x40);
  144. lua_pushinteger(LS, Idx);
  145. lua_gettable(LS, LUA_REGISTRYINDEX);
  146. lua_xmove(LS, L, 1);
  147. return 1;
  148. }
  149.  
  150. int getconnectionstate(lua_State* L)
  151. {
  152. if (!lua_isuserdata(L, 1))
  153. return luaL_argerror(L, 1, "signal expected");
  154. DWORD Conn = (DWORD)lua_touserdata(L, 1);
  155. DWORD TR = GetConnectionTR(L, Conn);
  156. DWORD NRL = *(DWORD*)(*(DWORD*)(TR + 0x38) + 0x8);
  157. lua_pushlightuserdata(L, (void*)NRL);
  158. return 1;
  159. }
  160.  
  161. int GetNameCallMethod(lua_State* L)
  162. {
  163. uintptr_t RL = ExtraSpace::GetRoot(L)->RL;
  164. RobloxFunc::r_lua_pushobject(RL, *reinterpret_cast<uintptr_t*>(RL + x_namecall), R_LUA_TSTRING);
  165. Wrapping::Wrap(RL, L, -1);
  166. r_lua_pop(RL, 1);
  167. return 1;
  168. }
  169.  
  170. int SetNameCallMethod(lua_State* L)
  171. {
  172. uintptr_t RL = ExtraSpace::GetRoot(L)->RL;
  173. *reinterpret_cast<uintptr_t*>(RL + x_namecall) = reinterpret_cast<uintptr_t>(index2adr(L, 1)->value.p);
  174. return 0;
  175. }
  176.  
  177.  
  178.  
  179. int CheckCaller(lua_State* L)
  180. {
  181. uintptr_t Thread = ExtraSpace::GetRoot(L)->RLGiven;
  182. const uintptr_t Space = *reinterpret_cast<uintptr_t*>(Thread + x_Identity2);
  183. const uintptr_t Script = *reinterpret_cast<uintptr_t*>(Space + x_ScriptPtr);
  184. lua_pushboolean(L, !Script);
  185. return 1;
  186. }
  187.  
  188. int UnLockModule(lua_State* L)
  189. {
  190. uintptr_t RL = ExtraSpace::GetRoot(L)->RL;
  191. Wrapping::Wrap(L, RL, 1);
  192. const uintptr_t Module = *reinterpret_cast<uintptr_t*>(r_lua_touserdata(RL, -1));
  193. *reinterpret_cast<int8_t*>(Module + x_UnLockModule) = 1;
  194. r_lua_pop(RL, 1);
  195. return 0;
  196. }
  197.  
  198. int GetRawMetaTable(lua_State* L)
  199. {
  200. const bool RObject = RobloxFunc::CheckRobloxObject(L, 1);
  201. if (RObject)
  202. {
  203. uintptr_t RL = ExtraSpace::GetRoot(L)->RL;
  204. Wrapping::Wrap(L, RL, 1);
  205. if (r_lua_getmetatable(RL, -1))
  206. {
  207. Wrapping::Wrap(RL, L, -1);
  208. r_lua_pop(RL, 2);
  209. }
  210. else
  211. {
  212. r_lua_pop(RL, 1);
  213. return luaL_error(L, "Attempt to call getrawmetatable failed: Passed value does not have a metatable\n");
  214. }
  215. }
  216. else
  217. {
  218. if (!lua_getmetatable(L, 1))
  219. {
  220. return luaL_error(L, "Attempt to call getrawmetatable failed: Passed value does not have a metatable\n");
  221. }
  222. }
  223. return 1;
  224. }
  225.  
  226. int FireClickDetector(lua_State* L)
  227. {
  228. uintptr_t RL = ExtraSpace::GetRoot(L)->RL;
  229. Wrapping::Wrap(L, RL, 1);
  230. const uintptr_t Click = *reinterpret_cast<uintptr_t*>(r_lua_touserdata(RL, -1));
  231. float Distance = 0;
  232. if (lua_gettop(L) > 1)
  233. Distance = lua_tonumber(L, 2);
  234. r_lua_getglobal(RL, "game");
  235. r_lua_getfield(RL, -1, "GetService");
  236. r_lua_insert(RL, -2);
  237. r_lua_pushstring(RL, "Players");
  238. r_lua_pcall(RL, 2, 1, 0);
  239. r_lua_getfield(RL, -1, "LocalPlayer");
  240. const uintptr_t LP = *reinterpret_cast<uintptr_t*>(r_lua_touserdata(RL, -1));
  241. r_fireclickdetector(Click, Distance, LP);
  242. r_lua_pop(RL, 2);
  243. return 0;
  244. }
  245.  
  246. int GetGC(lua_State* L)
  247. {
  248. int Index = 1;
  249. uintptr_t RL = ExtraSpace::GetRoot(L)->RL;
  250. uintptr_t GlobalState = GetGlobalState(RL);
  251. GCObject* GC_Objects = *reinterpret_cast<GCObject**>(GlobalState + x_rootgc);
  252. r_lua_newtable(RL);
  253. while (GC_Objects != nullptr)
  254. {
  255. const auto GC_Type = *reinterpret_cast<uint8_t*>((reinterpret_cast<uint32_t>(GC_Objects) + x_gchtt));
  256. if ((GC_Type == R_LUA_TTABLE || GC_Type == R_LUA_TFUNCTION || GC_Type == R_LUA_TUSERDATA))
  257. {
  258. RobloxFunc::r_lua_pushobject(RL, reinterpret_cast<uintptr_t>(GC_Objects), GC_Type);
  259. r_lua_rawseti(RL, -2, Index++);
  260. }
  261.  
  262. GC_Objects = GC_Objects->gch.next;
  263. }
  264. Wrapping::Wrap(RL, L, -1);
  265. r_lua_pop(RL, 1);
  266. return 1;
  267. }
  268.  
  269. int SetClipboard(lua_State* L)
  270. {
  271. std::size_t Length;
  272. const char* Setting = lua_tolstring(L, 1, &Length);
  273. if (OpenClipboard(NULL))
  274. {
  275. if (EmptyClipboard())
  276. {
  277. HGLOBAL hglbCopy = GlobalAlloc(GMEM_FIXED, Length + 1);
  278. if (hglbCopy == NULL)
  279. {
  280. CloseClipboard();
  281. return luaL_error(L, "Failed to SetClipboard");
  282. }
  283. memcpy(hglbCopy, Setting, Length + 1);
  284. if (!SetClipboardData(CF_TEXT, hglbCopy))
  285. {
  286. CloseClipboard();
  287. GlobalFree(hglbCopy);
  288. return luaL_error(L, "Failed to SetClipboard");
  289. }
  290. CloseClipboard();
  291. }
  292. else
  293. {
  294. return luaL_error(L, "Failed to SetClipboard");
  295. }
  296. }
  297. else
  298. {
  299. return luaL_error(L, "Failed to SetClipboard");
  300. }
  301. return 0;
  302. }
  303.  
  304. int GetClipboard(lua_State* L)
  305. {
  306. std::size_t Length;
  307. const char* Setting = lua_tolstring(L, 1, &Length);
  308. if (OpenClipboard(NULL))
  309. {
  310. HANDLE Got = GetClipboardData(CF_TEXT);
  311. if (Got == nullptr)
  312. {
  313. CloseClipboard();
  314. return luaL_error(L, "Failed to GetClipboard");
  315. }
  316.  
  317. char* pszText = static_cast<char*>(GlobalLock(Got));
  318. if (pszText == nullptr)
  319. {
  320. CloseClipboard();
  321. return luaL_error(L, "Failed to GetClipboard");
  322. }
  323. std::string text(pszText);
  324. GlobalUnlock(Got);
  325. CloseClipboard();
  326. lua_pushstring(L, text.c_str());
  327. return 1;
  328. }
  329. else
  330. {
  331. return luaL_error(L, "Failed to GetClipboard");
  332. }
  333. }
  334.  
  335. int GetRegList(lua_State* L)
  336. {
  337. uintptr_t RL = ExtraSpace::GetRoot(L)->RL;
  338. r_lua_pushlightuserdata(RL, reinterpret_cast<void*>(aslr(x_RobloxInstancePushFunction)));
  339. r_lua_rawget(RL, LUA_REGISTRYINDEX);
  340. Wrapping::Wrap(RL, L, -1);
  341. r_lua_pop(RL, 1);
  342. return 1;
  343. }
  344.  
  345. int IsCClosure(lua_State* L)
  346. {
  347. luaL_checktype(L, 1, LUA_TFUNCTION);
  348. const bool IsR = RobloxFunc::CheckRobloxObject(L, 1);
  349. if (IsR)
  350. {
  351. uintptr_t RL = ExtraSpace::GetRoot(L)->RL;
  352. Wrapping::Wrap(L, RL, 1);
  353. lua_pushboolean(L, r_lua_iscfunction(RL, -1));
  354. r_lua_pop(RL, 1);
  355. }
  356. else
  357. {
  358. lua_pushboolean(L, lua_iscfunction(L, 1));
  359. }
  360. return 1;
  361. }
  362.  
  363. int newcclosure(lua_State* L) {
  364. if (!lua_iscfunction(L, -1))
  365. return luaL_argerror(L, -1, "expected function as argument #1");
  366. Wrapper::UnWrap(L, RLS, 1);
  367. lua_tocfunction(L, -1);
  368. return 1;
  369. }
  370.  
  371. int setreadonly(lua_State* L)//Table, Bool
  372. {
  373. luaL_checktype(L, 1, LUA_TTABLE);
  374. luaL_checktype(L, 2, LUA_TBOOLEAN);
  375. if (!luaL_getmetafield(L, 1, "__key"))
  376. {
  377. index2adr(L, 1)->value.gc->h.readonly = lua_toboolean(L, 2);
  378. }
  379. else
  380. {
  381. lua_pop(L, 1);
  382. *reinterpret_cast<uint8_t*>(index2adr(L, 1)->value.gc->h.readonly) = lua_toboolean(L, 2);
  383. }
  384. return 0;
  385. }
  386.  
  387. int isreadonly(lua_State* L)
  388. {
  389. luaL_checkany(L, 1);
  390. if (!luaL_getmetafield(L, 1, "__key"))
  391. {
  392. lua_pushboolean(L, index2adr(L, 1)->value.gc->h.readonly);
  393. }
  394. else
  395. {
  396. lua_pop(L, 1);
  397. lua_pushboolean(L, *reinterpret_cast<uint8_t*>(index2adr(L, 1)->value.gc->h.readonly));
  398. }
  399. return 1;
  400. }
  401.  
  402. int ReadFile(lua_State* L)
  403. {
  404. const char* Name = lua_tostring(L, 1);
  405. std::string Dir = Tools::Files::GetDLLPath("\\workspace").append("\\" + std::string(Name));
  406. std::ifstream infile(Dir.c_str());
  407. if (!infile.good())
  408. {
  409. return luaL_error(L, "File Does Not Exist!");
  410. }
  411. lua_pushstring(L, Tools::Files::ReadFile(Dir).c_str());
  412. return 1;
  413. }
  414.  
  415. int WriteFile(lua_State* L)
  416. {
  417. const char* Name = lua_tostring(L, 1);
  418. const char* Writing = lua_tostring(L, 2);
  419. Tools::Files::WriteFile(Tools::Files::GetDLLPath("\\workspace").append("\\" + std::string(Name)), Writing);
  420. return 0;
  421. }
  422.  
  423. static int getgenv(lua_State* L) {
  424. lua_pushvalue(LS, LUA_GLOBALSINDEX);
  425. lua_xmove(LS, L, 1);
  426. return 1;
  427. }
  428.  
  429. int getsenv(lua_State* LS) {
  430. lua_pushvalue(LS, LUA_ENVIRONINDEX);
  431. Wrapper::Wrap(RLS, LS, -1);
  432. return 1;
  433. }
  434.  
  435. int getrenv(lua_State* L) {
  436. r_lua_pushvalue(RLS, int(RLS));
  437. Wrapper::Wrap(RLS, L, -1);
  438. return 1;
  439. }
  440.  
  441. int getreg(lua_State* L) {
  442. lua_pushvalue(L, LUA_REGISTRYINDEX);
  443. return 1;
  444. }
  445.  
  446. int getfenv(lua_State* m_L) {
  447. lua_pushvalue(LS, LUA_GLOBALSINDEX);
  448. lua_xmove(LS, m_L, 1);
  449. return 1;
  450. }
  451.  
  452. int setidentity(lua_State* L) {
  453. int unk[] = { NULL, NULL };
  454. int level = lua_tonumber(L, -1);
  455. SandBoxThread(RLS, &level, (int)unk);
  456. return 0;
  457. }
  458.  
  459. int isrbxactive(lua_State* L) {
  460. HWND RobloxWindow;
  461. RobloxWindow = FindMainWindow(GetCurrentProcessId());
  462. lua_pushboolean(L, GetForegroundWindow() == RobloxWindow);
  463. return 1;
  464. }
  465.  
  466. int error(lua_State* L) {
  467. Print(3, lua_tostring(L, -1));
  468. return 1;
  469. }
  470.  
  471. int info(lua_State* L) {
  472. Print(1, lua_tostring(L, -1));
  473. return 1;
  474. }
  475.  
  476. int Debug_SetMetaTable(lua_State* L) {
  477. if (lua_gettop(L) == 0) {
  478. luaL_error(L, "'debug.setmetatable' needs at least 1 argument.");
  479. return 0;
  480. }
  481. r_lua_pushboolean(RLS, lua_setmetatable(L, 1));
  482. return 1;
  483. }
  484.  
  485. static int Debug_setfenv(lua_State* L) {
  486. luaL_checktype(L, 2, LUA_TTABLE);
  487. lua_settop(L, 2);
  488. if (lua_setfenv(L, 1) == 0)
  489. luaL_error(L, LUA_QL("setfenv")
  490. " cannot change environment of given object");
  491. return 1;
  492. }
  493.  
  494. int Debug_GetMetaTable(lua_State* L) {
  495. if (lua_gettop(L) == 0) {
  496. luaL_error(L, "'debug.getrawmetatable' needs 1 argument.");
  497. return 0;
  498. }
  499. Wrapper::Wrap(RLS, L, 1);
  500. if (r_lua_getmetatable(RLS, -1) == 0) {
  501. lua_pushnil(L);
  502. return 0;
  503. }
  504. Wrapper::UnWrap(L, RLS, -1);
  505. return 1;
  506. }
  507.  
  508. int Debug_GetRegistry(lua_State* L) {
  509. r_lua_pushvalue(RLS, LUA_REGISTRYINDEX);
  510. return 1;
  511. }
  512.  
  513. static int Debug_traceback(lua_State* L) {
  514. int level;
  515. int firstpart = 1; /* still before eventual `...' */
  516. int arg;
  517. lua_State* L1 = getthread(L, &arg);
  518. lua_Debug ar;
  519. if (lua_isnumber(L, arg + 2)) {
  520. level = (int)lua_tointeger(L, arg + 2);
  521. lua_pop(L, 1);
  522. }
  523. else
  524. level = (L == L1) ? 1 : 0; /* level 0 may be this own function */
  525. if (lua_gettop(L) == arg)
  526. lua_pushliteral(L, "");
  527. else if (!lua_isstring(L, arg + 1)) return 1; /* message is not a string */
  528. else lua_pushliteral(L, "\n");
  529. lua_pushliteral(L, "stack traceback:");
  530. while (lua_getstack(L1, level++, &ar)) {
  531. if (level > LEVELS1 && firstpart) {
  532. /* no more than `LEVELS2' more levels? */
  533. if (!lua_getstack(L1, level + LEVELS2, &ar))
  534. level--; /* keep going */
  535. else {
  536. lua_pushliteral(L, "\n\t..."); /* too many levels */
  537. while (lua_getstack(L1, level + LEVELS2, &ar)) /* find last levels */
  538. level++;
  539. }
  540. firstpart = 0;
  541. continue;
  542. }
  543. lua_pushliteral(L, "\n\t");
  544. lua_getinfo(L1, "Snl", &ar);
  545. lua_pushfstring(L, "%s:", ar.short_src);
  546. if (ar.currentline > 0)
  547. lua_pushfstring(L, "%d:", ar.currentline);
  548. if (*ar.namewhat != '\0') /* is there a name? */
  549. lua_pushfstring(L, " in function " LUA_QS, ar.name);
  550. else {
  551. if (*ar.what == 'm') /* main? */
  552. lua_pushfstring(L, " in main chunk");
  553. else if (*ar.what == 'C' || *ar.what == 't')
  554. lua_pushliteral(L, " ?"); /* C function or tail call */
  555. else
  556. lua_pushfstring(L, " in function <%s:%d>",
  557. ar.short_src, ar.linedefined);
  558. }
  559. lua_concat(L, lua_gettop(L) - arg);
  560. }
  561. lua_concat(L, lua_gettop(L) - arg);
  562. return 1;
  563. }
  564.  
  565. int getupvalues(lua_State* L)
  566. {
  567. lua_pushvalue(L, 1);
  568. lua_newtable(L);
  569.  
  570. int idx = 1;
  571. while (true)
  572. {
  573. const char* name = lua_getupvalue(L, -2, idx);
  574.  
  575. if (!name)
  576. {
  577. break;
  578. }
  579.  
  580. lua_setfield(L, -2, name);
  581. idx++;
  582. }
  583. return 1;
  584. }
  585.  
  586. static int Debug_getupvalue(lua_State* L) {
  587. return auxupvalue(L, 1);
  588. }
  589.  
  590.  
  591. static int Debug_setupvalue(lua_State* L) {
  592. luaL_checkany(L, 3);
  593. return auxupvalue(L, 0);
  594. }
  595.  
  596. int setlocal(lua_State* L) {
  597.  
  598. luaL_checktype(L, 1, R_LUA_TNUMBER);
  599. luaL_checktype(L, 2, R_LUA_TSTRING);
  600. luaL_checkany(L, 3);
  601.  
  602. const char* Name = lua_tostring(L, 2);
  603.  
  604. lua_Debug ar;
  605. if (!lua_getstack(L, lua_tointeger(L, 1), &ar))
  606. return luaL_argerror(L, 1, "level out of range");
  607. int n = 1;
  608. while (const char* name = lua_getlocal(L, &ar, n))
  609. {
  610. lua_pop(L, 1);
  611. if (!strcmp(name, Name))
  612. {
  613. lua_pushvalue(L, 3);
  614. lua_setlocal(L, &ar, n);
  615. lua_pushboolean(L, true);
  616. return 1;
  617. }
  618. n++;
  619. }
  620.  
  621. lua_pushboolean(L, false);
  622. return 1;
  623. }
  624.  
  625. int getlocal(lua_State* L) {
  626. luaL_checktype(L, 1, R_LUA_TNUMBER);
  627. luaL_checktype(L, 2, R_LUA_TSTRING);
  628.  
  629. const char* Name = lua_tostring(L, 2);
  630.  
  631. lua_Debug ar;
  632. if (!lua_getstack(L, lua_tointeger(L, 1), &ar))
  633. return luaL_argerror(L, 1, "level out of range");
  634.  
  635. int n = 1;
  636. while (const char* name = lua_getlocal(L, &ar, n))
  637. {
  638. if (!strcmp(name, Name)) return 1;
  639. lua_pop(L, 1);
  640. n++;
  641. }
  642.  
  643. lua_pushnil(L);
  644. return 1;
  645. }
  646.  
  647. int getlocals2(lua_State* L) {
  648. lua_Debug ar;
  649. if (!lua_getstack(L, luaL_checkinteger(L, 1), &ar))
  650. return luaL_argerror(L, 1, "level out of range");
  651.  
  652. lua_newtable(L);
  653.  
  654. int n = 1;
  655. while (const char* name = lua_getlocal(L, &ar, n))
  656. {
  657. if (strcmp("(*temporary)", name) != 0)
  658. {
  659. lua_pushstring(L, name);
  660. lua_pushvalue(L, -2);
  661. lua_settable(L, -4);
  662. }
  663. lua_pop(L, 1);
  664. n++;
  665. }
  666.  
  667. return 1;
  668. }
  669.  
  670. static void settabss(lua_State* L, const char* i, const char* v) { //needed for getinfo
  671. lua_pushstring(L, v);
  672. lua_setfield(L, -2, i);
  673. }
  674.  
  675.  
  676. static void settabsi(lua_State* L, const char* i, int v) { //needed for getinfo
  677. lua_pushinteger(L, v);
  678. lua_setfield(L, -2, i);
  679. }
  680.  
  681. static int Debug_getinfo(lua_State* L) {
  682. lua_Debug ar;
  683. int arg;
  684. lua_State* L1 = getthread(L, &arg);
  685. const char* options = luaL_optstring(L, arg + 2, "flnSu");
  686. if (lua_isnumber(L, arg + 1)) {
  687. if (!lua_getstack(L1, (int)lua_tointeger(L, arg + 1), &ar)) {
  688. lua_pushnil(L); /* level out of range */
  689. return 1;
  690. }
  691. }
  692. else if (lua_isfunction(L, arg + 1)) {
  693. lua_pushfstring(L, ">%s", options);
  694. options = lua_tostring(L, -1);
  695. lua_pushvalue(L, arg + 1);
  696. lua_xmove(L, L1, 1);
  697. }
  698. else
  699. return luaL_argerror(L, arg + 1, "function or level expected");
  700. if (!lua_getinfo(L1, options, &ar))
  701. return luaL_argerror(L, arg + 2, "invalid option");
  702. lua_createtable(L, 0, 2);
  703. if (strchr(options, 'S')) {
  704. settabss(L, "source", ar.source);
  705. settabss(L, "short_src", ar.short_src);
  706. settabsi(L, "linedefined", ar.linedefined);
  707. settabsi(L, "lastlinedefined", ar.lastlinedefined);
  708. settabss(L, "what", ar.what);
  709. }
  710. if (strchr(options, 'l'))
  711. settabsi(L, "currentline", ar.currentline);
  712. if (strchr(options, 'u'))
  713. settabsi(L, "nups", ar.nups);
  714. if (strchr(options, 'n')) {
  715. settabss(L, "name", ar.name);
  716. settabss(L, "namewhat", ar.namewhat);
  717. }
  718. if (strchr(options, 'L'))
  719. treatstackoption(L, L1, "activelines");
  720. if (strchr(options, 'f'))
  721. treatstackoption(L, L1, "func");
  722. return 1; /* return table */
  723. }
  724.  
  725. //mouse lib
  726. INPUT Inputs[1] = { 0 };
  727.  
  728. int Mouse1Down(lua_State* LS) {
  729. Inputs[0].mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN;
  730. SendInput(1, Inputs, sizeof(INPUT));
  731. return 0;
  732. }
  733.  
  734. int Mouse1Up(lua_State* L) {
  735. Inputs[0].mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTUP;
  736. SendInput(1, Inputs, sizeof(INPUT));
  737. return 0;
  738. }
  739.  
  740. int Mouse2Down(lua_State* L) {
  741. Inputs[0].mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_RIGHTDOWN;
  742. SendInput(1, Inputs, sizeof(INPUT));
  743. return 0;
  744. }
  745.  
  746. int Mouse2Up(lua_State* L) {
  747. Inputs[0].mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_RIGHTUP;
  748. SendInput(1, Inputs, sizeof(INPUT));
  749. return 0;
  750. }
  751.  
  752. int Mouse1Click(lua_State* L) {
  753. float n = lua_tonumber(L, -1);
  754. Inputs[0].mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN;
  755. SendInput(1, Inputs, sizeof(INPUT));
  756. Sleep(n);
  757. Inputs[0].mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTUP;
  758. SendInput(1, Inputs, sizeof(INPUT));
  759. return 0;
  760. }
  761.  
  762. int Mouse2Click(lua_State* L) {
  763. float n = lua_tonumber(L, -1);
  764. Inputs[0].mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN;
  765. SendInput(1, Inputs, sizeof(INPUT));
  766. Sleep(n);
  767. Inputs[0].mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTUP;
  768. SendInput(1, Inputs, sizeof(INPUT));
  769. return 0;
  770. }
  771.  
  772. int MouseScroll(lua_State* L) {
  773. int amount = lua_tonumber(L, -1);
  774. Inputs[0].mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_HWHEEL;
  775. Inputs[0].mi.mouseData = amount;
  776. SendInput(1, Inputs, sizeof(INPUT));
  777. Inputs[0].mi.mouseData = NULL;
  778. return 0;
  779. }
  780.  
  781. int MouseMoveRelative(lua_State* L) {
  782. LONG x = lua_tonumber(L, -2);
  783. LONG y = lua_tonumber(L, -1);
  784. POINT p;
  785. if (GetCursorPos(&p))
  786. {
  787. Inputs[0].mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
  788. Inputs[0].mi.dx = ((p.x + x) * 0xFFFF / GetSystemMetrics(SM_CXSCREEN) + 1);
  789. Inputs[0].mi.dy = ((p.y + y) * 0xFFFF / GetSystemMetrics(SM_CYSCREEN) + 1);
  790. SendInput(1, Inputs, sizeof(INPUT));
  791. }
  792. return 0;
  793. }
  794.  
  795. //keyboard lib
  796.  
  797. INPUT Inputs[1] = { 0 };
  798.  
  799. int KeyPress(lua_State* L) {
  800. WORD key = lua_tonumber(L, -1);
  801. Inputs[0].ki.wVk = key;
  802. SendInput(1, Inputs, sizeof(INPUT));
  803. Inputs[0].ki.wVk = NULL;
  804. return 0;
  805. }
  806.  
  807. int KeyRelease(lua_State* L) {
  808. WORD key = lua_tonumber(L, -1);
  809. Inputs[0].ki.wVk = key;
  810. Inputs[0].mi.dwFlags = KEYEVENTF_KEYUP;
  811. SendInput(1, Inputs, sizeof(INPUT));
  812. Inputs[0].mi.dwFlags = NULL;
  813. Inputs[0].ki.wVk = NULL;
  814. return 0;
  815. }
  816.  
  817. int KeyTap(lua_State* L) {
  818. WORD key = lua_tonumber(L, -2);
  819. int delay = lua_tonumber(L, -1);
  820. Inputs[0].ki.wVk = key;
  821. SendInput(1, Inputs, sizeof(INPUT));
  822. Sleep(delay);
  823. Inputs[0].mi.dwFlags = KEYEVENTF_KEYUP;
  824. SendInput(1, Inputs, sizeof(INPUT));
  825. Inputs[0].mi.dwFlags = NULL;
  826. Inputs[0].ki.wVk = NULL;
  827. return 0;
  828. }
  829.  
  830. int IsReady(lua_State* L) {
  831. lua_pushboolean(L, READY);
  832. return 1;
  833. }
  834.  
  835. int hashProtect(lua_State* L) { // to use this function you need to add sha.cpp in ur project this is the code for that https://pastebin.com/raw/xQdrkJqf
  836. string input = lua_tostring(L, -1);
  837. lua_pushstring(L, sha256(input).c_str());
  838. return 1;
  839. }
  840.  
  841. int EncodeBase64(lua_State* L) { // to use this function you need to add Base64.cpp in ur project this is the code for that https://pastebin.com/raw/2HjcFtiy
  842. string data = lua_tostring(L, 1);
  843. lua_pushstring(L, base64_encode(data).c_str());
  844. return 1;
  845. }
  846.  
  847. int DecodeBase64(lua_State* L) { // to use this function you need to add Base64.cpp in ur project this is the code for that https://pastebin.com/raw/2HjcFtiy
  848. string data = lua_tostring(L, 1);
  849. lua_pushstring(L, base64_decode(data).c_str());
  850. return 1;
  851. }
  852.  
  853. static int EQ(lua_State* Thread) {
  854. lua_pushboolean(Thread, (*(DWORD*)lua_touserdata(Thread, 1) == *(DWORD*)lua_touserdata(Thread, 2)));
  855. return 1;
  856. }
  857.  
  858. static int GC(lua_State* Thread) {
  859. void* UD = lua_touserdata(Thread, 1);
  860. if (RLS) {
  861. r_lua_rawgeti(RLS, LUA_REGISTRYINDEX, (int)UD);
  862. if (r_lua_type(RLS, -1) <= R_LUA_TNIL) {
  863. lua_pushnil(Thread);
  864. lua_rawseti(Thread, LUA_REGISTRYINDEX, (int)UD);
  865. }
  866. }
  867. return 0;
  868. }
  869.  
  870. //how to register them lol
  871.  
  872.  
  873. lua_register(LS, "setfflag", SetFFlag);
  874. lua_register(LS, "hookfunction", HookFunction);
  875. lua_register(LS, "getconnections", getconnections);
  876. lua_register(LS, "getconnectionfunc", getconnectionfunc);
  877. lua_register(LS, "getconnectionstate", getconnectionstate);
  878. lua_register(LS, "getnamecallmethod", GetNameCallMethod);
  879. lua_register(LS, "setnamecallmethod", SetNameCallMethod);
  880. lua_register(LS, "checkcaller", CheckCaller);
  881. lua_register(LS, "unlockmodule", UnLockModule);
  882. lua_register(LS, "getrawmetatable", GetRawMetaTable);
  883. lua_register(LS, "fireclickdetector", FireClickDetector);
  884. lua_register(LS, "getgc", GetGC);
  885. lua_register(LS, "setclipboard", SetClipboard);
  886. lua_register(LS, "getclipboard", GetClipboard);
  887. lua_register(LS, "getreglist", GetRegList);
  888. lua_register(LS, "iscclosure", IsCClosure);
  889. lua_register(LS, "newcclosure", newcclosure);
  890. lua_register(LS, "setreadonly", setreadonly);
  891. lua_register(LS, "isreadonly", isreadonly);
  892. lua_register(LS, "readfile", ReadFile);
  893. lua_register(LS, "writefile", WriteFile);
  894. lua_register(LS, "getgenv", getgenv);
  895. lua_register(LS, "getsenv", getsenv);
  896. lua_register(LS, "getrenv", getrenv);
  897. lua_register(LS, "getreg", getreg);
  898. lua_register(LS, "getfenv", getfenv);
  899. lua_register(LS, "setidentity", setidentity);
  900. lua_register(LS, "isrbxactive", isrbxactive);
  901. lua_register(LS, "error", error);
  902. lua_register(LS, "warn", warn);
  903. lua_register(LS, "setmetatable", Debug_SetMetaTable);
  904. lua_register(LS, "setfenv", Debug_SetFenv);
  905. lua_register(LS, "getmetatable", Debug_GetMetaTable);
  906. lua_register(LS, "getregistry", Debug_GetRegistry);
  907. lua_register(LS, "traceback", Debug_traceback);
  908. lua_register(LS, "getupvalues", getupvalues);
  909. lua_register(LS, "getupvalue", Debug_getupvalue);
  910. lua_register(LS, "setupvalue", Debug_setupvalue);
  911. lua_register(LS, "setlocal", setlocal);
  912. lua_register(LS, "getlocal", getlocal);
  913. lua_register(LS, "getlocals", getlocals2);
  914. lua_register(LS, "getinfo", Debug_getinfo);
  915. lua_register(LS, "mousemoverel", MouseMoveRelative);
  916. lua_register(LS, "mousemoverelative", MouseMoveRelative);
  917. lua_register(LS, "mousescroll", MouseScroll);
  918. lua_register(LS, "MouseButton1Click", Mouse1Click);
  919. lua_register(LS, "MouseButton1Press", Mouse1Down);
  920. lua_register(LS, "MouseButton1Release", Mouse1Up);
  921. lua_register(LS, "MouseButton2Click", Mouse2Click);
  922. lua_register(LS, "MouseButton2Press", Mouse2Down);
  923. lua_register(LS, "MouseButton2Release", Mouse2Up);
  924. lua_register(LS, "MouseButton1Down", Mouse1Down);
  925. lua_register(LS, "MouseButton1Up", Mouse1Up);
  926. lua_register(LS, "MouseButton2Down", Mouse2Down);
  927. lua_register(LS, "MouseButton2Up", Mouse2Up);
  928. lua_register(LS, "keypress", KeyPress);
  929. lua_register(LS, "keyrelease", KeyRelease);
  930. lua_register(LS, "keytap", KeyTap);
  931. lua_register(LS, "isready", IsReady);
  932. lua_register(LS, "hashprotect", hashProtect); // to use this function you need to add sha.cpp in ur project this is the code for that https://pastebin.com/raw/xQdrkJqf
  933. lua_register(LS, "EncodeBase64", EncodeBase64); // to use this function you need to add Base64.cpp in ur project this is the code for that https://pastebin.com/raw/2HjcFtiy
  934. lua_register(LS, "DecodeBase64", DecodeBase64); // to use this function you need to add Base64.cpp in ur project this is the code for that https://pastebin.com/raw/2HjcFtiy
  935. lua_register(LS, "EQ", EQ);
  936. lua_register(LS, "GC", GC);
Add Comment
Please, Sign In to add comment