Multithreaded call to redirect_traffic

This commit is contained in:
Dimitri Lozeve 2016-06-03 16:46:56 +02:00
parent bf9ad1a030
commit a46a804df4
3 changed files with 17 additions and 1 deletions

View file

@ -1,5 +1,6 @@
CC=clang CC=clang
CFLAGS=-g -Wall -DDEBUG CFLAGS=-g -Wall
LDFLAGS=-lpthread
.PHONY: clean all .PHONY: clean all

1
arp.h
View file

@ -7,6 +7,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <pthread.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/socket.h> #include <sys/socket.h>

View file

@ -161,6 +161,20 @@ int main(int argc, char **argv)
macaddr2[0],macaddr2[1],macaddr2[2], macaddr2[0],macaddr2[1],macaddr2[2],
macaddr2[3],macaddr2[4],macaddr2[5]); macaddr2[3],macaddr2[4],macaddr2[5]);
struct args args;
memcpy(args.macaddr1, macaddr1, sizeof(*macaddr1));
memcpy(args.macaddr2, macaddr2, sizeof(*macaddr2));
memcpy(&args.ip_addr1, ipaddr1, sizeof(*ipaddr1));
memcpy(&args.ip_addr2, ipaddr2, sizeof(*ipaddr2));
pthread_t thread;
if (pthread_create(&thread, NULL, redirect_traffic, (void *)&args)) {
perror("[FAIL] pthread_create()");
exit(EXIT_FAILURE);
}
/* We send ARP requests and replies to both targets, impersonating /* We send ARP requests and replies to both targets, impersonating
the other. We use both requests and replies because some devices the other. We use both requests and replies because some devices
(linux > 2.4.x for example) don't update their ARP cache on (linux > 2.4.x for example) don't update their ARP cache on