Advertisement
Guest User

gay

a guest
Mar 20th, 2019
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 26.75 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <string>
  3. #include <iostream>
  4. #include <vector>
  5. #include "ConsoleColourProc.h"
  6. #include "MainImgui.h"
  7. #include "eyecrawl.h"
  8. #include "MinHook.h"
  9.  
  10. using namespace std;
  11. #define DLL_EXPORT extern "C" __declspec(dllexport)
  12. #define FILTER true
  13.  
  14. DWORD WINAPI LuaPipe(PVOID lvpParameter)
  15. {
  16.     string WholeScript = "";
  17.     HANDLE hPipe;
  18.     char buffer[999999];
  19.     DWORD dwRead;
  20.     hPipe = CreateNamedPipe(TEXT("\\\\.\\pipe\\AtomWrapper"),
  21.         PIPE_ACCESS_DUPLEX | PIPE_TYPE_BYTE | PIPE_READMODE_BYTE,
  22.         PIPE_WAIT,
  23.         1,
  24.         999999,
  25.         999999,
  26.         NMPWAIT_USE_DEFAULT_WAIT,
  27.         NULL);
  28.     while (hPipe != INVALID_HANDLE_VALUE)
  29.     {
  30.         if (ConnectNamedPipe(hPipe, NULL) != FALSE)
  31.         {
  32.             while (ReadFile(hPipe, buffer, sizeof(buffer) - 1, &dwRead, NULL) != FALSE)
  33.             {
  34.                 buffer[dwRead] = '\0';
  35.                 try {
  36.                     try {
  37.                         WholeScript = WholeScript + buffer;
  38.                     }
  39.                     catch (...) {
  40.                     }
  41.                 }
  42.                 catch (std::exception e) {
  43.  
  44.                 }
  45.                 catch (...) {
  46.  
  47.                 }
  48.             }
  49.             Wrapper::Execute_Script(WholeScript);
  50.             WholeScript = "";
  51.         }
  52.         DisconnectNamedPipe(hPipe);
  53.     }
  54. }
  55. void ConsoleBypass(const char* Title) {
  56.     DWORD superskiddoisachink;
  57.     VirtualProtect((PVOID)&FreeConsole, 1, PAGE_EXECUTE_READWRITE, &superskiddoisachink);
  58.     *(BYTE*)(&FreeConsole) = 0xC3;
  59.     AllocConsole();
  60.     SetConsoleTitleA(Title);
  61.     freopen("CONOUT$", "w", stdout);
  62.     freopen("CONIN$", "r", stdin);
  63.     HWND ConsoleHandle = GetConsoleWindow();
  64.     ::SetWindowPos(ConsoleHandle, HWND_TOPMOST, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
  65.     ::ShowWindow(ConsoleHandle, SW_NORMAL);
  66. }
  67.  
  68. int WrapGlobal(DWORD atom_rthread, lua_State* atom_lthread, const char* GlobalIdentity) {
  69.     r_l_getglobal(atom_rthread, GlobalIdentity);
  70.     Wrap(atom_rthread, atom_lthread, -1);
  71.     lua_setglobal(atom_lthread, GlobalIdentity);
  72.     //r_l_pop(atom_rthread, 1);
  73.     return 1;
  74. }
  75.  
  76. #include <windows.h>
  77. #include <string>
  78. #include <stdio.h>
  79. using std::string;
  80.  
  81. #pragma comment(lib,"ws2_32.lib")
  82.  
  83. HINSTANCE hInst;
  84. WSADATA wsaData;
  85. void mParseUrl(char *mUrl, string &serverName, string &filepath, string &filename);
  86. SOCKET connectToServer(char *szServerName, WORD portNum);
  87. int getHeaderLength(char *content);
  88. char *readUrl2(char *szUrl, long &bytesReturnedOut, char **headerOut);
  89.  
  90.  
  91. int r_httpget(lua_State *L)
  92. {
  93.     if (!lua_isstring(L, 1))
  94.         return 1;
  95.     const int bufLen = 1024;
  96.     const char *szUrl = lua_tostring(L, 1); // Don't mind this error, it will always error for some reason
  97.     long fileSize;
  98.     char *memBuffer, *headerBuffer;
  99.     FILE *fp;
  100.     memBuffer = headerBuffer = NULL;
  101.     if (WSAStartup(0x101, &wsaData) != 0)
  102.         return -1;
  103.     memBuffer = readUrl2((char *)szUrl, fileSize, &headerBuffer);
  104.     lua_pushstring(L, memBuffer);
  105.     if (fileSize != 0)
  106.     {
  107.         fp = fopen("downloaded.file", "wb");
  108.         fwrite(memBuffer, 1, fileSize, fp);
  109.         fclose(fp);
  110.         delete(memBuffer);
  111.         delete(headerBuffer);
  112.     }
  113.     WSACleanup();
  114.     return 1;
  115. }
  116.  
  117. void mParseUrl(char *mUrl, string &serverName, string &filepath, string &filename)
  118. {
  119.     string::size_type n;
  120.     string url = mUrl;
  121.  
  122.     if (url.substr(0, 7) == "http://")
  123.         url.erase(0, 7);
  124.  
  125.     if (url.substr(0, 8) == "https://")
  126.         url.erase(0, 8);
  127.  
  128.     n = url.find('/');
  129.     if (n != string::npos)
  130.     {
  131.         serverName = url.substr(0, n);
  132.         filepath = url.substr(n);
  133.         n = filepath.rfind('/');
  134.         filename = filepath.substr(n + 1);
  135.     }
  136.  
  137.     else
  138.     {
  139.         serverName = url;
  140.         filepath = "/";
  141.         filename = "";
  142.     }
  143. }
  144.  
  145. SOCKET connectToServer(char *szServerName, WORD portNum)
  146. {
  147.     struct hostent *hp;
  148.     unsigned int addr;
  149.     struct sockaddr_in server;
  150.     SOCKET conn;
  151.  
  152.     conn = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  153.     if (conn == INVALID_SOCKET)
  154.         return NULL;
  155.  
  156.     if (inet_addr(szServerName) == INADDR_NONE)
  157.     {
  158.         hp = gethostbyname(szServerName);
  159.     }
  160.     else
  161.     {
  162.         addr = inet_addr(szServerName);
  163.         hp = gethostbyaddr((char*)&addr, sizeof(addr), AF_INET);
  164.     }
  165.  
  166.     if (hp == NULL)
  167.     {
  168.         closesocket(conn);
  169.         return NULL;
  170.     }
  171.  
  172.     server.sin_addr.s_addr = *((unsigned long*)hp->h_addr);
  173.     server.sin_family = AF_INET;
  174.     server.sin_port = htons(portNum);
  175.     if (connect(conn, (struct sockaddr*)&server, sizeof(server)))
  176.     {
  177.         closesocket(conn);
  178.         return NULL;
  179.     }
  180.     return conn;
  181. }
  182.  
  183. int getHeaderLength(char *content)
  184. {
  185.     const char *srchStr1 = "\r\n\r\n", *srchStr2 = "\n\r\n\r";
  186.     char *findPos;
  187.     int ofset = -1;
  188.  
  189.     findPos = strstr(content, srchStr1);
  190.     if (findPos != NULL)
  191.     {
  192.         ofset = findPos - content;
  193.         ofset += strlen(srchStr1);
  194.     }
  195.  
  196.     else
  197.     {
  198.         findPos = strstr(content, srchStr2);
  199.         if (findPos != NULL)
  200.         {
  201.             ofset = findPos - content;
  202.             ofset += strlen(srchStr2);
  203.         }
  204.     }
  205.     return ofset;
  206. }
  207.  
  208. char *readUrl2(char *szUrl, long &bytesReturnedOut, char **headerOut)
  209. {
  210.     const int bufSize = 512;
  211.     char readBuffer[bufSize], sendBuffer[bufSize], tmpBuffer[bufSize];
  212.     char *tmpResult = NULL, *result;
  213.     SOCKET conn;
  214.     string server, filepath, filename;
  215.     long totalBytesRead, thisReadSize, headerLen;
  216.     mParseUrl(szUrl, server, filepath, filename);
  217.     conn = connectToServer((char*)server.c_str(), 80);
  218.     sprintf(tmpBuffer, "GET %s HTTP/1.0", filepath.c_str());
  219.     strcpy(sendBuffer, tmpBuffer);
  220.     strcat(sendBuffer, "\r\n");
  221.     sprintf(tmpBuffer, "Host: %s", server.c_str());
  222.     strcat(sendBuffer, tmpBuffer);
  223.     strcat(sendBuffer, "\r\n");
  224.     strcat(sendBuffer, "\r\n");
  225.     send(conn, sendBuffer, strlen(sendBuffer), 0);
  226.     totalBytesRead = 0;
  227.     while (1)
  228.     {
  229.         memset(readBuffer, 0, bufSize);
  230.         thisReadSize = recv(conn, readBuffer, bufSize, 0);
  231.  
  232.         if (thisReadSize <= 0)
  233.             break;
  234.  
  235.         tmpResult = (char*)realloc(tmpResult, thisReadSize + totalBytesRead);
  236.  
  237.         memcpy(tmpResult + totalBytesRead, readBuffer, thisReadSize);
  238.         totalBytesRead += thisReadSize;
  239.     }
  240.  
  241.     headerLen = getHeaderLength(tmpResult);
  242.     long contenLen = totalBytesRead - headerLen;
  243.     result = new char[contenLen + 1];
  244.     memcpy(result, tmpResult + headerLen, contenLen);
  245.     result[contenLen] = 0x0;
  246.     char *myTmp;
  247.  
  248.     myTmp = new char[headerLen + 1];
  249.     strncpy(myTmp, tmpResult, headerLen);
  250.     myTmp[headerLen] = NULL;
  251.     delete(tmpResult);
  252.     *headerOut = myTmp;
  253.  
  254.     bytesReturnedOut = contenLen;
  255.     closesocket(conn);
  256.     return(result);
  257. }
  258.  
  259. namespace Hook{
  260. void* placeHook(DWORD address, void* hook, bool revert = false) {
  261.     DWORD oldprot;
  262.     if (!revert) {
  263.         void* oldmem = new void*;
  264.         void* result = new void*;
  265.         memcpy(oldmem, (void*)address, sizeof(void*) * 4);
  266.         VirtualProtect((LPVOID)address, 1, PAGE_EXECUTE_READWRITE, &oldprot);
  267.         *(char*)address = 0xE9; *(DWORD*)(address + 1) = (DWORD)hook - address - 5;
  268.         memcpy(result, oldmem, sizeof(void*) * 4);
  269.         VirtualProtect((LPVOID)address, 1, oldprot, &oldprot);
  270.         return result;
  271.     }
  272.     else {
  273.         VirtualProtect((LPVOID)address, 1, PAGE_EXECUTE_READWRITE, &oldprot);
  274.         memcpy((void*)address, hook, sizeof(void*) * 4);
  275.         VirtualProtect((LPVOID)address, 1, oldprot, &oldprot);
  276.         return NULL;
  277.     }
  278. }
  279.  
  280. }
  281. DWORD RLSorg = 0;
  282. DWORD hookaddr = 0x7fc5f0; //gettop addr
  283.  
  284. int gettopd(DWORD rState)
  285. {
  286.     RLSorg = rState;
  287.     return (*(DWORD *)(rState + 32) - *(DWORD *)(rState + 20)) >> 4;
  288. }
  289.  
  290.  
  291.  
  292. #define ASLR(OFFSET) (OFFSET - 0x400000 + (DWORD)GetModuleHandle(NULL))
  293.  
  294. int atomwrapper_loadstring(lua_State* LS) {
  295.     if (lua_gettop(LS) == 0) {
  296.         luaL_error(LS, "'loadstring' needs 1 string argument.");
  297.         return 0;
  298.     }
  299.     Wrapper::Execute_Script(std::string(lua_tostring(LS, -1)));
  300.     return 0;
  301. }
  302.  
  303. #define SetIdentity(rL, i) DWORD* identity  = (DWORD*)(rL - 32); *identity ^= (i ^ (unsigned __int8)*identity) & 0x1F;
  304.  
  305. void yeet(){
  306.     MessageBox(NULL, "yeet", "yeet", NULL);
  307. }
  308.  
  309. static int GlobalsIndex(lua_State* Thread) {
  310.     int RThread = r_l_newthread(RLS);
  311.     r_l_getglobal(RThread, lua_tostring(Thread, 2));
  312.     if (r_l_type(RThread, -1) > R_LUA_TNIL) {
  313.         Wrap(RThread, Thread, -1);
  314.         return 1;
  315.     }
  316.     return 0;
  317. }
  318.  
  319. int AtomHideConsole(lua_State* L) {
  320.     ::ShowWindow(GetConsoleWindow(), SW_HIDE);
  321.     return 1;
  322. }
  323.  
  324. int AtomShowConsole(lua_State* L) {
  325.     ::ShowWindow(GetConsoleWindow(), SW_SHOW);
  326.     return 1;
  327. }
  328.  
  329.  
  330. int mouse1press_impl(int r_lua_State) {
  331.     INPUT input;
  332.     input.type = INPUT_MOUSE;
  333.     memset(&input.mi, 0, sizeof(MOUSEINPUT));
  334.     input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
  335.     SendInput(1, &input, sizeof(input));
  336.     return 0;
  337. }
  338.  
  339. int mouse1release_impl(int r_lua_State) {
  340.     INPUT input;
  341.     input.type = INPUT_MOUSE;
  342.     memset(&input.mi, 0, sizeof(MOUSEINPUT));
  343.     input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
  344.     SendInput(1, &input, sizeof(input));
  345.     return 0;
  346. }
  347.  
  348. int mouse1click_impl(int r_lua_State) {
  349.     INPUT input;
  350.     input.type = INPUT_MOUSE;
  351.     memset(&input.mi, 0, sizeof(MOUSEINPUT));
  352.     input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP;
  353.     SendInput(1, &input, sizeof(input));
  354.     return 0;
  355. }
  356.  
  357. int mouse2press_impl(int r_lua_State) {
  358.     INPUT input;
  359.     input.type = INPUT_MOUSE;
  360.     memset(&input.mi, 0, sizeof(MOUSEINPUT));
  361.     input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
  362.     SendInput(1, &input, sizeof(input));
  363.     return 0;
  364. }
  365.  
  366. int mouse2release_impl(int r_lua_State) {
  367.     INPUT input;
  368.     input.type = INPUT_MOUSE;
  369.     memset(&input.mi, 0, sizeof(MOUSEINPUT));
  370.     input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;
  371.     SendInput(1, &input, sizeof(input));
  372.     return 0;
  373. }
  374.  
  375. int mouse2click_impl(int r_lua_State) {
  376.     INPUT input;
  377.     input.type = INPUT_MOUSE;
  378.     memset(&input.mi, 0, sizeof(MOUSEINPUT));
  379.     input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP;
  380.     SendInput(1, &input, sizeof(input));
  381.     return 0;
  382. }
  383.  
  384. int custom_getrenv(lua_State* L) {
  385.     Wrap(RLS, L, -10002);
  386.     return 1;
  387. }
  388.  
  389. int custom_getgenv(lua_State* L) {
  390.     lua_pushvalue(L, -10002);
  391.     return 1;
  392. }
  393.  
  394. int MouseButton1Down(lua_State* L) {
  395.     INPUT input;
  396.     input.type = INPUT_MOUSE;
  397.     memset(&input.mi, 0, sizeof(MOUSEINPUT));
  398.     input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP;
  399.     SendInput(1, &input, sizeof(input));
  400.     return 0;
  401. }
  402.  
  403. int MouseButton2Down(lua_State* L) {
  404.     INPUT input;
  405.     input.type = INPUT_MOUSE;
  406.     memset(&input.mi, 0, sizeof(MOUSEINPUT));
  407.     input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP;
  408.     SendInput(1, &input, sizeof(input));
  409.     return 0;
  410. }
  411.  
  412. int MouseButton1Up(lua_State* L) {
  413.     INPUT input;
  414.     input.type = INPUT_MOUSE;
  415.     memset(&input.mi, 0, sizeof(MOUSEINPUT));
  416.     input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
  417.     SendInput(1, &input, sizeof(input));
  418.     return 0;
  419. }
  420.  
  421. int MouseButton2Up(lua_State* L) {
  422.     INPUT input;
  423.     input.type = INPUT_MOUSE;
  424.     memset(&input.mi, 0, sizeof(MOUSEINPUT));
  425.     input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;
  426.     SendInput(1, &input, sizeof(input));
  427.     return 0;
  428. }
  429.  
  430.  
  431. int custom_copyclipboard(lua_State *Ls) {
  432.     string name = lua_tostring(Ls, -1);
  433.     OpenClipboard(0);
  434.     EmptyClipboard();
  435.     HGLOBAL hg = GlobalAlloc(GMEM_MOVEABLE, name.size());
  436.     if (!hg) {
  437.         CloseClipboard();
  438.     }
  439.     memcpy(GlobalLock(hg), name.c_str(), name.size());
  440.     GlobalUnlock(hg);
  441.     SetClipboardData(CF_TEXT, hg);
  442.     CloseClipboard();
  443.     GlobalFree(hg);
  444.     return 1;
  445. }
  446.  
  447. void toClipboard(const std::string &s) {
  448.     OpenClipboard(0);
  449.     EmptyClipboard();
  450.     HGLOBAL hg = GlobalAlloc(GMEM_MOVEABLE, s.size());
  451.     if (!hg) {
  452.         CloseClipboard();
  453.         return;
  454.     }
  455.     memcpy(GlobalLock(hg), s.c_str(), s.size());
  456.     GlobalUnlock(hg);
  457.     SetClipboardData(CF_TEXT, hg);
  458.     CloseClipboard();
  459.     GlobalFree(hg);
  460. }
  461.  
  462. void fn_toclipboard(lua_State *L) {
  463.     std::string tc = lua_tostring(L, -1);
  464.     toClipboard(tc);
  465.     MessageBoxA(NULL, "Successfully copied to your clipboard!", "Done!", NULL);
  466. }
  467. typedef int (WINAPI *INDEX2ADR_DEF)(uintptr_t, int);
  468. INDEX2ADR_DEF oldi2adr = NULL;
  469. void detectRobloxClosed() {
  470.     while (true) {
  471.         if (!FindWindowA(NULL, "Roblox")) {
  472.             exit(1);
  473.         }
  474.     }
  475. }
  476.  
  477. void initChecks() {
  478.     __asm {
  479.         jmp detectRobloxClosed;
  480.     }
  481. }
  482. /*
  483. union r_Value
  484. {
  485.     int b;
  486.     double n;
  487.     void* p;
  488.     void* gc;
  489. };
  490.  
  491. struct r_TValue
  492. {
  493.     r_Value value;
  494.     int tt;
  495. };
  496.  
  497. r_TValue* r_gettop(int r_lua_State) {
  498.     return *(r_TValue**)(r_lua_State + 16);
  499.  
  500. }
  501.  
  502. int setreadonly_impl(lua_State* r_lua_State) {
  503.     if (r_l_gettop(RLS) < 1) {
  504.         r_l_pushboolean(RLS, 0);
  505.         r_l_pushstring(RLS, "2 or more arguments expected");
  506.         return 2;
  507.     }
  508.  
  509.     r_TValue* top = r_gettop(RLS);
  510.     r_TValue* b = top - 1;
  511.     r_TValue* obj = top - 2;
  512.  
  513.     if (obj->tt != R_LUA_TTABLE) {
  514.         r_l_pushboolean(RLS, 0);
  515.         r_l_pushstring(RLS, "table expected");
  516.         return 2;
  517.     }
  518.  
  519.     if (b->tt != R_LUA_TBOOLEAN) {
  520.         r_l_pushboolean(RLS, 0);
  521.         r_l_pushstring(RLS, "boolean expected");
  522.         return 2;
  523.     }
  524.  
  525.     *(unsigned char*)(obj->value_0 + 6) = b->value_0;
  526.     r_l_pushboolean(RLS, 1);
  527.     return 1;
  528. }
  529.  
  530.  
  531.  
  532.  
  533. int isreadonly_impl(lua_State* r_lua_State) {
  534.     if (r_l_gettop(m_rL) < 1) {
  535.         r_l_pushnil(m_rL);
  536.         r_l_pushstring(m_rL, "1 or more arguments expected");
  537.         return 2;
  538.     }
  539.  
  540.     r_TValue* top = r_gettop(m_rL);
  541.     r_TValue* obj = top - 1;
  542.  
  543.     if (obj->tt != RLUA_TTABLE) {
  544.         r_l_pushnil(m_rL);
  545.         r_l_pushstring(m_rL, "table expected");
  546.         return 2;
  547.     }
  548.  
  549.  
  550.     r_l_pushboolean(m_rL, (int)*(unsigned char*)(obj->value_0 + 6));
  551.     return 1;
  552. }
  553. */
  554.  
  555. /*int a1 = rand() % 1 + 1;
  556. XorS(YEETKEY, "YIELD FUNCTION HANDLER");
  557. XorS(AESKEY, "VRN9fuJHcgmnV/9DLXUe2TE4qLHl80+AaiqbxfZSjW0wv6aoA"+'='+'=');
  558. std::vector<std::string> keyorder = {AESKEY.decrypt(), "SkSDoBk8yYidbKVWnRCSq4jvLoUQjTGNPkofz" };*/
  559.  
  560. int SecureScript(lua_State* thread) {
  561.     int begin = 0;
  562.     std::string endstr = "";
  563.     std::string str = lua_tostring(thread, -1);
  564.     for (char& c : str) {;
  565.         if (begin < 1) {
  566.             cout << c << endl;
  567.             endstr.push_back(c);
  568.             begin++;
  569.         }
  570.         else {
  571.             begin = 0;
  572.         }
  573.         cout << endstr << endl;
  574.     }
  575.     return 1;
  576. }
  577.  
  578. int SecureEncrypt(lua_State* thread) {
  579.     return 1;
  580. }
  581.  
  582. int cerror(lua_State* thread) {
  583.  
  584.     return 1;
  585. }
  586.  
  587. int movemouse(lua_State* thread) {
  588.     int x = lua_tonumber(thread, -1);
  589.     int y = lua_tonumber(thread, -2);
  590.     POINT p;
  591.     if (GetCursorPos(&p))
  592.     {
  593.         SetCursorPos(p.x + x, p.y + y);
  594.     }
  595.  
  596.     return 1;
  597. }
  598.  
  599. //int movemouse(lua_State* thread) {
  600. //
  601. //  POINT p;
  602. //  GetCursorPos(&p);
  603. //  int curx = p.x;
  604. //  int cury = p.y;
  605. //
  606. //  int x = lua_tonumber(thread, -1);
  607. //  int y = lua_tonumber(thread, -1);
  608. //
  609. //  INPUT input;
  610. //  input.type = INPUT_MOUSE;
  611. //  memset(&input.mi, 0, sizeof(MOUSEINPUT));
  612. //  input.mi.dx = curx + x;
  613. //  input.mi.dy = cury + y;
  614. //  input.mi.dwFlags = MOUSEEVENTF_MOVE;
  615. //  SendInput(1, &input, sizeof(INPUT));
  616. //
  617. //  return 1;
  618. //}
  619.  
  620.  
  621. int IndexGetRawMetatable(lua_State *L) {
  622.     DWORD luaState = RLS;
  623.     double Num = lua_tonumber(L, lua_upvalueindex(1));
  624.     printf("index calledd1\n");
  625.     r_l_rawgeti(luaState, LUA_REGISTRYINDEX, Num);
  626.     r_l_getmetatable(luaState, -1);
  627.     r_l_getfield(RLS, -1, lua_tostring(L, -1));
  628.     UnWrap(L, luaState, -1);
  629.     r_l_settop(RLS, 0);
  630.     return 1;
  631. }
  632.  
  633. int NewINdexGetRawmetatble(lua_State *L) {
  634.     DWORD luaState = RLS;
  635.     double Num = lua_tonumber(L, lua_upvalueindex(1));
  636.     const char* key = lua_tostring(L, -2);
  637.     printf("key: %s\n", key);
  638.     r_l_rawgeti(luaState, LUA_REGISTRYINDEX, Num);
  639.     r_l_getmetatable (luaState, -1);
  640.     r_l_pushstring(luaState, key);
  641.     UnWrap(L, RLS, -1);
  642.     r_l_settable(luaState, -3);
  643.     r_l_settop(RLS, -2);
  644.     return 1;
  645. }
  646.  
  647. int GetRawMetaTable(lua_State *L) {
  648.     UnWrap(L, RLS, -1);
  649.     if (r_l_getmetatable(RLS, -1) == 0) {
  650.         lua_pushnil(L);
  651.         return 0;
  652.     }
  653.     r_l_SRO(RLS, -1, 0);
  654.     int num = r_l_lref (RLS, LUA_REGISTRYINDEX);
  655.     lua_newtable(L);
  656.     lua_newtable(L);
  657.     lua_pushnumber(L, num);
  658.     lua_pushcclosure(L, IndexGetRawMetatable, 1);
  659.     lua_setfield(L, -2, "__index");
  660.     lua_pushnumber(L, num);
  661.     lua_pushcclosure(L, NewINdexGetRawmetatble, 1);
  662.     lua_setfield(L, -2, "__newindex");
  663.     lua_setmetatable(L, -2);
  664.     return 1;
  665. }
  666.  
  667. typedef struct r_TValue1 {
  668.     int value_0;
  669.     int value_1;
  670.     int tt;
  671.     int unk;
  672. };
  673.  
  674.  
  675.  
  676.  
  677.  
  678. r_TValue1* r_gettop(int r_lua_State) {
  679.     return *(r_TValue1**)(r_lua_State + 16);
  680. }
  681.  
  682. int custom_setreadonly(lua_State* thread) {
  683.     lua_gettable(thread, -1);
  684.     r_l_SRO(RLS, 1, lua_toboolean(LS, -2));
  685.  
  686.     return 0;
  687. }
  688.  
  689.  
  690. int printtoconsole(lua_State* thread) {
  691.     std::string msg = lua_tostring(thread, -1);
  692.     cout << iblue << "[AtomWrapper] " + msg << endl;
  693.     return 1;
  694. }
  695.  
  696. int Lua_WrapGlobal(lua_State* thread) {
  697.     std::string globalName = lua_tostring(thread, -1);
  698.     WrapGlobal(RLS, LS, globalName.c_str());
  699.     cout << iblue << "Wrapped Global: " + globalName << endl;
  700.     return 1;
  701. }
  702.  
  703. int error(lua_State* thread) {
  704.     std::string errorstr = lua_tostring(thread, -1);
  705.     int type = lua_tonumber(thread, -2);
  706.     std::string finalerror = "warn('"; finalerror = finalerror + errorstr; finalerror = finalerror + "')";
  707.     luaL_dostring(thread, finalerror.c_str());
  708.  
  709.     return 1;
  710. }
  711.  
  712. int TestFunc(lua_State* L) {
  713.     cout << "hi" << endl;
  714.     return 1;
  715. }
  716.  
  717.  
  718. int main(){
  719.     XorS(ConsoleName, "AtomWrapper | Level 6 Unrestricted Lua Wrapper");
  720.     ConsoleBypass(ConsoleName.decrypt());
  721.  
  722.     cout << ipurple << "--Credits--\nDeveloper: RoboMat\nUpdating: ElKoax" << endl;
  723.     DWORD stuff;
  724.     VirtualProtect((LPVOID)&FindWindowA, 1, PAGE_EXECUTE_READWRITE, &stuff);
  725.     *(char*)&FindWindowA = 0x90;
  726.     VirtualProtect((LPVOID)&FindWindowA, 1, stuff, &stuff);
  727.  
  728.  
  729.  
  730.     cout << ipurple << "Hooking...";
  731.     void* old = Hook::placeHook(ASLR(hookaddr), gettopd);
  732.     do { Sleep(1); } while (RLSorg == 0);
  733.     Hook::placeHook(ASLR(hookaddr), old, 1);
  734.     RLS = RLSorg;
  735.     std::cout << igreen << "Success!" << endl;
  736.    
  737.  
  738.     LS = lua_open();
  739.     Int3BreakPoints();
  740.     luaL_openlibs(LS);
  741.     SetIdentity(RLS, 6);
  742.  
  743.     cout << iblue << "Creating Environment...";
  744.  
  745.  
  746.  
  747.  
  748.     //Globals
  749.  
  750.     WrapGlobal(RLS, LS, "game");
  751.     WrapGlobal(RLS, LS, "Game");
  752.     WrapGlobal(RLS, LS, "workspace");
  753.     WrapGlobal(RLS, LS, "Workspace");
  754.     WrapGlobal(RLS, LS, "Axes");
  755.     WrapGlobal(RLS, LS, "BrickColor");
  756.     WrapGlobal(RLS, LS, "CFrame");
  757.     WrapGlobal(RLS, LS, "Color3");
  758.     WrapGlobal(RLS, LS, "ColorSequence");
  759.     WrapGlobal(RLS, LS, "ColorSequenceKeypoint");
  760.     WrapGlobal(RLS, LS, "NumberRange");
  761.     WrapGlobal(RLS, LS, "NumberSequence");
  762.     WrapGlobal(RLS, LS, "NumberSequenceKeypoint");
  763.     WrapGlobal(RLS, LS, "PhysicalProperties");
  764.     WrapGlobal(RLS, LS, "Ray");
  765.     WrapGlobal(RLS, LS, "Rect");
  766.     WrapGlobal(RLS, LS, "Region3");
  767.     WrapGlobal(RLS, LS, "Region3int16");
  768.     WrapGlobal(RLS, LS, "TweenInfo");
  769.     WrapGlobal(RLS, LS, "UDim");
  770.     WrapGlobal(RLS, LS, "UDim2");
  771.     WrapGlobal(RLS, LS, "Vector2");
  772.     WrapGlobal(RLS, LS, "Vector2int16");
  773.     WrapGlobal(RLS, LS, "Vector3");
  774.     WrapGlobal(RLS, LS, "Vector3int16");
  775.     WrapGlobal(RLS, LS, "Enum");
  776.     WrapGlobal(RLS, LS, "Faces");
  777.     WrapGlobal(RLS, LS, "Instance");
  778.     WrapGlobal(RLS, LS, "math");
  779.     WrapGlobal(RLS, LS, "warn");
  780.     WrapGlobal(RLS, LS, "typeof");
  781.     WrapGlobal(RLS, LS, "type");
  782.     WrapGlobal(RLS, LS, "spawn");
  783.     WrapGlobal(RLS, LS, "Spawn");
  784.     WrapGlobal(RLS, LS, "print");
  785.     WrapGlobal(RLS, LS, "printidentity");
  786.     WrapGlobal(RLS, LS, "ypcall");
  787.     WrapGlobal(RLS, LS, "Wait");
  788.     WrapGlobal(RLS, LS, "wait");
  789.     WrapGlobal(RLS, LS, "delay");
  790.     WrapGlobal(RLS, LS, "Delay");
  791.     WrapGlobal(RLS, LS, "tick");
  792.     WrapGlobal(RLS, LS, "LoadLibrary");
  793.     //Globals
  794.  
  795.  
  796.  
  797.     cout << iblue << "Starting userdata caching system...";
  798.     std::cout << igreen << "Success!" << endl;
  799.     cout << iblue << "Creating AtomWrapper Custom Global Tables...";
  800.     std::cout << igreen << "Success!" << endl;
  801.  
  802.     XorS(FilterCheck, "_FILTERED = true");
  803.     luaL_dostring(LS, FilterCheck.decrypt()); //filtered check
  804.  
  805.     lua_newtable(LS);
  806.     lua_setglobal(LS, "_G");
  807.  
  808.     /*
  809.     AtomWrapper Custom Globals
  810.     */
  811.     lua_newtable(LS);
  812.     lua_setglobal(LS, "_AG");
  813.  
  814.     lua_register(LS, "WrapGlobal", Lua_WrapGlobal);
  815.     lua_register(LS, "printconsole", printtoconsole);
  816.     lua_register(LS, "getrawmetatable", GetRawMetaTable);
  817.     lua_register(LS, "SecureScript", SecureScript);
  818.     lua_register(LS, "SecureEncrypt", SecureEncrypt);
  819.     lua_register(LS, "ShowConsole", AtomShowConsole);
  820.     lua_register(LS, "HideConsole", AtomHideConsole);
  821.     lua_register(LS, "loadstring", atomwrapper_loadstring);
  822.     lua_register(LS, "HttpGet", r_httpget);
  823.     lua_register(LS, "getrenv", custom_getrenv);
  824.     lua_register(LS, "getgenv", custom_getgenv);
  825.     lua_register(LS, "setreadonly", custom_setreadonly);
  826.     lua_register(LS, "mousemoverel", movemouse);
  827.     lua_register(LS, "error", error);
  828.     luaL_dostring(LS, "function GetObjects(assetId)\r\n    local obj = game:GetService(\"InsertService\"):LoadLocalAsset(assetId)\r\n    return { obj };\r\nend\r\n\r\nfunction ensure(obj)\r\n    for _,child in pairs(obj:GetChildren()) do\r\n        if (child.ClassName == \"LocalScript\") then\r\n            loadstring(child.Source)();\r\n            ensure(child);\r\n        else\r\n            ensure(child);\r\n        end\r\n    end\r\nend\r\n\r\n");
  829.     luaL_dostring(LS, "game.StarterGui:SetCore('SendNotification', {Duration = 10; Title='AtomWrapper'; Text='AtomWrapper Injected'})");
  830.     Functions::RegisterDebugFunctions(LS);
  831.     Functions::RegisterFuncs(LS);
  832.  
  833.  
  834.     //Wrapper::Execute_Script(DownloadURL("https://pastebin.com/raw/Vszxg7Pc"));
  835.     XorS(credits, "AtomWrapper is now ready for use created by RoboMat and ELKOAX");
  836.     cout << igreen << credits.decrypt() << endl;
  837. //  ShowWindow(GetConsoleWindow(), SW_HIDE);
  838.     CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)LuaPipe, NULL, NULL, NULL);
  839.     cout << iblue << "Starting ImGui thread..." << endl;
  840.     CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)InitImgui, NULL, NULL, NULL);
  841.  
  842.     return 1;
  843. }
  844.  
  845.  
  846. unsigned int ProtectSections(HMODULE Module
  847. ) {
  848.     MODULEINFO ModuleInfo;
  849.     GetModuleInformation(GetCurrentProcess(), Module, &ModuleInfo, sizeof(ModuleInfo));
  850.     uintptr_t Address = reinterpret_cast<uintptr_t>(Module);
  851.     uintptr_t TermAddress = Address + ModuleInfo.SizeOfImage;
  852.     MEMORY_BASIC_INFORMATION MemoryInfo;
  853.  
  854.  
  855.     while (Address < TermAddress) {
  856.         VirtualQuery(reinterpret_cast<void*>(Address), &MemoryInfo, sizeof(MemoryInfo));
  857.         if (MemoryInfo.State == MEM_COMMIT && (MemoryInfo.Protect & (PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY))) {
  858.             DWORD OldProtection;
  859.             VirtualProtect(reinterpret_cast<void*>(Address), MemoryInfo.RegionSize, PAGE_EXECUTE_READ, &OldProtection);
  860.         }
  861.         Address = reinterpret_cast<uintptr_t>(MemoryInfo.BaseAddress) + MemoryInfo.RegionSize;
  862.     }
  863.  
  864.     VirtualQuery(reinterpret_cast<void*>(MemoryInfo.AllocationBase), &MemoryInfo, sizeof(MemoryInfo));
  865.     if (MemoryInfo.State != MEM_COMMIT || !(MemoryInfo.Protect & PAGE_EXECUTE_READ))
  866.         return 0x400;
  867.     return MemoryInfo.RegionSize - 0x400;
  868. }
  869.  
  870.  
  871. __forceinline void UnlinkModule(HINSTANCE Module
  872. ) {
  873.     unsigned long PEB_DATA = 0;
  874.     _asm {
  875.         pushad;
  876.         pushfd;
  877.         mov eax, fs:[30h]
  878.             mov eax, [eax + 0Ch]
  879.             mov PEB_DATA, eax
  880.  
  881.             InLoadOrderModuleList :
  882.         mov esi, [eax + 0Ch]
  883.             mov edx, [eax + 10h]
  884.  
  885.             LoopInLoadOrderModuleList :
  886.             lodsd
  887.             mov esi, eax
  888.             mov ecx, [eax + 18h]
  889.             cmp ecx, Module
  890.             jne SkipA
  891.             mov ebx, [eax]
  892.             mov ecx, [eax + 4]
  893.             mov[ecx], ebx
  894.             mov[ebx + 4], ecx
  895.             jmp InMemoryOrderModuleList
  896.  
  897.             SkipA :
  898.         cmp edx, esi
  899.             jne LoopInLoadOrderModuleList
  900.  
  901.             InMemoryOrderModuleList :
  902.         mov eax, PEB_DATA
  903.             mov esi, [eax + 14h]
  904.             mov edx, [eax + 18h]
  905.  
  906.             LoopInMemoryOrderModuleList :
  907.             lodsd
  908.             mov esi, eax
  909.             mov ecx, [eax + 10h]
  910.             cmp ecx, Module
  911.             jne SkipB
  912.             mov ebx, [eax]
  913.             mov ecx, [eax + 4]
  914.             mov[ecx], ebx
  915.             mov[ebx + 4], ecx
  916.             jmp InInitializationOrderModuleList
  917.  
  918.             SkipB :
  919.         cmp edx, esi
  920.             jne LoopInMemoryOrderModuleList
  921.  
  922.             InInitializationOrderModuleList :
  923.         mov eax, PEB_DATA
  924.             mov esi, [eax + 1Ch]
  925.             mov edx, [eax + 20h]
  926.  
  927.             LoopInInitializationOrderModuleList :
  928.             lodsd
  929.             mov esi, eax
  930.             mov ecx, [eax + 08h]
  931.             cmp ecx, Module
  932.             jne SkipC
  933.             mov ebx, [eax]
  934.             mov ecx, [eax + 4]
  935.             mov[ecx], ebx
  936.             mov[ebx + 4], ecx
  937.             jmp Finished
  938.  
  939.             SkipC :
  940.         cmp edx, esi
  941.             jne LoopInInitializationOrderModuleList
  942.  
  943.             Finished :
  944.         popfd;
  945.         popad;
  946.     }
  947. }
  948.  
  949.  
  950. BOOL APIENTRY DllMain(HMODULE Module, DWORD Reason, void* Reserved)
  951. {
  952.     switch (Reason)
  953.     {
  954.     case DLL_PROCESS_ATTACH:
  955.         DisableThreadLibraryCalls(Module);
  956.         UnlinkModule(Module);
  957.         DWORD OldProtection;
  958.         VirtualProtect(Module, 4096, PAGE_READWRITE, &OldProtection);
  959.         ZeroMemory(Module, 4096);
  960.         ProtectSections(Module);
  961.         HANDLE hThread = NULL;
  962.         HANDLE hDllMainThread = OpenThread(THREAD_ALL_ACCESS, NULL, GetCurrentThreadId());
  963.         if (Reserved == NULL) {
  964.             if (!(hThread = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)main, NULL, NULL, NULL))) {
  965.                 CloseHandle(hDllMainThread);
  966.                 return FALSE;
  967.             }
  968.             CloseHandle(hThread);
  969.         }
  970.         return TRUE;
  971.     }
  972. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement