pastebin - collaborative debugging tool
rovema.kpaste.net RSS


hello_system_world.cpp - not working yet
Posted by Anonymous on Mon 18th Sep 2023 17:18
raw | new post

  1. #include <stdio.h>
  2. #include <windows.h>
  3. #include <iostream>
  4. #include <string>
  5.  
  6. void get_file_size(std::string path)
  7. {
  8.     struct _stat fileinfo;
  9.     _stat(path.c_str(), &fileinfo);
  10.     std::cout << "file size is " << fileinfo.st_size << std::endl;
  11. }
  12. int main()
  13. {
  14.     HANDLE  tokenHandle;
  15.     puts("#mark0");
  16.     bool returnValue = LogonUserA("SYSTEM", NULL, "tiGGkra#HKrahs", LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &tokenHandle);
  17.     if (false == returnValue) {
  18.         return 1;
  19.     }
  20.     puts("#mark1");
  21.     bool res = ImpersonateLoggedOnUser(tokenHandle);
  22.     if (res)
  23.     {
  24.         std::string path = "C:\\cygwin64\\bin\\getent.exe";
  25.         puts("#mark2");
  26.         get_file_size(path);
  27.         system("C:\\cygwin64\\bin\\id.exe -a");
  28.         RevertToSelf();
  29.     }
  30.     puts("#mark3");
  31.     CloseHandle(tokenHandle);
  32.     return 0;
  33. }

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at