Hacking - The Art of Exploitation, 2nd Edition

(Romina) #1
Networking 249

only builds ethernet/IP ARP packets, and consequently the first value should
be ARPHRD_ETHER. The ARP packet type should be one of the following:
ARPOP_REQUEST, ARPOP_REPLY, ARPOP_REVREQUEST, ARPOP_REVREPLY,
ARPOP_INVREQUEST, or ARPOP_INVREPLY.


libnet_destroy_packet() frees the memory associated with the packet.


libnet_close_link_interface() closes an opened low-level packet interface.
Returned is 1 upon success or -1 on error.


With a basic understanding of C, API documentation, and common sense,


you can teach yourself just by examining open source projects. For example,


Dug Song provides a program called arpspoof, included with dsniff, that per-


forms the ARP redirection attack.


From the arpspoof Man Page


NAME
arpspoof - intercept packets on a switched LAN


SYNOPSIS
arpspoof [-i interface] [-t target] host


DESCRIPTION


arpspoof redirects packets from a target host (or all hosts) on the LAN
intended for another host on the LAN by forging ARP replies. This is
an extremely effective way of sniffing traffic on a switch.


Kernel IP forwarding (or a userland program which accomplishes the
same, e.g. fragrouter(8)) must be turned on ahead of time.


OPTIONS


-i interface
Specify the interface to use.


-t target
Specify a particular host to ARP poison (if not specified, all
hosts on the LAN).


host Specify the host you wish to intercept packets for (usually the
local gateway).


SEE ALSO


dsniff(8), fragrouter(8)


AUTHOR


Dug Song [email protected]


The magic of this program comes from its arp_send() function, which also


uses libnet to spoof packets. The source code for this function should be read-


able to you, since many of the previously explained libnet functions are used


(shown in bold below). The use of structures and an error buffer should also


be familiar.

Free download pdf