Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Batch File Corruptor v1.2
- Made by Liquos, with help from /sci/
- Cleaning by The Lightning Stalker
- */
- #include <fstream>
- #include <cstdlib>
- #include <iostream>
- #include <sys/types.h>
- #include <sys/stat.h>
- using namespace std;
- int fileSize(const char * szFileName){
- struct stat fileStat;
- int err = stat(szFileName, &fileStat);
- if (0 != err) return 0;
- return fileStat.st_size;
- }
- int corruptFile(string fileName, int pad, int freq, int passes){
- unsigned int corBytes = 0;
- fstream cfile;
- cfile.open(fileName.c_str());
- char randByte;
- unsigned long long pPos;
- /* struct stat buff; */
- unsigned long long size = fileSize(fileName.c_str());
- cout << "Corrupting " << fileName << endl;
- for(int curPass = 0; curPass < passes; curPass++){
- pPos = pad+(rand()%freq);
- while(pPos < size - pad){
- cfile.seekp(pPos);
- randByte = (rand()%255);
- cfile.put(randByte);
- pPos += (rand()%freq)+1;
- corBytes++;
- }
- }
- cfile.close();
- cout << corBytes << " bytes corrupted." << endl << endl;
- return 0;
- }
- int main(int argc, char* argv[]){
- srand(time(NULL));
- int pad, freq, passes;
- cout << "Padding(x32): ";
- cin >> pad;
- cout << "Frequency (lower = more corruption): ";
- cin >> freq;
- cout << "Passes: ";
- cin >> passes;
- freq *= 128;
- pad *= 32;
- for(int curFile = 1; curFile < argc; curFile++){
- corruptFile(argv[curFile], pad, freq, passes);
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement