Advertisement
STANAANDREY

spammer

Jul 7th, 2020
1,773
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.34 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <windows.h>
  4. #include <conio.h>
  5. #include <bits/stdc++.h>
  6. #define clrscr() system("cls")
  7. #ifndef WINVER
  8. #define WINVER 0x0500
  9. #endif
  10. using namespace std;
  11. const int SZMAX = 1e8, WIDTH = 20;
  12. const char mcolor[] = "color 0b";
  13. const string unit = "(in miliseconds)";
  14. char op;
  15. string message;
  16.  
  17. typedef struct {
  18.     vector<string> CLI_data;
  19.     function<bool()> valid_break_cond;
  20. } CLI_params;
  21. int reps;
  22. DWORD start_delay, delay, spam_delay;
  23. unordered_map<string, CLI_params> CLI_mapper;
  24. void map_CL_funs_strs() {
  25.     function<bool()> f;
  26.     CLI_mapper["mess_input_source"] = {
  27.         {
  28.             "Read message from:(1/2):",
  29.             "1.Console!",
  30.             "2.File!"
  31.         },
  32.         []()->bool {
  33.             op = getch();
  34.             return strchr("12", op);
  35.         }
  36.     };
  37.     CLI_mapper["source:keyboard"] = {
  38.         {
  39.             "Type the message:"
  40.         },
  41.         []()->bool {
  42.             getline(cin, message);
  43.             return !message.empty();
  44.         }
  45.     };
  46.     CLI_mapper["source:file"] = {
  47.         {
  48.             "Type file adress or file and make sure that the file is in folder with app:"
  49.         },
  50.         []()->bool {
  51.             string fsource;
  52.             ifstream fhandler;
  53.             fhandler.open(fsource.c_str());
  54.             if (!fhandler.good() || !fhandler.is_open()) {
  55.                 Beep(523,1500);
  56.                 std::cerr << "File not found/couldn't be opened!" << '\n';
  57.                 Sleep(5000);
  58.                 return false;
  59.             }
  60.             string temp;
  61.             while (getline(fhandler, temp))
  62.                 message += temp;
  63.             return true;
  64.         }
  65.     };
  66.     CLI_mapper["time data: start_delay"] = {
  67.         {
  68.             "Delay until spammer start" + unit + ":"
  69.         },
  70.         []()->bool {
  71.             cin >> start_delay;
  72.             return (start_delay > 2000);
  73.         }
  74.     };
  75.     CLI_mapper["time data: delay"] = {
  76.         {
  77.             "Delay between message characters" + unit + ":"
  78.         },
  79.         []()->bool {
  80.             cin >> delay;
  81.             return (delay >= 0);
  82.         }
  83.     };
  84.     CLI_mapper["time data: spam_delay"] = {
  85.         {
  86.             "Delay between messages" + unit + ":"
  87.         },
  88.         []()->bool {
  89.             cin >> spam_delay;
  90.             return (spam_delay >= 0);
  91.         }
  92.     };
  93.     CLI_mapper["loop"] = {
  94.         {
  95.             "Repeat by(times):"
  96.         },
  97.         []()->bool {
  98.             cin >> reps;
  99.             return (reps > 0);
  100.         }
  101.     };
  102. }//*/
  103.  
  104. void __attribute__((constructor)) Setup();
  105. void Setup() {
  106.     ios::sync_with_stdio(true);
  107.     cout.tie(nullptr);
  108.     system(mcolor);
  109.     map_CL_funs_strs();
  110.     cout.fill('\t');
  111.     cout.width(WIDTH);
  112.     cout << "SPAMMER BOT!!!" << endl;
  113. }
  114. void SendKbInp(const char *str, const DWORD delayT = 0, bool pressEnter = true) {
  115.     INPUT ip;
  116.     ip.type = INPUT_KEYBOARD;
  117.     ip.ki.wScan = 0;
  118.     ip.ki.time = 0;
  119.     ip.ki.dwExtraInfo = 0;
  120.     for (int i = 0;;) {
  121.         char c;
  122.         if (!str[i]) {
  123.             if (!pressEnter)
  124.                 return;
  125.             c = VK_RETURN;
  126.             pressEnter = false;
  127.         }
  128.         else
  129.             c = str[i++];
  130.  
  131.         ip.ki.wVk = VkKeyScanA(c);
  132.         ip.ki.dwFlags = false;
  133.         SendInput(1, &ip, sizeof(INPUT));
  134.         ip.ki.dwFlags = KEYEVENTF_KEYUP;
  135.         SendInput(1, &ip, sizeof(INPUT));
  136.         Sleep(delayT);
  137.     }//*/
  138. }
  139.  
  140.  
  141. void choice_CLI(CLI_params cli_params) {
  142.         while (true) {
  143.             for (auto it : cli_params.CLI_data)
  144.                 puts(it.c_str());
  145.             if (cli_params.valid_break_cond())
  146.                 break;
  147.         }
  148. }
  149.  
  150. void exit_app() {
  151.     cout << "Exiting";
  152.     for (int i = 0; i < 3; i++) {
  153.         Sleep(1200);
  154.         cout << '.';
  155.     }
  156.     exit(EXIT_SUCCESS);
  157. }
  158.  
  159. int main() {
  160.     while (true) {
  161.         choice_CLI(CLI_mapper["mess_input_source"]);
  162.         if (op == '1')
  163.             choice_CLI(CLI_mapper["source:keyboard"]);
  164.         else if (op == '2')
  165.             choice_CLI(CLI_mapper["source:file"]);
  166.         choice_CLI(CLI_mapper["time data: start_delay"]);
  167.         choice_CLI(CLI_mapper["time data: delay"]);
  168.         choice_CLI(CLI_mapper["time data: spam_delay"]);
  169.         choice_CLI(CLI_mapper["loop"]);
  170.         cout << "Process is about to start in aprox " << start_delay / 1000 << " seconds. Put the cursor where u want to spam or program crashes!";
  171.         cin.get();
  172.         Sleep(start_delay);
  173.         for (int reps = 1; reps <= ::reps; reps++) {
  174.             SendKbInp(message.c_str(), delay, true);
  175.             if (reps != ::reps)
  176.                 Sleep(spam_delay);
  177.         }
  178.         cout << "Process finished" << endl;
  179.         cout << "To reuse press space:" << endl;
  180.         op = getch();
  181.         clrscr();
  182.         if (op != ' ')
  183.             break;//*/
  184.     }//*/
  185.     //getchar();
  186.     exit_app();
  187. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement