|
|
|
@ -1,16 +1,16 @@
|
|
|
|
|
%# -*- coding: utf-8-unix -*-
|
|
|
|
|
|
|
|
|
|
\section{Wireshark软件使用与ARP分析}
|
|
|
|
|
\label{sec:c1_s1}
|
|
|
|
|
\label{sec:c:wireshark:s:arp}
|
|
|
|
|
|
|
|
|
|
\subsection{实验目的}
|
|
|
|
|
\label{subsec:c1_s1_object}
|
|
|
|
|
\label{subsec:c:wireshark:s:arp_object}
|
|
|
|
|
|
|
|
|
|
本实验旨在让学生掌握Wireshark的基本操作,使用捕获过滤器和显示过滤器,
|
|
|
|
|
抓取和分析有线局域网的数据包;掌握以太网MAC帧的基本结构,掌握ARP协议的特点及工作过程。
|
|
|
|
|
|
|
|
|
|
\subsection{实验内容}
|
|
|
|
|
\label{subsec:c1_s1_content}
|
|
|
|
|
\label{subsec:c:wireshark:s:arp_content}
|
|
|
|
|
|
|
|
|
|
练习使用Wireshark抓取相关有线局域网的数据包并进行分析。
|
|
|
|
|
|
|
|
|
@ -27,7 +27,7 @@
|
|
|
|
|
\end{enumerate}
|
|
|
|
|
|
|
|
|
|
\subsection{实验原理}
|
|
|
|
|
\label{subsec:c1_s1_principle}
|
|
|
|
|
\label{subsec:c:wireshark:s:arp_principle}
|
|
|
|
|
|
|
|
|
|
\subsubsection{Wireshark简介}
|
|
|
|
|
|
|
|
|
@ -46,7 +46,7 @@ Wireshark可以在Windows、Linux和MacOS操作系统中运行,
|
|
|
|
|
\subsubsection{以太网MAC帧格式}
|
|
|
|
|
|
|
|
|
|
本实验基于使用最广泛的有线局域网(以太网Ethernet II),
|
|
|
|
|
以太网的帧结构如表\ref{tab:c1_eth-format}所示。
|
|
|
|
|
以太网的帧结构如表\ref{tab:c:wireshark_eth-format}所示。
|
|
|
|
|
其中,MAC地址(Media Access Control Address,媒体存取控制位址)或称物理地址(Physical Address),
|
|
|
|
|
用于在网络中标识网卡。MAC地址的长度为48位(6个字节),
|
|
|
|
|
通常表示为12个16进制数,如:00-16-EA-AE-3C-40。
|
|
|
|
@ -54,13 +54,16 @@ Wireshark可以在Windows、Linux和MacOS操作系统中运行,
|
|
|
|
|
它由IEEE分配;
|
|
|
|
|
而后3个字节的16进制数AE-3C-40代表该制造商所生产的某个网络产品(如网卡)的系列号。
|
|
|
|
|
|
|
|
|
|
\begin{table}[!hpb]
|
|
|
|
|
\renewcommand{\arraystretch}{1.5}
|
|
|
|
|
\begin{table}[!ht]
|
|
|
|
|
\small
|
|
|
|
|
\centering
|
|
|
|
|
\caption{以太网帧格式}
|
|
|
|
|
\label{tab:c1_eth-format}
|
|
|
|
|
\begin{tabular}{cccccc} \toprule
|
|
|
|
|
前导字符 & 目的MAC地址 & 源MAC地址 & 类型 & IP数据报 & 帧校验\\ \midrule
|
|
|
|
|
8字节 & 6字节 & 6字节 & 2字节 & & 4字节 \\ \bottomrule
|
|
|
|
|
\label{tab:c:wireshark_eth-format}
|
|
|
|
|
\begin{tabular}{|c|c|c|c|c|c|} \hline
|
|
|
|
|
\heiti 前导字符 & \heiti 目的MAC地址 & \heiti 源MAC地址 &
|
|
|
|
|
\heiti 类型 & \heiti IP数据报 & \heiti 帧校验\\ \hline
|
|
|
|
|
8字节 & 6字节 & 6字节 & 2字节 & - & 4字节 \\ \hline
|
|
|
|
|
\end{tabular}
|
|
|
|
|
\end{table}
|
|
|
|
|
|
|
|
|
@ -90,7 +93,7 @@ ARP解析的过程(主机A和B不在同一网段的情况请参阅课本相关
|
|
|
|
|
同时将IP数据报进行封装后发送出去。
|
|
|
|
|
\end{enumerate}
|
|
|
|
|
|
|
|
|
|
ARP报文结构如图\ref{fig:c1_arp-format}所示,
|
|
|
|
|
ARP报文结构如图\ref{fig:c:wireshark_arp-format}所示,
|
|
|
|
|
ARP报文总长度为28字节,MAC地址长度为6字节,
|
|
|
|
|
IP地址长度为4字节。每个字段的含义如下:
|
|
|
|
|
|
|
|
|
@ -103,11 +106,11 @@ IP地址长度为4字节。每个字段的含义如下:
|
|
|
|
|
ARP 请求为1,ARP 响应为2,RARP 请求为3,RARP 响应为4。
|
|
|
|
|
\end{itemize}
|
|
|
|
|
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\includegraphics[width=9cm]{c1_arp-format}
|
|
|
|
|
\includegraphics[width=9cm]{arp-format}
|
|
|
|
|
\caption{ARP报文结构示意图}
|
|
|
|
|
\label{fig:c1_arp-format}
|
|
|
|
|
\label{fig:c:wireshark_arp-format}
|
|
|
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
\subsubsection{实验方法及手段}
|
|
|
|
@ -117,7 +120,7 @@ IP地址长度为4字节。每个字段的含义如下:
|
|
|
|
|
掌握以太网MAC帧和IP数据报的结构以及ARP协议的工作过程。
|
|
|
|
|
|
|
|
|
|
\subsection{实验条件}
|
|
|
|
|
\label{subsec:c1_s1_requirement}
|
|
|
|
|
\label{subsec:c:wireshark:s:arp_requirement}
|
|
|
|
|
|
|
|
|
|
\begin{itemize}
|
|
|
|
|
\item 装有Wireshark软件的PC机一台(Windows或Linux操作系统);
|
|
|
|
@ -125,7 +128,7 @@ IP地址长度为4字节。每个字段的含义如下:
|
|
|
|
|
\end{itemize}
|
|
|
|
|
|
|
|
|
|
\subsection{实验步骤}
|
|
|
|
|
\label{subsec:c1_s1_procedure}
|
|
|
|
|
\label{subsec:c:wireshark:s:arp_procedure}
|
|
|
|
|
|
|
|
|
|
\subsubsection{WireShark基本使用}
|
|
|
|
|
|
|
|
|
@ -133,39 +136,39 @@ IP地址长度为4字节。每个字段的含义如下:
|
|
|
|
|
\item 通过Wireshark官网下载最新版软件,按默认选项安装。
|
|
|
|
|
\item 运行Wireshark软件,程序界面会显示当前的网络接口列表,
|
|
|
|
|
选择要抓取的网络接口,双击开始抓包,
|
|
|
|
|
Wireshark软件选择网络接口的界面如图\ref{fig:c1_wireshark-boot-ui}所示。
|
|
|
|
|
Wireshark软件选择网络接口的界面如图\ref{fig:c:wireshark_wireshark-boot-ui}所示。
|
|
|
|
|
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\includegraphics[width=16cm]{c1_wireshark-boot-ui}
|
|
|
|
|
\includegraphics[width=12cm]{wireshark-boot-ui}
|
|
|
|
|
\caption{Wireshark软件启动界面}
|
|
|
|
|
\label{fig:c1_wireshark-boot-ui}
|
|
|
|
|
\label{fig:c:wireshark_wireshark-boot-ui}
|
|
|
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
\item 点击工具栏上红色的stop按钮停止抓包。
|
|
|
|
|
\item 菜单、工具栏、状态栏和主窗口如图\ref{fig:c1_wireshark-main-ui}所示,
|
|
|
|
|
\item 菜单、工具栏、状态栏和主窗口如图\ref{fig:c:wireshark_wireshark-main-ui}所示,
|
|
|
|
|
可以根据自己需要通过菜单“视图”以及“编辑/首选项/外观”的相关选项对基本设置进行更改。
|
|
|
|
|
例如图\ref{fig:c1_wireshark-setup-ui}中的语言、字体缩放、颜色、布局等项目。
|
|
|
|
|
例如图\ref{fig:c:wireshark_wireshark-setup-ui}中的语言、字体缩放、颜色、布局等项目。
|
|
|
|
|
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\includegraphics[width=16cm]{c1_wireshark-main-ui}
|
|
|
|
|
\includegraphics[width=12cm]{wireshark-main-ui}
|
|
|
|
|
\caption{Wireshark主窗口界面}
|
|
|
|
|
\label{fig:c1_wireshark-main-ui}
|
|
|
|
|
\label{fig:c:wireshark_wireshark-main-ui}
|
|
|
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\includegraphics[width=16cm]{c1_wireshark-setup-ui}
|
|
|
|
|
\includegraphics[width=12cm]{wireshark-setup-ui}
|
|
|
|
|
\caption{Wireshark的设置界面}
|
|
|
|
|
\label{fig:c1_wireshark-setup-ui}
|
|
|
|
|
\label{fig:c:wireshark_wireshark-setup-ui}
|
|
|
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
\item 使用“显示过滤器”可以方便地从捕获的数据包中筛选出我们想要观察的某些数据包信息。
|
|
|
|
|
显示过滤器支持若干的过滤选项:
|
|
|
|
|
源MAC、目的MAC、源IP、目的IP、TCP/UDP传输协议、
|
|
|
|
|
应用层协议(HTTP, DHCP)、源端口Port、目的端口Port等。
|
|
|
|
|
在显示过滤器栏中输入过滤表达式(图\ref{fig:c1_wireshark-filters}),
|
|
|
|
|
在显示过滤器栏中输入过滤表达式(图\ref{fig:c:wireshark_wireshark-filters}),
|
|
|
|
|
例如下面的命令:
|
|
|
|
|
更详细的显示过滤语法可以查看WireShark的官方文档
|
|
|
|
|
\footnote{
|
|
|
|
@ -174,67 +177,67 @@ IP地址长度为4字节。每个字段的含义如下:
|
|
|
|
|
}。
|
|
|
|
|
|
|
|
|
|
\begin{itemize}
|
|
|
|
|
\item \texttt{arp} \hfill \textit{//显示arp协议报文}
|
|
|
|
|
\item \texttt{ip.src == a.b.c.d \&\& icmp} \hfill \textit{//显示源地址为a.b.c.d的icmp报文}
|
|
|
|
|
\item \texttt{arp~~~~~~~~~~~~~~~~~~~~~~~~//显示arp协议报文}
|
|
|
|
|
\item \texttt{ip.src == a.b.c.d \&\& icmp~~//显示源地址为a.b.c.d的icmp报文}
|
|
|
|
|
\end{itemize}
|
|
|
|
|
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\includegraphics[width=16cm]{c1_wireshark-filters}
|
|
|
|
|
\includegraphics[width=12cm]{wireshark-filters}
|
|
|
|
|
\caption{显示过滤规则的示例}
|
|
|
|
|
\label{fig:c1_wireshark-filters}
|
|
|
|
|
\label{fig:c:wireshark_wireshark-filters}
|
|
|
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
\item 通过主菜单“文件”/“导出特定分组”(如图\ref{fig:c1_wireshark-save}),
|
|
|
|
|
\item 通过主菜单“文件”/“导出特定分组”(如图\ref{fig:c:wireshark_wireshark-save}),
|
|
|
|
|
可以保存抓取的网络数据(也可以先选中某个包,只保存部分数据)。
|
|
|
|
|
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\includegraphics[width=16cm]{c1_wireshark-save}
|
|
|
|
|
\includegraphics[width=12cm]{wireshark-save}
|
|
|
|
|
\caption{操作主菜单保存数据文件}
|
|
|
|
|
\label{fig:c1_wireshark-save}
|
|
|
|
|
\label{fig:c:wireshark_wireshark-save}
|
|
|
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
\item 如果只抓取特定的数据包,
|
|
|
|
|
可以使用菜单“捕获”/”捕获过滤器”选定想要的类型
|
|
|
|
|
(如图\ref{fig:c1_wireshark-special-type})。
|
|
|
|
|
(如图\ref{fig:c:wireshark_wireshark-special-type})。
|
|
|
|
|
例如,选择“IPv4 only”,Wireshark只抓取ipv4类型的数据包。
|
|
|
|
|
Wireshark过滤器官方文档提供了更加全面详细的语法和常用示例
|
|
|
|
|
\footnote{\href{https://wiki.wireshark.org/CaptureFilters/\#Useful_Filters}
|
|
|
|
|
{WireShark常用过滤器语法}}。
|
|
|
|
|
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\includegraphics[width=16cm]{c1_wireshark-special-type}
|
|
|
|
|
\includegraphics[width=12cm]{wireshark-special-type}
|
|
|
|
|
\caption{选中特定的捕获类型}
|
|
|
|
|
\label{fig:c1_wireshark-special-type}
|
|
|
|
|
\label{fig:c:wireshark_wireshark-special-type}
|
|
|
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
\item Wireshark还提供了丰富的统计功能供用户选用,
|
|
|
|
|
如图\ref{fig:c1_wireshark-statistic}。
|
|
|
|
|
如图\ref{fig:c:wireshark_wireshark-statistic}。
|
|
|
|
|
更多文档可以查询Wireshark使用帮助
|
|
|
|
|
\footnote{\href{https://www.wireshark.org/\#learnWS}{WireShark学习手册}}。
|
|
|
|
|
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\includegraphics[width=16cm]{c1_wireshark-statistic}
|
|
|
|
|
\includegraphics[width=12cm]{wireshark-statistic}
|
|
|
|
|
\caption{统计功能}
|
|
|
|
|
\label{fig:c1_wireshark-statistic}
|
|
|
|
|
\label{fig:c:wireshark_wireshark-statistic}
|
|
|
|
|
\end{figure}
|
|
|
|
|
\end{enumerate}
|
|
|
|
|
|
|
|
|
|
\subsubsection{查看OUI信息}
|
|
|
|
|
查看本机MAC地址字段,查看OUI信息,搜索各厂商的OUI进行验证。
|
|
|
|
|
\subsubsection{分析以太网的帧结构}
|
|
|
|
|
选择其中一个数据包,点击Ethernet II展开(图\ref{fig:c1_eth-frame-detail}),
|
|
|
|
|
选择其中一个数据包,点击Ethernet II展开(图\ref{fig:c:wireshark_eth-frame-detail}),
|
|
|
|
|
查看MAC帧的各个字段。计算帧的长度,并与Wireshark的分析结果比较。
|
|
|
|
|
同时查看比较广播帧和单播帧的异同。
|
|
|
|
|
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\includegraphics[width=16cm]{c1_eth-frame-detail}
|
|
|
|
|
\includegraphics[width=12cm]{eth-frame-detail}
|
|
|
|
|
\caption{以太网帧结构展开界面}
|
|
|
|
|
\label{fig:c1_eth-frame-detail}
|
|
|
|
|
\label{fig:c:wireshark_eth-frame-detail}
|
|
|
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
\subsubsection{差错检测,FCS计算检验}
|
|
|
|
@ -244,16 +247,16 @@ IP地址长度为4字节。每个字段的含义如下:
|
|
|
|
|
\item 使用\texttt{arp –d}命令(其语法见图\ref{fig:arp-cmd}),清空本机已有的ARP缓存,
|
|
|
|
|
开启Wireshark,ping本机的同网段地址,在显示过滤器条框中输入“\texttt{arp}”,
|
|
|
|
|
观察捕获的ARP报文的各个字段,分析请求/响应的过程。
|
|
|
|
|
\begin{figure}[!htp]
|
|
|
|
|
\begin{figure}[!ht]
|
|
|
|
|
\centering
|
|
|
|
|
\begin{code}[text]
|
|
|
|
|
arp [-a [InetAddr] [-N IfaceAddr]] [-g [InetAddr] [-N IfaceAddr]]
|
|
|
|
|
[-d InetAddr [IfaceAddr]] [-s InetAddr EtherAddr [IfaceAddr]]
|
|
|
|
|
|
|
|
|
|
-a显示所有接口/特定接口的当前 ARP 缓存表。
|
|
|
|
|
-g 同-a。
|
|
|
|
|
-d删除所有/指定的IP地址项。
|
|
|
|
|
-s向ARP 缓存添加可将IP地址InetAddr解析成物理地址EtherAddr的静态项。
|
|
|
|
|
-a 显示所有接口/特定接口的当前 ARP 缓存表
|
|
|
|
|
-g 同-a
|
|
|
|
|
-d 删除所有/指定的IP地址项
|
|
|
|
|
-s 在ARP缓存中添加对应InetAddr地址的EtherAddr地址静态项
|
|
|
|
|
\end{code}
|
|
|
|
|
\caption{arp命令语法及参数}
|
|
|
|
|
\label{fig:arp-cmd}
|
|
|
|
@ -265,7 +268,7 @@ arp [-a [InetAddr] [-N IfaceAddr]] [-g [InetAddr] [-N IfaceAddr]]
|
|
|
|
|
\end{enumerate}
|
|
|
|
|
|
|
|
|
|
\subsection{思考题}
|
|
|
|
|
\label{subsec:c1_s1_rethink}
|
|
|
|
|
\label{subsec:c:wireshark:s:arp_rethink}
|
|
|
|
|
|
|
|
|
|
\begin{enumerate}
|
|
|
|
|
\item 使用了显示过滤器后,Wireshark的抓包工作量会减少吗?
|
|
|
|
@ -282,7 +285,7 @@ arp [-a [InetAddr] [-N IfaceAddr]] [-g [InetAddr] [-N IfaceAddr]]
|
|
|
|
|
\end{enumerate}
|
|
|
|
|
|
|
|
|
|
\subsection{考核方法}
|
|
|
|
|
\label{subsec:c1_s1_criterion}
|
|
|
|
|
\label{subsec:c:wireshark:s:arp_criterion}
|
|
|
|
|
|
|
|
|
|
考核分为现场考核和实验报告两个部分,具体如下。
|
|
|
|
|
报告内容应包含以下内容,相关的分析解释都需要截图证明,
|