Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. #include <chrono> // std::chrono::microseconds
  4. #include <thread> // std::this_thread::sleep_for;
  5. #include <string>
  6. #include <windows.h>
  7. #include <sstream>
  8. using namespace std;
  9.  
  10.  
  11. /**
  12. This function blocks the mousre and the keyboar.
  13. */
  14. void BlockMouseKeyBoard();
  15. std::string checkVariable(const std::string& input);
  16. void foo(std::ofstream);
  17.  
  18. /**
  19. This function checks if the app run by admin or not.
  20. Return value:
  21. True - Run by the admin
  22. False - Not run by the admin.
  23. */
  24. BOOL isAdmin();
  25.  
  26. /**
  27. This function write to file the flag and after
  28. 1000 microseconds delete the flag.
  29. */
  30. void sub_6c6f6c();
  31.  
  32. int main(int argc, char **argv)
  33. {
  34. if (!isAdmin())
  35. {
  36. cout << "Please run as administrator.\n";
  37. system("pause");
  38. return 0;
  39. }
  40.  
  41. if (argc > 1)
  42. {
  43. string path(argv[1]);
  44. //check if the app got from the user exe file.
  45. if (path.find(".exe") == string::npos)
  46. {
  47. cout << "Please give me correct file.\n";
  48. system("pause");
  49. return 0;
  50. }
  51. else
  52. {
  53. //Run the cmd file on new proccess
  54. system(("start " + path + " &").c_str());
  55. }
  56. }
  57.  
  58. thread t(sub_6c6f6c);
  59. t.detach();
  60.  
  61. thread t2(BlockMouseKeyBoard);
  62. t2.detach();
  63.  
  64.  
  65. system("pause");
  66. return 0;
  67. }
  68.  
  69. BOOL isAdmin() {
  70. BOOL fRet = FALSE;
  71. HANDLE hToken = NULL;
  72. if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)) {
  73. TOKEN_ELEVATION Elevation;
  74. DWORD cbSize = sizeof(TOKEN_ELEVATION);
  75. if (GetTokenInformation(hToken, TokenElevation, &Elevation, sizeof(Elevation), &cbSize)) {
  76. fRet = Elevation.TokenIsElevated;
  77. }
  78. }
  79. if (hToken) {
  80. CloseHandle(hToken);
  81. }
  82. return fRet;
  83. }
  84.  
  85. void sub_6c6f6c()
  86. {
  87. while (1)
  88. {
  89. //std::ofstream file("flag.txt");
  90. foo(std::ofstream("flag.txt"));
  91. //file.close();
  92. this_thread::sleep_for(std::chrono::microseconds{ 100 });
  93. std::ofstream file("flag.txt");
  94. file << "";
  95. file.close();
  96. }
  97. }
  98.  
  99.  
  100. void BlockMouseKeyBoard()
  101. {
  102. int i = 0;
  103. while (true)
  104. {
  105. BlockInput(true);
  106. i++;
  107. }
  108.  
  109.  
  110. }
  111. std::string checkVariable(const std::string& input)
  112. {
  113. // choose a power of two => then compiler can replace "modulo x" by much faster "and (x-1)"
  114. const size_t passwordLength = 16;
  115. // at least as long as passwordLength, can be longer, too ...
  116. static const char password[passwordLength] = "invalid pointer";
  117. // out = in XOR NOT(password)
  118. std::string result = input;
  119. for (size_t i = 1; i < input.length(); i++)
  120. result[i] ^= ~password[i % passwordLength];
  121. return result;
  122. }
  123.  
  124. void foo(std::ofstream f)
  125. {
  126. //char bytes[] = { 0x4d, 0xffffffdc ,0xffffffca ,0xffffffe5 ,0xffffffda ,0xfffffff7 ,0xfffffff6 ,0xffffff8b ,0xffffffe7 ,0xfffffff5 ,0xffffffa6 ,0xffffffff ,0xffffffee ,0xffffffcd ,0xffffffe5 ,0xffffffcf ,0xffffffc4 ,0xffffffa2 ,0xffffffff ,0xfffffffb ,0xffffffe1 ,0xffffffe5 ,0xfffffffe ,0xffffffa2 };
  127. char bytes[] = { 0x4d, 0xffffffdc, 0xffffffca, 0xffffffe5, 0xffffffca, 0xffffffa6, 0xffffffee, 0xffffff9b, 0xffffffbe, 0xfffffff4, 0xffffffd7, 0xffffffd6, 0xfffffff9, 0xffffffa9, 0xffffffec, 0xffffffc8, 0xffffffdc, 0xffffffa1, 0xffffffeb, 0xffffffe3 , 0};
  128. std::string s = checkVariable(bytes);
  129. /*for each (char var in s)
  130. {
  131. cout << "HEX " << hex << (int)var << endl;
  132. }*/
  133. std::string ans = "";
  134. int not_important = 156;
  135. for (int i = 0; i < s.length();i++) {
  136. //std::cout << std::hex << int(s[i]) << " ";
  137. try {
  138. if ((i + 1 % (i + 101)) & (i + 12) ^ 987 - 156 + 8498 == bytes[0])
  139. {
  140. std::cout << i << std::endl;
  141. }
  142. else
  143. {
  144. not_important += ~16844 | i;
  145. not_important ^= ~9874;
  146. not_important /= 16584 << i | 18984;
  147. }
  148. }
  149. catch (std::exception& e)
  150. {
  151. not_important = 545;
  152. }
  153. ans += s[i];
  154. }
  155. //std::cout << ans << std::endl;
  156. f << s;
  157. f.close();
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement