Graphics Programs Reference
In-Depth Information
libnet_error(LIBNET_ERR_WARNING, "can't close network interface.");
return 0;
}
This program uses a print_ip() function to handle converting the
u_long type, used by libnet to store IP addresses, to the struct type expected
by inet_ntoa() . The value doesn't change—the typecasting just appeases the
compiler.
The current release of libnet is version 1.1, which is incompatible with
libnet 1.0. However, Nemesis and arpspoof still rely on the 1.0 version of
libnet, so this version is included in the LiveCD and this is also what we will
use in our synflood program. Similar to compiling with libpcap, when compil-
ing with libnet, the flag -lnet is used. However, this isn't quite enough infor-
mation for the compiler, as the output below shows.
reader@hacking:~/booksrc $ gcc -o synflood synflood.c -lnet
In file included from synflood.c:1:
/usr/include/libnet.h:87:2: #error "byte order has not been specified, you'll"
synflood.c:6: error: syntax error before string constant
r eader@hacking:~/booksrc $
The compiler still fails because several mandatory define flags need to be
set for libnet. Included with libnet, a program called libnet-config will output
these flags.
reader@hacking:~/booksrc $ libnet-config --help
Usage: libnet-config [OPTIONS]
Options:
[--libs]
[--cflags]
[--defines]
reader@hacking:~/booksrc $ libnet-config --defines
-D_BSD_SOURCE -D__BSD_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H
- DLIBNET_LIL_ENDIAN
Using the BASH shell's command substitution in both, these defines can
be dynamically inserted into the compile command.
reader@hacking:~/booksrc $ gcc $(libnet-config --defines) -o synflood
synflood.c -lnet
reader@hacking:~/booksrc $ ./synflood
Usage:
./synflood <target host> <target port>
reader@hacking:~/booksrc $
reader@hacking:~/booksrc $ ./synflood 192.168.42.88 22
Fatal: can't open network interface. -- this program must run as root.
reader@hacking:~/booksrc $ sudo ./synflood 192.168.42.88 22
S YN Flooding port 22 of 192.168.42.88..
Search WWH ::




Custom Search