Skip to content
Browse files

arpspoof: add verbose switch and clean up messages

  • Loading branch information...
1 parent 881e95d commit 8db5155cfa02fe76edecc4961032dfb61b1d96c2 @wertarbyte committed Dec 4, 2011
Showing with 15 additions and 6 deletions.
  1. +3 −1 arpspoof.8
  2. +12 −5 arpspoof.c
View
4 arpspoof.8
@@ -9,7 +9,7 @@ intercept packets on a switched LAN
.na
.nf
.fi
-\fBarpspoof\fR [\fB-i \fIinterface\fR] [\fB-c \fIown|host|both\fR] [\fB-s \fInetwork/prefixlength\fR] [\fB-t \fItarget\fR] [\fB-r\fR] \fIhost\fR
+\fBarpspoof\fR [-v] [\fB-i \fIinterface\fR] [\fB-c \fIown|host|both\fR] [\fB-s \fInetwork/prefixlength\fR] [\fB-t \fItarget\fR] [\fB-r\fR] \fIhost\fR
.SH DESCRIPTION
.ad
.fi
@@ -21,6 +21,8 @@ switch.
Kernel IP forwarding (or a userland program which accomplishes the
same, e.g. fragrouter(8)) must be turned on ahead of time.
.SH OPTIONS
+.IP "\fB-v\fR"
+Make arpspoof verbose about what it is doing.
.IP "\fB-i \fIinterface\fR"
Specify the interface to use.
.IP "\fB-c \fIown|host|both\fR"
View
17 arpspoof.c
@@ -42,6 +42,7 @@ struct host {
#define HOST_ACTIVE (1<<0)
#define HOST_SUBNET (1<<1)
+static int verbose = 0;
static libnet_t *l;
static struct host spoof = {0};
static int n_targets = 0;
@@ -60,7 +61,7 @@ static void
usage(void)
{
fprintf(stderr, "Version: " VERSION "\n"
- "Usage: arpspoof [-i interface] [-c own|host|both] [-t target] [-s network/prefixlength] [-r] host\n");
+ "Usage: arpspoof [-v] [-i interface] [-c own|host|both] [-t target] [-s network/prefixlength] [-r] host\n");
exit(1);
}
@@ -249,8 +250,11 @@ main(int argc, char *argv[])
/* allocate enough memory for target list */
targets = calloc( argc+1, sizeof(struct host) );
- while ((c = getopt(argc, argv, "ri:s:t:c:h?V")) != -1) {
+ while ((c = getopt(argc, argv, "vri:s:t:c:h?V")) != -1) {
switch (c) {
+ case 'v':
+ verbose = 1;
+ break;
case 'i':
intf = optarg;
break;
@@ -331,22 +335,25 @@ main(int argc, char *argv[])
if ((l = libnet_init(LIBNET_LINK, intf, libnet_ebuf)) == NULL)
errx(1, "%s", libnet_ebuf);
- printf("Scanning %d hw addresses...\n", n_targets);
+ fprintf(stderr, "Scanning %d hw addresses...\n", n_targets);
struct host *target = targets;
for (; target->ip; target++) {
+ if (verbose) {
+ fprintf(stderr, "Looking up host %s...\n", libnet_addr2name4(target->ip, LIBNET_DONT_RESOLVE));
+ }
int arp_status = arp_find(target->ip, &target->mac);
if (arp_status &&
/* just make sure we are not getting an empty or broadcast address */
(memcmp(&target->mac, zero_ha, sizeof(struct ether_addr)) != 0) &&
(memcmp(&target->mac, brd_ha, sizeof(struct ether_addr)) != 0)) {
target->flags |= HOST_ACTIVE;
if (target->flags & HOST_SUBNET) {
- printf("Found host in subnet %s: %s\n", libnet_addr2name4(target->ip, LIBNET_DONT_RESOLVE), ether_ntoa((struct ether_addr *)&target->mac));
+ fprintf(stderr, "Found host in subnet %s: %s\n", libnet_addr2name4(target->ip, LIBNET_DONT_RESOLVE), ether_ntoa((struct ether_addr *)&target->mac));
}
} else {
target->flags &= (~HOST_ACTIVE);
if (! (target->flags & HOST_SUBNET)) {
- printf("Unable to find specified host %s\n", libnet_addr2name4(target->ip, LIBNET_DONT_RESOLVE));
+ fprintf(stderr, "Unable to find specified host %s\n", libnet_addr2name4(target->ip, LIBNET_DONT_RESOLVE));
}
}
}

0 comments on commit 8db5155

Please sign in to comment.
Something went wrong with that request. Please try again.