Implementation of Arp Sniffer in linux

Source: Internet
Author: User

* ===================================================== ============================================
Coder: Paris-ye
Released on: 1/9/2003
Test on: FIG 9.0
Information:
This is a arp spoof sniffer.
W <--- workstation
B <--- Server or GateWay
M <--- Man in the middle (agent), self IP address
Make:
First you must install "pcap" and "libnet"
Gcc-I/usr/local/include-L/usr/local/lib-o sniffer. c-lpcap-lnet
Usage:
./Sniffer-I [Interface]-M [Self IP]-W [Workstation IP]-S [Server IP]-P [port]
========================================================== ============================================= */
# Include;
# Include;
# Include;
# Include;
# Include;
# Define MAXBUF 1024*4
# Define PCAP_TOUT 5
# Define PROMISC 0
# Define TRUE 1
# Define FALSE 0
/* Ethernet protocol IDs */
# Define ETHERTYPE_PUP 0x0200/* Xerox PUP */
# Define ETHERTYPE_IP: 0x0800/* IP */
# Define ETHERTYPE_ARP 0x0806/* Address resolution */
# Define ETHERTYPE_REVARP 0x8035/* Reverse ARP */
/* This structure defines an ethernet arp header .*/
/* ARP protocol opcodes .*/
# Define ARPOP_REQUEST 1/* ARP request .*/
# Define ARPOP_REPLY 2/* ARP reply .*/
# Define ARPOP_RREQUEST 3/* RARP request .*/
# Define ARPOP_RREPLY 4/* RARP reply .*/
# Define ARPOP_InREQUEST 8/* InARP request .*/
# Define ARPOP_InREPLY 9/* InARP reply .*/
# Define ARPOP_NAK 10/* (ATM) arp nak .*/
/* ARP protocol HARDWARE identifiers .*/
# Define ARPHRD_NETROM 0/* From KA9Q: NET/ROM pseudo .*/
# Define ARPHRD_ETHER 1/* Ethernet 10/100 Mbps .*/
# Define ARPHRD_EETHER 2/* Experimental Ethernet .*/
# Define ARPHRD_AX25 3/* AX.25 Level 2 .*/
# Define ARPHRD_PRONET 4/* PROnet token ring .*/
# Define ARPHRD_CHAOS 5/* Chaosnet .*/
# Define ARPHRD_IEEE802 6/* IEEE 802.2 Ethernet/TR/TB .*/
# Define ARPHRD_ARCNET 7/* ARCnet .*/
# Define ARPHRD_APPLETLK 8/* APPLEtalk .*/
# Define ARPHRD_DLCI 15/* Frame Relay DLCI .*/
# Define ARPHRD_ATM 19/* ATM .*/
# Define ARPHRD_METRICOM 23/* Metricom STRIP (new IANA id ).*/
/* Dummy types for non ARP hardware */
# Define ARPHRD_SLIP 0x256
# Define ARPHRD_CSLIP 0x257
# Define ARPHRD_SLIP6 0x258
# Define ARPHRD_CSLIP6 0x259
# Define ARPHRD_RSRVD 0x260/* Notional KISS type .*/
# Define ARPHRD_ADAPT 0x264
# Define ARPHRD_ROSE 0x270
# Define ARPHRD_X25 0x271/* CCITT X.25 .*/
# Define ARPHDR_HWX25 0x272/* Boards with X.25 in firmware .*/
# Define ARPHRD_PPP 0x512
# Define ARPHRD_CISCO 0x513/* Cisco HDLC .*/
# Define ARPHRD_HDLC ARPHRD_CISCO
# Define ARPHRD_LAPB 0x516/* LAPB .*/
# Define ARPHRD_DDCMP 0x517/* Digitals DDCMP .*/
# Define ARPHRD_RAWHDLC 0x518/* Raw HDLC .*/

# Define ARPHRD_TUNNEL 0x768/* IPIP tunnel .*/
# Define ARPHRD_TUNNEL6 0x769/* IPIP6 tunnel .*/
# Define ARPHRD_FRAD 0x770/* Frame Relay Access Device .*/
# Define ARPHRD_SKIP 0x771/* SKIP vif .*/
# Define ARPHRD_LOOPBACK 0x772/* Loopback device .*/
# Define ARPHRD_LOCALTLK 0x773/* Localtalk device .*/
# Define ARPHRD_FDDI 0x774/* Fiber Distributed Data Interface .*/
# Define ARPHRD_BIF 0x775/* AP1000 BIF .*/
# Define ARPHRD_SIT 0x776/* sit0 device-IPv6-in-IPv4 .*/
# Define ARPHRD_IPDDP 0x777/* IP-in-DDP tunnel .*/
# Define ARPHRD_IPGRE 0x778

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.