# wireshark **Repository Path**: zhang_renyang/wireshark ## Basic Information - **Project Name**: wireshark - **Description**: wireshark - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2018-03-29 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## wireshark有什么用 1. 分析网络底层协议 2. 解决网络故障问题 3. 找寻网络安全问题 ## 安装 - [download](https://www.wireshark.org/download.html) - [wiresharkbook](http://wiresharkbook.com/) ## 抓包原理 - win/libcap 抓包时的依赖的库文件 - Capture 捕包引擎,利用libpcap/winpcap从底层抓取网络数据包,libpcap/wincap提供了通用的抓包接口,能从不同类型的网络接口(以太网)抓取数据包 - Wiretap 格式支持,从抓包文件中读取数据包,支持多种文件格式 - Core 核心引擎,通过函数调用将其他模块连接在一起,起到联动调度的作用,Epan wireshark Packetage Analyzing 包分析引擎 - Protocal Tree 保存数据包的协议信息,wireshark采用树行结构,解析协议报文时只需要从根节点通过函数句柄一次调用各层 - Dissectors: 在epan/dissector目录下,各种协议解码器,支持700+中协议解析 - Plugins 一些协议解码器以插件形式实现 - Display-Filters 显示过滤引擎,源码epan/dfilter目录 - GTK1/2 图形处理工具,处理用户的输入输出显示 ## 快速抓包 - 初始化界面 - 选择网卡 - 停止抓包 - 保存数据包 ## 界面 - 标题栏 - 主菜单栏 - 工具栏 - 数据包过滤栏 - 数据包列表区 - 数据包详细区 - 数据包字节区 - 数据包统计区 ## 过滤器设置 ### 抓包过滤器 #### 语法 协议+方向+类型+值 - 类型 host port - 方向 src dst - 协议 ether ip tcp udp http ftp - 逻辑运算符 && || ! #### 例子 - src host 192.168.1.1 && dst port 80 抓取来源地址为192.168.1.1,并且目的为80端口的流量 - host 192.168.1.1|| host host 192.168.1.2 抓取192.168.1.1或192.168.1.2的流量 - !broadcast 不抓取广播包 ##### 过滤MAC - ether host 00:00:00:00:00:00 网卡主机 - ether src host 00:00:00:00:00:00 来源MAC - ether dst host 00:00:00:00:00:00 目标MAC ##### 过滤IP - host 192.168.1.1 - src host 192.168.1.1 - det host 192.168.1.1 ##### 过滤端口 - port 80 - !port 80 - dst port 80 - src port 80 ##### 过滤协议 - arp - tcp ##### 综合过滤 - host 192.168.1.100 && port 8080 ### 显示过滤器 #### 语法 - 比较操作符 == != > < >= <= - 逻辑操作符 and or xor(有且仅有一个条件被满足) not - IP地址 ip addr ip.src ip.dst - 端口过滤 tcp.port tcp.srcport tcp.dstport tcp.flags.syn tcp.flag.ack - 协议过滤 arp ip icmp udp tcp bootp dns #### 案例 #### 过滤IP - ip.addr == 192.168.0.1 - ip.src == 192.168.0.1 - ip.dst == 192.168.0.1 - ip.src == 192.168.0.1 and ip.dst == 192.168.0.1 #### 过滤端口 - tcp.port == 80 - tcp.srcport == 80 - tcp.dstport == 80 - tcp.flags.sync == 1 #### 过滤协议 - arp - tcp - udp - not http - not arp #### 案例 - ip.src == 192.168.0.1 and tcp.dstport == 80 - ip.addr == 192.168.0.1 and udp.port == 60000 ### follow tcp