Enviado em 04/07/2019 - 12:03h
A minha versão:
//test.c (04/07/2019)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
void stop_attack(pid_t child){
int wstatus;
system("killall xerxes");
if(kill(child, SIGTERM)!=0){
kill(child, SIGKILL);
}
wait(&wstatus);
}
int main(void){
const time_t timer=3600;
pid_t child=fork();
if(child<0){
exit(EXIT_FAILURE);
}else if(child==0){
for(time_t i=0; i<=timer; i++){
usleep(1000000);
}
stop_attack(child);
}else{
system("./xerxes 127.0.0.1 80");
}
return EXIT_SUCCESS;
}