diff --git a/arp.c b/arp.c index 1c68c7f..4c1b872 100644 --- a/arp.c +++ b/arp.c @@ -229,42 +229,3 @@ int listen_arp_frame(int sockfd, struct ether_arp *result) return -1; } - - -/* Redirects all ethernet traffic from one address to another. - - args: struct args, which contains the hardware and protocol - addresses of the targets. - - Never returns (killed when the main thread terminates). - */ -void *redirect_traffic(void *args) -{ - struct args *addresses = (struct args *) args; - - int sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); - if (sockfd < 0) { - perror("[FAIL] socket()"); - exit(EXIT_FAILURE); - } - - char buffer[1024]; - struct ether_header *eh = (struct ether_header *) buffer; - - while (1) { - int len = recv(sockfd, buffer, sizeof(buffer), 0); - if (len <= 0) { - continue; - } - - if (eh->ether_dhost == addresses->macaddr1) { - sendto(sockfd, buffer, sizeof(buffer), 0, (struct sockaddr *)&addresses->ip_addr1, sizeof(struct sockaddr)); - } - else if (eh->ether_dhost == addresses->macaddr2) { - sendto(sockfd, buffer, sizeof(buffer), 0, (struct sockaddr *)&addresses->ip_addr2, sizeof(struct sockaddr)); - } - } - - return NULL; -} - diff --git a/arp.h b/arp.h index e6f6b87..9ac30d5 100644 --- a/arp.h +++ b/arp.h @@ -61,21 +61,5 @@ int send_arp_reply(int sockfd, int ifindex, struct sockaddr_in *sender_ip, unsig int listen_arp_frame(int sockfd, struct ether_arp *result); -struct args { - unsigned char macaddr1[6]; - unsigned char macaddr2[6]; - struct sockaddr_in ip_addr1; - struct sockaddr_in ip_addr2; -}; - -/* Redirects all ethernet traffic from one address to another. - - args: struct args, which contains the hardware and protocol - addresses of the targets. - - Never returns (killed when the main thread terminates). - */ -void *redirect_traffic(void *args); - #endif /* ARP_H_ */ diff --git a/arp_mitm.c b/arp_mitm.c index 727baa1..f49521e 100644 --- a/arp_mitm.c +++ b/arp_mitm.c @@ -161,20 +161,6 @@ int main(int argc, char **argv) macaddr2[0],macaddr2[1],macaddr2[2], 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 the other. We use both requests and replies because some devices (linux > 2.4.x for example) don't update their ARP cache on