ARP欺骗实验

总目标

写一个抓包工具

小实验2.ARP欺骗实验

1.实验:ARP欺骗之send_arp

2. 实验平台:Linux (RedHat5)

3.实验目的:通过对send_arp程序的使用,了解ARP包的基本构造,以及局域网中ARP病毒的原理。

4.预期结果:通过使用send_arp程序,更改被“骗”主机的ARP表,以达到欺骗目的。

5.实验步骤:

1、在虚拟机中创建三个Linux系统,分别为A、B、C。(在本实验中以A冒充B的身份来欺骗C)
2、在以上三个虚拟机中分别输入ifconfig,得到ip和mac地址。
3、在C下分别ping主机A和B,然后输入arp -a得到ARP表,记录下来IPA对应的MAC地址,以及IPB对应的MAC地址。(所得到的ip和mac对应关系正确标志着实际情况下A、B的ip和mac对应关系)。
4、在A下启动send_arp程序,在shell命令提示符下的命令行为send_arp -p IP_B -h MAC_A -P IP_C -H MAC_C -t 2 -v

解释:发送ARP包,-p对应的是ARP包中显示的发送方ip,-h对应的是ARP包中显示的发送方的MAC,-P对应的是ARP包中所显示的目的IP地址,-H对应的是ARP包中所显示的目的MAC地址,-t对应的是该ARP类型,其中-t后跟的2表明该ARP包属于应答包,-v表示的是回显该ARP包中所包含的基础信息。

5、在C下再次输入arp -a,记录所得到的ARP表,显示发现本来IP_B对应的MAC_B,变成了和MAC_A所对应。

实验原理图:
在这里插入图片描述

实验要点

1.该实验至少需要两台电脑,被攻击的C和攻击者A

2.在我做的实验中,攻击者为linux下红帽子系统,被攻击者为win2003系统,这两台电脑在一个小型局域网中。换到我们自己的电脑上做实验的时候,ubuntu系统和windows系统无法ping通。

3.因为我们所发送的包为应答包,所以我们应该在主机Cping通主机B后,再立刻攻击主机C,否则攻击将会无效。我猜测这时候主机C应该是默认不接受应答包的。

代码部分

  /* Send_arp.c */


    #include <stdio.h>
    #include <ctype.h>
    #include <stdlib.h>
    #include <string.h>
    #include <errno.h>
    #include <netdb.h>
    #include <sys/socket.h>
    #include <arpa/inet.h>
    #include <linux/if_ether.h>
    #include <getopt.h>

    #define ETH_HW_ADDR_LEN 6
    #define IP_ADDR_LEN 4
    #define ARP_FRAME_TYPE 0x0806
    #define ETHER_HW_TYPE 1
    #define IP_PROTO_TYPE 0x0800

    #define DEBUG 1

    char usage[] = {
   "sendarp: send an arp packet\n   usage: sendarp [-?] [-v] [-t message_type] [-i interface]\n                   [-p sender_protocol_address] [-P target_protocol_address]\n                   [-h sender_hardware_address] [-H target_hardware_address] [-v]\n \n    -?    display this message\n    -v    verbose                         Default: not verbose\n             Be verbose\n \n    -t    message type               Default: 1\n             Identifies the purpose for this ARP packet\n              1    ARP Request\n              2    ARP Response\n              3    Reverse ARP Request\n              4    Reverse ARP Response\n              8    Inverse ARP Request\n              9    Inverse ARP Response\n \n    -i    interface                       Default: eth0\n              Select an interface (eth1, lo, ppp0, whatever...)\n \n    -p    sender protocol address         Default: 0.0.0.0\n              Identifies the ip address of the system issuing the ARP packet.\n \n     -P    target protocol address         Default: 0.0.0.0\n              Identifies the ip address of the ARP packet's destination.\n \n    -h    sender hardware address         Default: 00:00:00:00:00:00\n              Identifies the hardware address of the system issuing the ARP packet.\n \n     -H    target hardware address    Default: 00:00:00:00:00:00\n              Identifies the hardware address of the ARP packet's destination.\n \n    Bugs:\n          if you find any please email <jrs@abiogenesis.com>;\n              thanks.\n    Author(s):\n          Derived from send_arp.c by Yuri Volobuev <volobuev@t1.chem.umn.edu>; 1997\n          Modified by Jonthan R. Seagrave <jrs@abiogenesis.com>; 14 Sep 2000\n \n"};

    struct arp_packet {
   
            u_char dst_hw_addr[ETH_HW_ADDR_LEN];
            u_char src_hw_addr[ETH_HW_ADDR_LEN];
            u_short frame_type;
            u_short hw_type;
            u_short prot_type;
            u_char hw_addr_size;
            u_char prot_addr_size;
            u_short type;
            u_char sndr_hw_addr[ETH_HW_ADDR_LEN];
            u_char sndr_ip_addr[IP_ADDR_LEN];
            u_char rcpt_hw_addr[ETH_HW_ADDR_LEN];
            u_char rcpt_ip_addr[IP_ADDR_LEN];
            u_char padding[18];
    };

    void send_arp(char *src_ip, char *src_hw_addr, char *dst_ip, char *dst_hw_addr, char *interface, u_short type);
    void die(char *);
    void get_ip_addr(struct in_addr*,char*);
    v
  • 9
    点赞
  • 38
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值