网络-ARP协议详解与ARP欺骗(中毒)攻击实战_arp中毒

ARP攻击防御

静态绑定

ARP防火墙

参考


简介

地址解析协议,即ARP(Address Resolution Protocol),是根据IP地址获取物理地址(MAC地址)的一个协议。划分到网络层(TCP/IP)或数据链路层(OSI),用在局域网内。

功能:完成主机或路由器IP地址到MAC地址的映射

ARP高速缓存(arp表):IP地址和MAC地址的映射。

注:网络设备的接口有MAC地址,并不是一个网络设备仅有一个MAC地址,二层交换机这种设备没有MAC地址。

ARP报文

ARP报文格式

ARP报文的总长度为64字节,FCS(Frame Check Sequence,帧校验序列),俗称帧尾,即数据链路层的协定数据单元(帧)的尾部栏位,是一段4个位元组的循环冗余校验码,用来验证帧在传输过程中的完整性。

**硬件类型:**16位,2字节,用来定义运行ARP的网络类型。每个局域网基于其类型被指派一个整数。例如:以太网的类型为1。ARP可用在任何物理网络上。

**协议类型:**16位,2字节,用来定义使用的协议。例如:对IPv4协议这个字段是0x0800。ARP可用于任何高层协议。

**硬件长度:**8位,1字节,用来定义物理地址的长度,以字节为单位。例如:对于以太网的值为6。

**协议长度:**8位,1字节,用来定义逻辑地址的长度,以字节为单位。例如:对于IPv4协议的值为4。

**操作码:**16位,2字节,用来定义报文的类型。已定义的分组类型有两种:ARP请求(1),ARP响应(2)。

**源硬件地址:**可变长度字段,单位字节,用来定义发送方的物理地址。例如:对于以太网这个字段的长度是6字节。

**源协议地址:**可变长度字段,单位字节,用来定义发送方的逻辑(IP)地址。例如:对于IP协议这个字段的长度是4字节。

**目的硬件地址:**可变长度字段,用来定义目标的物理地址,例如,对以太网来说这个字段位6字节。对于ARP请求报文,这个字段为全0,因为发送方并不知道目标的硬件地址。

**目的协议地址:**可变长度字段,用来定义目标的逻辑(IP)地址,对于IPv4协议这个字段的长度为4个字节。

ARP流程

流程:检查ARP高速缓存,有对应表项则写入MAC帧,没有则用目的MAC地址为FF-FF FF-FF-FF-FF的帧封装并广播ARP请求分组同一局域网中所有主机都能收到该请求。目的主机收到请求后就会向源主机单播一个ARP响应分组,源主机收到后将此映射写入ARP缓存(10-20min更新一次)。

四种情况

1.主机A发给本网络上的主机B:用ARP表找到主机B的硬件地址;
2.主机A发给另–网络上的主机B:用ARP表找到本网络上一个路由器(网关)的硬件地址;
3.路由器发给本网络的主机A:用ARP表找到主机A的硬件地址;
4.路由器发给另一网络的主机B:用ARP表找到本网络上的一个路由器的硬件地址。

ARP请求

广播ARP请求分组

ARP响应

单播ARP响应分组

网络拓扑图

PCi对应IPi与MACi,i为1~5。默认网关为IP6。

PC1想与PC3通信

PC1广播ARP请求分组(IP1,IP3,MAC1,FF-FF-FF-FF-FF-FF),“我的ip为IP1,我的MAC地址为MAC1,哪位老哥的ip为IP3呀,你的MAC地址是多少呢?”,交换机发给PC2、PC3,PC2发现不是找自己的,不予答复(后续不再赘述),PC3单播ARP响应分组(IP3,MAC3),“小老弟,我的IP是IP3、MAC地址是MAC3”。

PC1想与PC5通信

PC1广播ARP请求分组(IP1,IP6,MAC1,FF-FF-FF-FF-FF-FF),“我的ip为IP1,我的MAC地址为MAC1,默认网关IP6,你的MAC地址是多少呢?”,路由器R1单播ARP响应分组(IP6,MAC6),“小老弟,我的IP是IP6、MAC地址是MAC6”。PC1收到后单播ARP请求分组(IP1,IP5,MAC1,MAC6),路由器R1收到后再次封装,单播ARP请求分组(IP1,IP5,MAC7,MAC8),路由器R2收到后再次封装,广播(IP1,IP5,MAC9,FF-FF-FF-FF-FF-FF),PC5单播ARP响应分组(IP5,MAC5),路由器R2收到PC5的单播知道PC5的MAC地址后再单播给路由器R1,R1再单播给PC1,PC1就知道PC5的MAC地址了。

ARP攻击原理

修改通信双方的数据包,使双方ARP表中对方IP对应的MAC地址为攻击者的MAC地址。以最简单的网络拓扑为例,其中PC1的IP、MAC为IP1、MAC1、PC2的IP、MAC为IP2、MAC2,路由器R1的IP、MAC为IP3、MAC3:

ARP攻击示例

  • 攻击者PC2聆听局域网上的MAC地址。它只要收到主机PC1和路由器R1洪泛的ARP Request,就可以进行欺骗活动。
  • 主机PC1、路由器R1都洪泛了ARP Request.攻击者现在有了主机和路由器的IP、MAC地址,开始攻击。
  • 攻击者发送一个ARP Reply给主机PC1,把此包ARP协议头部里的Source Protocal Address设为路由器的IP地址IP3,Source Hardware Address设为攻击者PC2自己的MAC地址MAC2。
  • 主机PC1收到ARP Reply后,更新它的ARP表,把路由器的MAC地址(IP3, MAC3)改为(IP3, MAC2)。
  • 当主机PC1要发送数据包给路由器R1时,它根据ARP表来封装数据包的Link报头,把目的MAC地址设为MAC2,而非MAC3。
  • 当交换机收到主机PC1发送给A路由器R1的数据包时,根据此包的目的MAC地址(MAC2)把数据包转发给攻击者PC2。
  • 攻击者收到数据包后,可以把它存起来后再发送给路由器R1,达到偷听效果。攻击者也可以篡改数据后才发送数据包给路由器R1。
  • 反之同理,如果局域网内还有PC3,PC1与PC3通信,攻击机PC2也可同样攻击。

看过博主其他文章的应该清楚,不实践一下是手痒的,接下来就看一看吧

实战

ARP欺骗

ARP欺骗(英语:ARP spoofing),又称ARP毒化(ARP poisoning,网络上多译为ARP中毒)或ARP攻击,是针对ARP的一种攻击技术,通过欺骗局域网内访问者PC的网关MAC地址,使访问者PC误以为攻击者更改后的MAC地址是网关的MAC,导致网络不通。此种攻击可让攻击者获取局域网上的数据包甚至可篡改数据包,且可让网络上特定计算机或所有计算机无法正常连线。

以攻击局域网,获取局域网内其他用户浏览的图片为例。

环境

攻击机(虚拟机)

操作系统:kali

使用软件:ettercap v0.8.3

IP:10.28.149.132

靶机(主机)

操作系统:Windows 10

查看arp表

使用cmd命令

arp -a

来查看arp表

主机arp表

更新攻击机软件

ettercap v0.8.2 不知什么原因,无法发现主机(图形界面,命令行都试了),所以进行了更新,如果你的本来就是0.8.3或者可以发现主机可以跳过此步骤。

0个主机

0个主机

博主的ettercap是0.8.2版本,截至目前(2020.12.1),ettercap的最新版本是0.8.3,由于无法发现主机,所以更新到了0.8.3版本。

apt update

更新

apt list --upgradable | grep ettercap

查看最新版本

查看最新版本

apt install ettercap-common ettercap-graphical

更新到0.8.3版本

更新中

ettercap -G

使用ettercap进行攻击

启动图形界面,选择网卡eth0,点击下图对勾

启动图形界面

点击左上角搜索标志(左数第二个),发现主机,点击右侧按钮(左数第三个)查看发现的主机列表。

发现22个ip地址

选中网关xxx.xxx.xxx.1,点击Add Target1、选中主机IP点击Add Target2。

点击右侧三个点,选择Targets可查看两个Targets。

当前目标

目标增删

两侧可以进行目标增删

查看连接

一、网安学习成长路线图

网安所有方向的技术点做的整理,形成各个领域的知识点汇总,它的用处就在于,你可以按照上面的知识点去找对应的学习资源,保证自己学得较为全面。
在这里插入图片描述

二、网安视频合集

观看零基础学习视频,看视频学习是最快捷也是最有效果的方式,跟着视频中老师的思路,从基础到深入,还是很容易入门的。
在这里插入图片描述

三、精品网安学习书籍

当我学到一定基础,有自己的理解能力的时候,会去阅读一些前辈整理的书籍或者手写的笔记资料,这些笔记详细记载了他们对一些技术点的理解,这些理解是比较独到,可以学到不一样的思路。
在这里插入图片描述

四、网络安全源码合集+工具包

光学理论是没用的,要学会跟着一起敲,要动手实操,才能将自己的所学运用到实际当中去,这时候可以搞点实战案例来学习。
在这里插入图片描述

五、网络安全面试题

最后就是大家最关心的网络安全面试题板块
在这里插入图片描述在这里插入图片描述

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化资料的朋友,可以点击这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

  • 10
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
What’s in This Book? This book contains a mix of theoretical and practical chapters. For the practical chapters, I’ve developed and made available a networking library called Canape Core, which you can use to build your own tools for protocol analysis and exploitation. I’ve also provided an example networked application called SuperFunkyChat, which implements a userto-user chat protocol. By following the discussions in the chapters, you can use the example application to learn the skills of protocol analysis and attack the sample network protocols. Here is a brief breakdown of each chapter: Chapter 1: The Basics of Networking This chapter describes the basics of computer networking with a particular focus on TCP/IP, which forms the basis of application-level network protocols. Subsequent chapters assume that you have a good grasp of the network basics. This chapter also introduces the approach I use to model application protocols. The model breaks down the application protocol into flexible layers and abstracts complex technical detail, allowing you to focus on the bespoke parts of the protocol you’re analyzing. Chapter 2: Capturing Application Traffic This chapter introduces the concepts of passive and active capture of network traffic, and it’s the first chapter to use the Canape Core network libraries for practical tasks. Chapter 3: Network Protocol Structures Download from finelybook www.finelybook.com 24This chapter contains details of the internal structures that are common across network protocols, such as the representation of numbers or human-readable text. When you’re analyzing captured network traffic, you can use this knowledge to quickly identify common structures, speeding up your analysis. Chapter 4: Advanced Application Traffic Capture This chapter explores a number of more advanced capture techniques that complement the examples in Chapter 2. The advanced capture techniques include configuring Network Address Translation to redirect traffic of interest and spoofing the address resolution protocol. Chapter 5: Analysis from the Wire This chapter introduces methods for analyzing captured network traffic using the passive and active techniques described in Chapter 2. In this chapter, we begin using the SuperFunkyChat application to generate example traffic. Chapter 6: Application Reverse Engineering This chapter describes techniques for reverse engineering networkconnected programs. Reverse engineering allows you to analyze a protocol without needing to capture example traffic. These methods also help to identify how custom encryption or obfuscation is implemented so you can better analyze traffic you’ve captured. Chapter 7: Network Protocol Security This chapter provides background information on techniques and cryptographic algorithms used to secure network protocols. Protecting the contents of network traffic from disclosure or tampering as it travels over public networks is of the utmost importance for network protocol security. Chapter 8: Implementing the Network Protocol This chapter explains techniques for implementing the application Download from finelybook www.finelybook.com 25network protocol in your own code so you can test the protocol’s behavior to find security weaknesses. Chapter 9: The Root Causes of Vulnerabilities This chapter describes common security vulnerabilities you’ll encounter in a network protocol. When you understand the root causes of vulnerabilities, you can more easily identify them during analysis. Chapter 10: Finding and Exploiting Security Vulnerabilities This chapter describes processes for finding security vulnerabilities based on the root causes in Chapter 9 and demonstrates a number of ways of exploiting them, including developing your own shell code and bypassing exploit mitigations through return-oriented programming. Appendix: Network Protocol Analysis Toolkit In the appendix, you’ll find descriptions of some of the tools I commonly use when performing network protocol analysis. Many of the tools are described briefly in the main body of the text as well. How to Use This Book If you want to start with a refresher on the basics of networking, read Chapter 1 first. When you’re familiar with the basics, proceed to Chapters 2, 3, and 5 for practical experience in capturing network traffic and learning the network protocol analysis process. With the knowledge of the principles of network traffic capture and analysis, you can then move on to Chapters 7 through 10 for practical information on how to find and exploit security vulnerabilities in these protocols. Chapters 4 and 6 contain more advanced information about additional capture techniques and application reverse engineering, so you can read them after you’ve read the other chapters if you prefer. For the practical examples, you’ll need to install .NET Core Download from finelybook www.finelybook.com 26(https://www.microsoft.com/net/core/), which is a cross-platform version of the .NET runtime from Microsoft that works on Windows, Linux, and macOS. You can then download releases for Canape Core from https://github.com/tyranid/CANAPE.Core/releases/ and SuperFunkyChat from https://github.com/tyranid/ExampleChatApplication/releases/; both use .NET Core as the runtime. Links to each site are available with the book’s resources at https://www.nostarch.com/networkprotocols/. To execute the example Canape Core scripts, you’ll need to use the CANAPE.Cli application, which will be in the release package downloaded from the Canape Core Github repository. Execute the script with the following command line, replacing script.csx with the name of the script you want to execute.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值