Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. /* credits to austin for these two functions */
  2. int sw_ReadFile(const std::string& path, std::string& out, unsigned char binary) {
  3. std::ios::openmode mode = std::ios::in;
  4. if (binary)
  5. mode |= std::ios::binary;
  6.  
  7. std::ifstream file(path, mode);
  8. if (file.is_open()) {
  9. std::stringstream buffer;
  10. buffer << file.rdbuf();
  11. out = buffer.str();
  12. file.close();
  13. return 1;
  14. }
  15.  
  16. file.close();
  17. return 0;
  18. }
  19.  
  20. void get_file(const char* dllName, const char* fileName, char* buffer, int bfSize) {
  21. GetModuleFileName(GetModuleHandle(dllName), buffer, bfSize);
  22. if (strlen(fileName) + strlen(buffer) < MAX_PATH) {
  23. char* pathEnd = strrchr(buffer, '\\');
  24. strcpy(pathEnd + 1, fileName);
  25. }
  26. else {
  27. *buffer = 0;
  28. }
  29. }
  30. void GetFilesInDirectory(std::vector<std::string>& out, const std::string& directory, unsigned char includePath) // thx stackoverflow
  31. {
  32. HANDLE dir;
  33. WIN32_FIND_DATA file_data;
  34.  
  35. if ((dir = FindFirstFile((directory + "/*").c_str(), &file_data)) == INVALID_HANDLE_VALUE)
  36. return; /* No files found */
  37.  
  38. do {
  39. const std::string file_name = file_data.cFileName;
  40. const std::string full_file_name = directory + "/" + file_name;
  41. const bool is_directory = (file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
  42.  
  43. if (file_name[0] == '.')
  44. continue;
  45.  
  46. if (is_directory)
  47. continue;
  48.  
  49. out.push_back(includePath ? full_file_name : file_name);
  50. } while (FindNextFile(dir, &file_data));
  51.  
  52. FindClose(dir);
  53. }
  54. void GetFile(const char* dllName, const char* fileName, char* buffer, int bfSize) {
  55. GetModuleFileName(GetModuleHandle(dllName), buffer, bfSize);
  56. if (strlen(fileName) + strlen(buffer) < MAX_PATH) {
  57. char* pathEnd = strrchr(buffer, '\\');
  58. strcpy(pathEnd + 1, fileName);
  59. }
  60. else {
  61. *buffer = 0;
  62. }
  63. }
  64. int ReadFile(const std::string& path, std::string& out, unsigned char binary) {
  65. std::ios::openmode mode = std::ios::in;
  66. if (binary)
  67. mode |= std::ios::binary;
  68.  
  69. std::ifstream file(path, mode);
  70. if (file.is_open()) {
  71. std::stringstream buffer;
  72. buffer << file.rdbuf();
  73. out = buffer.str();
  74. file.close();
  75. return 1;
  76. }
  77.  
  78. file.close();
  79. return 0;
  80. }
  81.  
  82.  
  83.  
  84. int WriteFile(const std::string& path, std::string data, unsigned char binary) {
  85. std::ios::openmode mode = std::ios::out;
  86. if (binary)
  87. mode |= std::ios::binary;
  88.  
  89. std::ofstream file(path, mode);
  90. if (file.is_open()) {
  91. file << data;
  92. file.close();
  93. return 1;
  94. }
  95.  
  96. file.close();
  97. return 0;
  98. }
  99.  
  100.  
  101.  
  102. int gethpath(lua_State* r_lua_State) {
  103. char path[MAX_PATH];
  104. GetFile("HaxonByteCode.dll", "", path, MAX_PATH);
  105.  
  106. lua_pushstring(r_lua_State, path);
  107. return 1;
  108. }
  109.  
  110. void modifyrbx()
  111. {
  112. //sloppey's findwindowa bypass
  113. DWORD old;
  114. VirtualProtect((LPVOID)& FindWindowA, 1, PAGE_EXECUTE_READWRITE, &old);
  115. *(char*)& FindWindowA = 0x90;
  116. VirtualProtect((LPVOID)& FindWindowA, 1, old, &old);
  117. SetWindowTextA(FindWindowA(NULL, "Roblox"), "Exploited with Haxon!");
  118. }
  119.  
  120. int readfile(lua_State* L) {
  121. string _path = (string)lua_tostring(L, 1);
  122. gethpath(L);
  123.  
  124. // TODO FIX
  125. string ok = (string)lua_tostring(L, -1);
  126. char pls1[100]; // array to hold the result.
  127.  
  128. strcpy(pls1, ok.c_str()); // copy string one into the result.
  129. strcat(pls1, "workspace\\");
  130.  
  131. char path[100]; // array to hold the result.
  132. strcpy(path, pls1); // copy string one into the result.
  133. strcat(path, _path.c_str());
  134.  
  135.  
  136. string _checkFile(path);
  137.  
  138.  
  139. string filecontents;
  140. if (!ReadFile(path, filecontents, 0)) {
  141. lua_pushnil(L);
  142. printf("Failed to read file. (%x\n)", filecontents);
  143. return 1;
  144. }
  145.  
  146. lua_pushstring(L, filecontents.c_str());
  147.  
  148. return 1;
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement