-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharp.h
93 lines (63 loc) · 2.46 KB
/
arp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* Satrap/arp.h */
#ifndef ARP_H_
#define ARP_H_
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <pthread.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <net/ethernet.h>
#include <netpacket/packet.h>
#include <netinet/ether.h>
/* Sends an ARP request
sockfd is the file descriptor of the socket to use to send the
frame, should be a raw socket (AF_PACKET), which accepts ARP
(ETH_P_ALL or ETH_P_ARP)
ifindex is the index of the network interface
ipaddr is the source IP address
macaddr is the source MAC address
target_ip is the IP address to be queried via ARP
The function returns 0 upon success, EXIT_FAILURE otherwise.
*/
int send_arp_request(int sockfd, int ifindex, struct sockaddr_in *ipaddr, unsigned char *macaddr, struct in_addr target_ip);
/* Sends an ARP reply
sockfd: file descriptor of the socket
ifindex: index of the network interface
sender_ip: source IP address
sender_mac: source MAC address
target_ip: IP address to which the answer is destined
target_mac: MAC address of the target
The function returns 0 on success, or exits with EXIT_FAILURE.
*/
int send_arp_reply(int sockfd, int ifindex, struct sockaddr_in *sender_ip, unsigned char *sender_mac, struct in_addr target_ip, unsigned char *target_mac);
/* Listens to an ARP frame
sockfd: the socket file descriptor
result: the parsed ARP frame
Returns 0 if an ARP answer was found, -1 otherwise.
*/
int listen_arp_frame(int sockfd, struct ether_arp *result);
/* Scans the subnet by sending ARP requests. If a reply is received,
we know that the target is alive.
sockfd: socket file descriptor
ifindex: index of the interface
ipaddr: local IP address
macaddr: local hardware address
netmask: local netmask
Returns 0 when the scan is complete.
*/
int arp_scan(int sockfd, int ifindex, struct sockaddr_in *ipaddr, unsigned char *macaddr, struct sockaddr_in *netmask);
/* ARP man-in-the-middle attack.
sockfd: socket file descriptor
ifindex: index of the interface
ipaddr: local IP address
macaddr: local hardware address
target1_ip: IP address of the first target
target2_ip: IP address of the second target
Never returns, has to be killed by the user.
*/
int arp_mitm(int sockfd, int ifindex, struct sockaddr_in *ipaddr, unsigned char *macaddr, struct in_addr *target1_ip, struct in_addr *target2_ip);
#endif /* ARP_H_ */