当前位置:网站首页>Technology sharing | packet capturing analysis TCP protocol
Technology sharing | packet capturing analysis TCP protocol
2022-07-06 19:59:00 【Hua Weiyun】
This article is excerpted from the internal textbook of Hogwarts testing and development society
TCP The protocol is in the transport layer , A connection oriented 、 reliable 、 Transport layer communication protocol based on byte stream .
Environmental preparation
Classify interface testing tools , It can be classified as follows :
- Network sniffer tool :tcpdump,wireshark
- Agent tools :fiddler,charles,anyproxyburpsuite,mitmproxy
- Analysis tools :curl,postman,chrome Devtool
Caught analysis TCP agreement
tcpdump
tcpdump Is a The of packets transmitted over a network “ head ” Completely intercepted to provide analysis Tools for . It supports for network layer 、 agreement 、 host 、 Network or port filtering , And provide and、or、not And other logical statements to remove useless information .
Give Way tcpdump Always monitor 443 port , If there is any difference, enter it into log In file
sudo tcpdump port 443 -v -w /tmp/tcp.log
Use this command , Will put the report in the directory /tmp/tcp.log
in .
Common parameters | meaning |
---|---|
port 443 | monitor 443 port |
-v | Output more detailed information |
-w | Write data to log in |
wireshark
wireshark It is also a network sniffing tool , In addition to having tcpdump function , There are more extensions , For example, analysis tools , But in interface testing , The process of capturing packets is often carried out on the server , Servers generally do not provide UI Interface , therefore wireshark Unable to work on server , Can only use tcpdump Grab bag generation log, And then log Import wireshark Use , There is UI Analysis on the client of the interface .
Caught analysis TCP agreement
Grab one http Of get request :
- Search on Baidu mp3
http://www.baidu.com/s?wd=mp3
- use tcpdump Intercept this get request , And generate log
- use wireshark open tcpdump Generated log
Use wireshark see log:
log The first few messages are three handshakes . Because the channel is unreliable , Before sending the data , It is necessary to ensure channel stability , And three handshakes are like the following operations :
- The first handshake : When establishing a connection , The client sends syn package (syn=j) To the server , And enter SYN_SENT state , Wait for server to confirm .
- The second handshake : Server received syn package , Must confirm customer's SYN(ack=j+1), At the same time, I also send a SYN package (seq=k), namely SYN+ACK package , At this time, the server enters SYN_RECV state ;
- The third handshake : Client receives server's SYN+ACK package , Send confirmation package to server ACK(ack=k+1), This package has been sent , Client and server access ESTABLISHED(TCP Successful connection ) state , Complete three handshakes .
After three handshakes , Can further communicate , It looks like this :
At the end of the communication , Four waves are also required :
- First wave : The client sends a... To the server FIN, Request to turn off data transfer .
- Second wave : The server received... From the client FIN, Send a ACK, among ack The value is equal to the FIN+SEQ.
- Third wave : The server sends a... To the client FIN, Tell client application to close .
- Fourth wave : The client receives... From the server FIN, Reply to one ACK To the server . among ack The value is equal to the FIN+SEQ.
Be careful : A request may be divided into multiple packets , So is a data , So in wireshark You'll see a lot of bags .
边栏推荐
- 1805. Number of different integers in the string
- 算法面试经典100题,Android程序员最新职业规划
- Phoenix Architecture 2 - accessing remote services
- 22-07-05 七牛云存储图片、用户头像上传
- 腾讯云数据库公有云市场稳居TOP 2!
- Tencent T3 teaches you hand in hand. It's really delicious
- MySQL information schema learning (II) -- InnoDB table
- DOM operation
- Period compression filter
- Linear distance between two points of cesium
猜你喜欢
深入浅出,面试突击版
腾讯架构师首发,2022Android面试笔试总结
腾讯字节阿里小米京东大厂Offer拿到手软,老师讲的真棒
腾讯T3手把手教你,真的太香了
Transformer model (pytorch code explanation)
Interview assault 63: how to remove duplication in MySQL?
The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
Leetcode 30. Concatenate substrings of all words
Speech recognition (ASR) paper selection: talcs: an open source Mandarin English code switching corps and a speech
激进技术派 vs 项目保守派的微服务架构之争
随机推荐
From spark csc. csr_ Matrix generate adjacency matrix
redisson bug分析
Appx代码签名指南
颜色(color)转换为三刺激值(r/g/b)(干股)
理解 YOLOV1 第二篇 预测阶段 非极大值抑制(NMS)
腾讯字节等大厂面试真题汇总,网易架构师深入讲解Android开发
Analysis of rainwater connection
logstash高速入口
[infrastructure] deployment and configuration of Flink / Flink CDC (MySQL / es)
使用ssh连接被拒
Alibaba数据源Druid可视化监控配置
Microservice architecture debate between radical technologists vs Project conservatives
BUUCTF---Reverse---easyre
Standardized QCI characteristics
爬虫(14) - Scrapy-Redis分布式爬虫(1) | 详解
LeetCode_ Gray code_ Medium_ 89. Gray code
mod_ WSGI + pymssql path SQL server seat
案例 ①|主机安全建设:3个层级,11大能力的最佳实践
Guangzhou's first data security summit will open in Baiyun District
精彩编码 【进制转换】