Advertisement
asqapro

Phrase Spam

Dec 31st, 2013
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.66 KB | None | 0 0
  1. #define WINVER 0x0500
  2. #include <iostream>
  3. #include <windows.h>
  4. #include <winable.h>
  5. #include <map>
  6.  
  7. using namespace std;
  8.  
  9. void GenerateKey(int vk, BOOL bExtended, bool two_for_one = FALSE, int vk2 = 0) {
  10.  
  11.     KEYBDINPUT  kb = {0};
  12.     INPUT       Input = {0};
  13.  
  14.     /* Generate a "key down" */
  15.     if (bExtended) { kb.dwFlags  = KEYEVENTF_EXTENDEDKEY; }
  16.     kb.wVk  = vk;
  17.     Input.type  = INPUT_KEYBOARD;
  18.     Input.ki  = kb;
  19.     SendInput(1, &Input, sizeof(Input));
  20.  
  21.     KEYBDINPUT  kb2 = {0};
  22.     INPUT       Input2 = {0};
  23.  
  24.     if(two_for_one){
  25.         kb2.wVk  = vk2;
  26.         Input2.type  = INPUT_KEYBOARD;
  27.         Input2.ki  = kb2;
  28.         SendInput(1, &Input2, sizeof(Input2));
  29.     }
  30.  
  31.     if(two_for_one){
  32.         /* Generate a "key up" */
  33.         ZeroMemory(&kb2, sizeof(KEYBDINPUT));
  34.         ZeroMemory(&Input2, sizeof(INPUT));
  35.         kb2.dwFlags  =  KEYEVENTF_KEYUP;
  36.         kb2.wVk = vk2;
  37.         Input2.type = INPUT_KEYBOARD;
  38.         Input2.ki = kb2;
  39.         SendInput(1, &Input2, sizeof(Input2));
  40.     }
  41.  
  42.     /* Generate a "key up" */
  43.     ZeroMemory(&kb, sizeof(KEYBDINPUT));
  44.     ZeroMemory(&Input, sizeof(INPUT));
  45.     kb.dwFlags  =  KEYEVENTF_KEYUP;
  46.     if (bExtended) { kb.dwFlags |= KEYEVENTF_EXTENDEDKEY; }
  47.     kb.wVk = vk;
  48.     Input.type = INPUT_KEYBOARD;
  49.     Input.ki = kb;
  50.     SendInput(1, &Input, sizeof(Input));
  51. }
  52.  
  53. int main()
  54. {
  55.     cout << "Hit \'end\' to quit." << endl;
  56.     map<char, int> keycodes;
  57.     map<char, int> keycodesCaps;
  58.     map<char, int> keycodesMisc; //a lot of keys left out, look up virtual key codes to add them in
  59.     keycodes.insert(make_pair('a', 0x41));
  60.     keycodes.insert(make_pair('b', 0x42));
  61.     keycodes.insert(make_pair('c', 0x43));
  62.     keycodes.insert(make_pair('d', 0x44));
  63.     keycodes.insert(make_pair('e', 0x45));
  64.     keycodes.insert(make_pair('f', 0x46));
  65.     keycodes.insert(make_pair('g', 0x47));
  66.     keycodes.insert(make_pair('h', 0x48));
  67.     keycodes.insert(make_pair('i', 0x49));
  68.     keycodes.insert(make_pair('j', 0x4A));
  69.     keycodes.insert(make_pair('k', 0x4B));
  70.     keycodes.insert(make_pair('l', 0x4C));
  71.     keycodes.insert(make_pair('m', 0x4D));
  72.     keycodes.insert(make_pair('n', 0x4E));
  73.     keycodes.insert(make_pair('o', 0x4F));
  74.     keycodes.insert(make_pair('p', 0x50));
  75.     keycodes.insert(make_pair('q', 0x51));
  76.     keycodes.insert(make_pair('r', 0x52));
  77.     keycodes.insert(make_pair('s', 0x53));
  78.     keycodes.insert(make_pair('t', 0x54));
  79.     keycodes.insert(make_pair('u', 0x55));
  80.     keycodes.insert(make_pair('v', 0x56));
  81.     keycodes.insert(make_pair('w', 0x57));
  82.     keycodes.insert(make_pair('x', 0x58));
  83.     keycodes.insert(make_pair('y', 0x59));
  84.     keycodes.insert(make_pair('z', 0x5A));
  85.  
  86.     keycodesCaps.insert(make_pair('A', 0x41));
  87.     keycodesCaps.insert(make_pair('B', 0x42));
  88.     keycodesCaps.insert(make_pair('C', 0x43));
  89.     keycodesCaps.insert(make_pair('D', 0x44));
  90.     keycodesCaps.insert(make_pair('E', 0x45));
  91.     keycodesCaps.insert(make_pair('F', 0x46));
  92.     keycodesCaps.insert(make_pair('G', 0x47));
  93.     keycodesCaps.insert(make_pair('H', 0x48));
  94.     keycodesCaps.insert(make_pair('I', 0x49));
  95.     keycodesCaps.insert(make_pair('J', 0x4A));
  96.     keycodesCaps.insert(make_pair('K', 0x4B));
  97.     keycodesCaps.insert(make_pair('L', 0x4C));
  98.     keycodesCaps.insert(make_pair('M', 0x4D));
  99.     keycodesCaps.insert(make_pair('N', 0x4E));
  100.     keycodesCaps.insert(make_pair('O', 0x4F));
  101.     keycodesCaps.insert(make_pair('P', 0x50));
  102.     keycodesCaps.insert(make_pair('Q', 0x51));
  103.     keycodesCaps.insert(make_pair('R', 0x52));
  104.     keycodesCaps.insert(make_pair('S', 0x53));
  105.     keycodesCaps.insert(make_pair('T', 0x54));
  106.     keycodesCaps.insert(make_pair('U', 0x55));
  107.     keycodesCaps.insert(make_pair('V', 0x56));
  108.     keycodesCaps.insert(make_pair('W', 0x57));
  109.     keycodesCaps.insert(make_pair('X', 0x58));
  110.     keycodesCaps.insert(make_pair('Y', 0x59));
  111.     keycodesCaps.insert(make_pair('Z', 0x5A));
  112.  
  113.     keycodesMisc.insert(make_pair('/', 0xBF));
  114.     keycodesMisc.insert(make_pair('\\',0xDC));
  115.     keycodesMisc.insert(make_pair('1', 0x31));
  116.     keycodesMisc.insert(make_pair('2', 0x32));
  117.     keycodesMisc.insert(make_pair('3', 0x33));
  118.     keycodesMisc.insert(make_pair('4', 0x34));
  119.     keycodesMisc.insert(make_pair('5', 0x35));
  120.     keycodesMisc.insert(make_pair('6', 0x36));
  121.     keycodesMisc.insert(make_pair('7', 0x37));
  122.     keycodesMisc.insert(make_pair('8', 0x38));
  123.     keycodesMisc.insert(make_pair('9', 0x39));
  124.     keycodesMisc.insert(make_pair('0', 0x30));
  125.     keycodesMisc.insert(make_pair(' ', VK_SPACE));
  126.  
  127.     string key;
  128.     unsigned int key_int = -1;
  129.     cout << "Enter the phrase you wish to send: ";
  130.     getline(cin, key);
  131.     int speed;
  132.     cout << "Enter the wait time (in miliseconds) between each send: ";
  133.     cin >> speed;
  134.     if(speed <= 0){
  135.         speed = 1;
  136.     }
  137.     while(true){
  138.         for(unsigned int iter = 0; iter < key.size(); iter++){
  139.             if(keycodes.find(key[iter]) != keycodes.end()){
  140.                 key_int = keycodes.find(key[iter])->second;
  141.                 GenerateKey(key_int, FALSE);
  142.             }
  143.             else if(keycodesCaps.find(key[iter]) != keycodesCaps.end()){
  144.                 key_int = keycodesCaps.find(key[iter])->second;
  145.                 GenerateKey(VK_SHIFT, FALSE, TRUE, key_int);
  146.             }
  147.             else if(keycodesMisc.find(key[iter]) != keycodesMisc.end()){
  148.                 key_int = keycodesMisc.find(key[iter])->second;
  149.                 GenerateKey(key_int, FALSE);
  150.             }
  151.             Sleep(50);
  152.             if(GetKeyState(VK_END) & 0x80){
  153.                 return 0;
  154.             }
  155.         }
  156.         GenerateKey(VK_RETURN, FALSE);
  157.         Sleep(speed);
  158.     }
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement