Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- // functions
- bool file_exists(const char* f);
- int main(int argc, char* argv[]){
- if(argc != 2){
- cerr << "Usage: fuzz \"file.jpg\"";
- return 0;
- }
- if(!file_exists(argv[1])){
- cerr << "Specified file doesn't exist.";
- return 1;
- }
- // Read source file
- FILE *fSource;
- fSource = fopen(argv[1], "r+");
- if(fSource == NULL){
- cerr << "Can't open file " << argv[1];
- return 2;
- }
- // Loop source file
- int byte;
- int i = 0;
- while((byte = fgetc(fSource)) != EOF){
- fseek(fSource, i++, SEEK_SET);
- fputc(byte ^ 0x13, fSource);
- fseek(fSource, i, SEEK_SET);
- }
- fclose(fSource);
- cout << "Fuzzed.";
- return 0;
- }
- bool file_exists(const char* f){
- ifstream file(f);
- return (bool) file;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement