wireshark是非常流行的網絡封包分析軟件,功能十分強大。可以截取各種網絡封包,顯示網絡封包的詳細信息。使用wireshark的人必須了解網絡協議,否則就看不懂wireshark了。
為了安全考慮,wireshark只能查看封包,而不能修改封包的內容,或者發送封包。
wireshark能獲取HTTP,也能獲取HTTPS,但是不能解密HTTPS,所以wireshark看不懂HTTPS中的內容,總結,如果是處理HTTP,HTTPS 還是用Fiddler, 其他協議比如TCP,UDP 就用wireshark.
隨便打開一個包
- Frame:物理層的數據幀概況。
- Ethernet II:數據鏈路層以太網幀頭部信息。
- Internet Protocol Version 4:互聯網層IP包頭部信息。
- Transmission Control Protocol:傳輸層的數據段頭部信息,此處是TCP協議。
- User Datagram Protocol:UDP協議
- Hypertext Transfer Protocol:應用層的信息,此處是HTTP協議
各層分析
一、物理層Frame
1 -Frame 5: 66 bytes on wire (528 bits), 66 bytes captured(捕獲) (528 bits) on interface 0 //5號幀,對方發送66字節,實際收到66字節
2
3 -Interface id: 0 (\Device\NPF_{37239901-4A63-419C-9693-97957A8232CD}) //接口id為0
4
5 -Encapsulation type: Ethernet (1) //封裝類型
6
7 -Arrival Time: Jul 5, 2017 15:14:31.865685000 //捕獲日期和時間(中國標准時間)
8
9 -[Time shift for this packet: 0.000000000 seconds]
10 -Epoch Time: 1499238871.865685000 seconds
11 -[Time delta from previous captured frame: 0.006861000 seconds] //與前一包時間間隔
12 -[Time delta from previous displayed frame: 0.006861000 seconds]
13 -[Time since reference or first frame: 0.613985000 seconds] //#此包與第一幀的時間間隔
14
15 -Frame Number: 5 //幀序號
16 -Frame Length: 66 bytes (528 bits) //幀長度
17 -Capture Length: 66 bytes (528 bits) //捕獲字節長度
18 -[Frame is marked: False] //是否做了標記
19 -[Frame is ignored: False] //是否被忽略
20 -[Protocols in frame: eth:ethertype:ip:tcp] //幀內封裝的協議層次結構
21 -[Coloring Rule Name: HTTP] //着色標記的協議名稱
22 -[Coloring Rule String: http || tcp.port == 80 || http2] //着色規則顯示的字符串
二、數據鏈路層以太網幀頭部信息
1 -Ethernet II, Src: Tp-LinkT_f5:3e:62 (c0:61:18:f5:3e:62), Dst: IntelCor_09:65:a5 (58:fb:84:09:65:a5)
2
3 - Destination: IntelCor_09:65:a5 (58:fb:84:09:65:a5) //目的MAC地址
4 - Source: Tp-LinkT_f5:3e:62 (c0:61:18:f5:3e:62) //源MAC地址(就是我電腦的MAC地址)
5 - Type: IPv4 (0x0800) //0x0800表示使用IP協議
三、互聯網層IP包頭部信息
1 Internet Protocol Version 4, Src: 192.168.2.112, Dst: 116.211.185.142
2 0100 .... = Version: 4 //IPV4協議
3 .... 0101 = Header Length: 20 bytes (5) //包頭長度
4
5 -Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT) //差分服務字段
6 -Total Length: 52 //IP包總長度
7 -Identification: 0x3849 (14409) //標識字段
8 -Flags: 0x02 (Don't Fragment) //標記字段
9 -Fragment offset: 0 //分段偏移量
10 -Time to live: 128 //生存期TTL
11 -Protocol: TCP (6) //此包內封裝的上層協議為TCP
12 -Header checksum: 0xd100 [validation disabled] //頭部數據的校驗和
13 -[Header checksum status: Unverified] //頭部數據校驗狀態
14 -Source: 192.168.2.112 //源IP地址
15 -Destination: 116.211.185.142 //目的IP地址
16 -[Destination GeoIP: Unknown]
17 -[Destination GeoIP: Unknown]
四、傳輸層TCP數據段頭部信息
1 Transmission Control Protocol, Src Port: 60606, Dst Port: 80, Seq: 0, Len: 0
2
3 -Source Port: 60606 //源端口號(ecbe)
4 -Destination Port: 80 //目的端口號(0050)
5 -[Stream index: 0]
6 -[TCP Segment Len: 0]
7 -Sequence number: 0 (relative sequence number) //序列號(相對序列號)(四個字節fd 3e dd a2)
8 -Acknowledgment number: 0 //確認號(四個字節00 00 00 00)
9 -Header Length: 32 bytes //頭部長度(0x80)
10 -Flags: 0x002 (SYN) //TCP標記字段
11 -Window size value: 8192 //流量控制的窗口大小(20 00)
12 -[Calculated window size: 8192]
13 -Checksum: 0x97ad [unverified] //數據段的校驗和(97 ad)
14 -[Checksum Status: Unverified]
15 -Urgent pointer: 0 //緊急指針(00 00)
16 -Options: (12 bytes), Maximum segment size, No-Operation (NOP), Window scale, No-Operation (NOP), No-Operation (NOP), SACK permitted //選項(可變長度
五、UDP數據段首部
1 User Datagram Protocol, Src Port: 7273, Dst Port: 15030
2 -Source Port: 7273 //源端口(1c 69)
3 -Destination Port: 15030 //目的端口(3a 6b)
4 -Length: 1410 //長度(05 82)
5 -Checksum: 0xd729 [unverified] //校驗和(d7 29)
6 -[Checksum Status: Unverified]
7 -[Stream index: 6335]
參考博客:https://my.oschina.net/u/1585857/blog/479306
Wireshark的常見幾種過濾方法
-Length: 1410 //長度(05 82)