int mem_fuzz() { unsigned long arg[8]; long *p; int i, syscallnr, flag; srand(getseed()); while(1) { do { flag = 0; syscallnr = (rand() % 253); for (i = 0; i < (sizeof(ignore) / sizeof(ignore[0])); i++) { if (ignore[i] == syscallnr ) { flag = 1; break; } } } while (flag); p = arg; for (i = 0; i < 8; i++) { *p++ = getarg(); } printf("syscall(%d, %p, %p, %p, %p, %p, %p, %p, %p);\n", syscallnr, arg[0], arg[1],arg[2],arg[3],arg[4],arg[5],arg[6],arg[7]); fflush(stdout); usleep(5); syscall(syscallnr, arg[0], arg[1],arg[2],arg[3],arg[4],arg[5],arg[6],arg[7]); } }
void randombytes(uint8_t *r, size_t nr) { int i; uint32_t l; if(!seeded){ seeded=1; srandom(getseed()); } for(i=0; i+4<=nr; i+=4,r+=4){ l = (uint32_t)random(); r[0] = l; r[1] = l>>8; r[2] = l>>16; r[3] = l>>24; } if(i<nr){ l = (uint32_t)random(); switch(nr-i){ case 3: r[2] = l>>16; case 2: r[1] = l>>8; case 1: r[0] = l; } }
int main(int argc, char *argv[], char *envp[]) { unsigned short cnt = 0, ndx; char *env_PATH, *path, env_paths[13][37]; // Only 13 paths taken from $PATH with 37 chars each one, enough to play with ... char *env_LD_LIBRARY_PATH = malloc(BUFF_SIZE); // Yeah yeah, I prefer to spend time writing this comment than checking the returned value by malloc() :D char *fuzzed_path; // Split $PATH env_PATH = getenv("PATH"); path = strtok(env_PATH, ":"); strncpy(env_paths[cnt], path, 37); env_paths[cnt++][36] = '\0'; while((path = strtok(NULL, ":")) != NULL && cnt < 13){ strncpy(env_paths[cnt], path, 37); env_paths[cnt++][36] = '\0'; } // Split srand(getseed()); // Overflows and off-by-one's section :D, exploit them ! *env_LD_LIBRARY_PATH = '\0'; while(strlen(env_LD_LIBRARY_PATH) < BUFF_SIZE){ if(rand() % 4 < 3){ // 75% chance of valid paths ndx = rand() % cnt; if(strlen(env_LD_LIBRARY_PATH) + strlen(env_paths[ndx]) < BUFF_SIZE) strcat(env_LD_LIBRARY_PATH, env_paths[ndx]); else break; } else { fuzzed_path = get_fuzzed_path(); if(strlen(env_LD_LIBRARY_PATH) + strlen(fuzzed_path) < BUFF_SIZE) strcat(env_LD_LIBRARY_PATH, fuzzed_path); else break; } if(strlen(env_LD_LIBRARY_PATH) + 1 < BUFF_SIZE) strcat(env_LD_LIBRARY_PATH, ":"); if(strlen(env_LD_LIBRARY_PATH) == BUFF_SIZE - 1) break; } printf("%s", env_LD_LIBRARY_PATH); free(env_LD_LIBRARY_PATH); return 0; }
int main(int argc, char *argv[]) { Testcase *t; int seed; if(argc == 1) seed = getseed(); else seed = strtoul(argv[1], 0, 10); printf("/* seed %u */\n", seed); srand(seed); t = randtestcase(); printf("void abort(void);\n"); printfunc(t); printmain(t); return 0; }
int main(int argc, char **argv) { int fd; char *p, *name; unsigned char c; unsigned int count, i, off, hsize; if (argc < 2) { hsize = DEFAULT_HEADER_SIZE; name = DEFAULT_NAME; } else if (argc < 3) { hsize = DEFAULT_HEADER_SIZE; name = argv[1]; } else { hsize = atoi(argv[2]); name = argv[1]; } fd = open(name, O_RDWR); if (fd < 0) { perror("open"); exit(0); } p = mmap(0, hsize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (p == MAP_FAILED) { perror("mmap"); close(fd); exit(0); } srand(getseed()); count = (unsigned) rand() % (hsize / 10); for (i = 0; i < count; i++) { off = rand() % hsize; c = rand() % 256; /* we want the highest bit set more often, in case of signedness issues */ if ( (rand() % 2) && c < 128) c |= 0x80; p[off] = c; } close(fd); munmap(p, hsize); return 0; }
static void test20(void) { stresstest(getseed(), true); }
static void test17(void) { stresstest(getseed(), false); }
int main(void) { float times['Z']; float matchtimelimit; /*the time limit for matches (used to calculate how long tourney can go)*/ float poolslength; /*how long it will take to finish pools*/ float tourneylength; /*how long it will take for the entire tournament*/ float poollength; /*how long each pool will take*/ float bracketlength; /*how long it will take to finish bracket (seed -> GF)*/ int poolsindex; int i; int j; int amountofplayers; /*amount of players entering pools*/ int bracketseed; /*size of bracket (power of 2)*/ int poolsize; /*size of each pool*/ int amountofpools; /*how many pools there are for each choice*/ int bestofbracket; /*actual variable corresponding to user choice*/ int bestofpools; /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ int setsperpool; /*how many sets must be played in a pool*/ int totalpoolssets; /*how many sets for all pools*/ int setsinbracket; /*how many sets must be played in bracket*/ int setups; /*how many sets for all brackets*/ int player1; int player2; char bracketchoice; /*user can choose between 4 bracket sizes, 4, 8, 16, 32*/ char bestofpoolschoice; /*user can choose between best of 3, 5, or 7 matches POOLS*/ char bestofbracketchoice; /*user can choose between best of 3, 5, or 7 matches BRACKET*/ int poolschoice; amountofplayers = getplayers(); setups = getsetups(); int primes[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997}; int poolsamountchoice[amountofplayers]; int poolsizechoice['Z'][2]; int playertags[amountofplayers][6]; int playerid[amountofplayers]; int * address; for (i = 0; i < amountofplayers; i++) { address = &playertags[i]; //gettags(address, i);//uncomment for tags 1/2 playerid[i] = primes[i]; } for (i = 0; i < amountofplayers; i++) { //printf("player %d's tag is %s their id is %d\n", i+1, playertags[i], playerid[i]);//uncomment for tags 2/2 } printf("Please enter desired \"Best of\" number for pools:\n"); scanf(" %d", &bestofpools); bestofpools = check_if_odd(bestofpools); printf("You have chosen best of %d for pools\n", bestofpools); printf("Please enter desired \"Best of\" number for bracket:\n"); scanf(" %d", &bestofbracket); bestofbracket = check_if_odd(bestofbracket); printf("You have chosen best of %d for bracket\n", bestofbracket); printf("Please enter the time limit (or average match time) for each match in minutes\n"); scanf("%f", &matchtimelimit); bracketseed = getseed(amountofplayers); printf("\n\nTo seed a bracket of %d players from %d initial players in the given amount of time, there needs to be:\n", bracketseed, amountofplayers); for (poolsindex = 0, poolsize = amountofplayers, amountofpools = 1, i = 0; poolsize >= 1 && (bracketseed / amountofpools) >= 1 && poolsize >= 2; amountofpools*=2, poolsindex++) { poolsize = amountofplayers / amountofpools; if ((poolsize * amountofpools) < amountofplayers) poolsize++; setsperpool = (poolsize * (poolsize+1))/2; totalpoolssets = setsperpool * amountofpools; poollength = (((setsperpool * bestofpools * matchtimelimit)/60)/setups); poolslength = (((totalpoolssets * bestofpools * matchtimelimit)/60)/setups); setsinbracket = ((bracketseed * 2)-1); bracketlength = ((setsinbracket * bestofbracket * matchtimelimit)/60/setups); tourneylength = poolslength + bracketlength; if (poolsize > 2) { printf("\nFORMAT: %c\n", (i + 'A')); printf("%d pools\n", amountofpools); printf("%d amount of players each\n", poolsize); printf("With the top %d players of each pool advancing to bracket\n", bracketseed / amountofpools); printf("Which would be %d max sets that must be played in each pool\nand take max %.2f hrs. to complete per pool\n", setsperpool, poollength); printf("Which would be %d max sets that must be played for all pools, which would take %.2f hrs. to complete before bracket is seeded\n", totalpoolssets, poolslength); printf("With %d sets in bracket, the entire tournament would take %.2f hrs.\n", setsinbracket, tourneylength); times[i] = tourneylength; poolsizechoice[i][0] = poolsize; poolsizechoice[i][1] = amountofpools; i++; } if ((bracketseed / amountofpools) == 1) break; } printf("\n\nChoices of:"); for(i = 0 ; i <= poolsindex && times[i] != 0;) { printf("\nFORMAT %c would take %.2f hours\n", (i + 'A'), times[i]); printf("%d pools with %d people each\n", poolsizechoice[i][1], poolsizechoice[i][0]); i++; } printf("\nA bracket of %d would take %.2f hrs.\n", bracketseed, bracketlength); //i--;// idk why this code is here lol printf("\n\n\nDISCLAIMER:\nALL CALCULATIONS ARE ESITMATES AND DO NOT FACTOR IN -\n" "TIME TAKEN BETWEEN GAMES/SETS/MATCHES. EX: TIME TAKEN TO FIND PLAYERS.\n"); return 0; }