Created
February 22, 2014 09:23
-
-
Save thequbit/9151015 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main(int argc, char *argv[]) | |
{ | |
FILE *f; | |
FILE *frnd; | |
int i = 0; | |
if(argc != 4) | |
{ | |
printf("Usage:\n\trnddata <file_name> <loop_count> <buffer_size>\n"); | |
return 1; | |
} | |
int BUFFER_SIZE = atoi(argv[2]); | |
int BUFFER_COUNT = atoi(argv[3]); // get first commadn line arg as number | |
unsigned char *buffer = (unsigned char*)malloc(BUFFER_SIZE); | |
printf("Writing out %i payloads of %i Bytes each ...\n",BUFFER_COUNT,BUFFER_SIZE); | |
// open our output file | |
f = fopen(argv[1],"w"); | |
// open our random number source | |
frnd = fopen("/dev/urandom","r"); | |
// create FILE_SIZE random bytes | |
for(i = 0; i < BUFFER_COUNT; i++) | |
{ | |
// read in BUFFER_SIZE random bytes | |
fread(buffer,BUFFER_SIZE,1,frnd); | |
// write out the buffer to our file | |
fwrite(buffer,sizeof(buffer),1,f); | |
} | |
// close out our file (DON'T FORGET TO DO THIS) | |
fclose(f); | |
printf("Done.\n"); | |
// all done | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment