Better handling of listen_arp_frame failure
This commit is contained in:
parent
0d66824635
commit
e8dde3776f
1 changed files with 13 additions and 3 deletions
14
arp.c
14
arp.c
|
@ -224,7 +224,9 @@ int listen_arp_frame(int sockfd, struct ether_arp *result)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
printf("[FAIL] No frame received\n");
|
printf("[FAIL] No frame received\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -318,7 +320,11 @@ int arp_mitm(int sockfd, int ifindex, struct sockaddr_in *ipaddr, unsigned char
|
||||||
hardware addresses. */
|
hardware addresses. */
|
||||||
send_arp_request(sockfd, ifindex, ipaddr, macaddr, *target1_ip);
|
send_arp_request(sockfd, ifindex, ipaddr, macaddr, *target1_ip);
|
||||||
struct ether_arp reply1;
|
struct ether_arp reply1;
|
||||||
listen_arp_frame(sockfd, &reply1);
|
int n = listen_arp_frame(sockfd, &reply1);
|
||||||
|
if (n != 0) {
|
||||||
|
printf("[FAIL] No frame received\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
unsigned char *macaddr1 = reply1.arp_sha;
|
unsigned char *macaddr1 = reply1.arp_sha;
|
||||||
printf("Target 1 hardware address: %02x:%02x:%02x:%02x:%02x:%02x\n",
|
printf("Target 1 hardware address: %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||||
macaddr1[0],macaddr1[1],macaddr1[2],
|
macaddr1[0],macaddr1[1],macaddr1[2],
|
||||||
|
@ -326,7 +332,11 @@ int arp_mitm(int sockfd, int ifindex, struct sockaddr_in *ipaddr, unsigned char
|
||||||
|
|
||||||
send_arp_request(sockfd, ifindex, ipaddr, macaddr, *target2_ip);
|
send_arp_request(sockfd, ifindex, ipaddr, macaddr, *target2_ip);
|
||||||
struct ether_arp reply2;
|
struct ether_arp reply2;
|
||||||
listen_arp_frame(sockfd, &reply2);
|
n = listen_arp_frame(sockfd, &reply2);
|
||||||
|
if (n != 0) {
|
||||||
|
printf("[FAIL] No frame received\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
unsigned char *macaddr2 = reply2.arp_sha;
|
unsigned char *macaddr2 = reply2.arp_sha;
|
||||||
printf("Target 2 hardware address: %02x:%02x:%02x:%02x:%02x:%02x\n",
|
printf("Target 2 hardware address: %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||||
macaddr2[0],macaddr2[1],macaddr2[2],
|
macaddr2[0],macaddr2[1],macaddr2[2],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue