惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 三国梦回

spring boot 项目中oracle datasource设置schema spring cloud项目中,在bootstrap.yml中指定了active的profile,结果不生效 线上服务重启后,从nacos取不到配置了,怎么回事 nginx location没学好,把自己坑了一把 技术问题记录20260125 最近遇到的两个技术问题记录 linux服务器文件上传失败 线上遇到的redis和数据库数据未同步问题、redisson内部实现问题 复杂业务系统线上问题排查过程 nacos中配了一个数字,springboot取回来怎么变了 一个java空指针异常的解决过程 简单记录下最近2个月完成的线上系统迁移工作 centos停服,迁移centos7.3系统到新搭建的openEuler 端口telnet不通排查过程 https证书中的subject alternative name字段作用及如何生成含该字段的证书 linux中如何判断一个rpm是手动安装还是通过yum安装的 对接服务升级后仅支持tls1.2,jdk1.7默认使用tls1.0,导致调用失败 分页查询不加排序有问题,加了排序怎么还有问题 利用mybatis拦截器记录sql,辅助我们建立索引(二) 利用mybatis拦截器记录sql,辅助我们建立索引(一) sql server版本太老,java客户端连接失败问题定位
网络抓包文件太大,如何切分
三国梦回 · 2025-01-22 · via 博客园 - 三国梦回

背景

节前最后几天了,随便写点水文吧,今天就记录一下,当我们拿到的网络抓包文件太大,应该怎么分析。

一般来说,我们个人抓包的话,linux上用tcpdump比较多,抓的时候也会用捕获表达式,抓出来的包一般不大,用wireshark分析就很容易。

但是,前一阵的一个晚上,dba突然找我,看能不能帮忙一起分析一个网络抓包文件,连了会议后一看,大小有4g,这么大的包,wireshark打开都很是困难,分析也很卡。

这么大的包,怎么来的呢,原来是网络同事直接在路由器上抓的,过滤条件就是某个数据库服务器的ip:1433端口(sql server数据库)。既然过滤了,包还这么大?问了下,原来在路由器上抓了整整一个半小时,然后这个库流量又大,所以最终就有4g。

dba的诉求是,某个数据库客户端发了某些sql,导致把数据库服务器搞死了,现在就是要找出来是哪个客户端,哪个sql。

最终呢,我只是给dba同事说了下,怎么拆分包,怎么查看包里的sql;后续忙起来后,我也没问进度,估计已经解决了吧。

这里就简单记录下,遇到这种大的包,怎么拆分。

editcap

editcap这个命令是wireshark自带的,一般就在wireshark目录下,像我这边在:C:\Program Files\Wireshark\editcap.exe,我一般会加入到环境变量PATH。

介绍如下:

Editcap is a program that reads some or all of the captured packets from the infile, optionally converts them in various ways and writes the resulting packets to the capture outfile (or outfiles).

即,可以读取pcap/pcapng类型的文件,通过各种方式进行一些处理、转换,然后将结果写入到另外的文件。

说明文档:

image-20250122161700554

在我们场景中,一般使用如下几个选项就行了:

image-20250122162346067

按时间

按包的开始时间

-A

Saves only the packets whose timestamp is on or after start time. The time is given in the following format YYYY-MM-DD HH:MM:SS[.nnnnnnnnn] (the decimal and fractional seconds are optional).

比如,对于如下这个包:

editcap  file20230325.pcap file20230325-after-pm-3.pcap -A "2023-03-25 15:00:00"

其中,file20230325-after-pm-3.pcap就是要保存的文件名,-A就是选择15点以后的报文。

可以看下图示例效果:

image-20250122162808207

获取包的时间范围

但你可能有个疑问,如果不知道包的时间范围呢?

可以先用如下命令获取:

capinfos file20230325.pcap

image-20250122163028108

按包的结束时间

-B

Saves only the packets whose timestamp is before stop time. The time is given in the following format YYYY-MM-DD HH:MM:SS[.nnnnnnnnn] (the decimal and fractional seconds are optional).

editcap  file20230325.pcap file20230325-start3-end310.pcap -A "2023-03-25 15:00:00" -B "2023-03-25 15:10:00"

image-20250122163358633

按包的数量

-c <packets per file>
Splits the packet output to different files based on uniform packet counts with a maximum of <packets per file> each. Each output file will be created with a suffix -nnnnn, starting with 00000. If the specified number of packets is written to the output file, the next output file is opened. The default is to use a single output file.

这个是把大文件拆分,按照包的数量,届时,每个子文件里的包的数量是一致的。

editcap  file20230325.pcap -c 100000 file20230325-by-packets-number.pcap

效果:

image-20250122163917848

但可以看到,每个里面都有1w个包

image-20250122164009642

image-20250122164036502

按时间间隔

-i

Splits the packet output to different files based on uniform time intervals using a maximum interval of each. Floating point values (e.g. 0.5) are allowed. Each output file will be created with a suffix -nnnnn, starting with 00000. If packets for the specified time interval are written to the output file, the next output file is opened. The default is to use a single output file.

单位是秒。

我们示例文件总共是1000多秒。

image-20250122164317496

editcap  file20230325.pcap -i 100 file20230325-by-seconds.pcap

image-20250122164429164

image-20250122164648284

image-20250122164708275

组合时间范围、包的数量两个选项

editcap  file20230325.pcap file20230325-start3-end310-packets-number.pcap -A "2023-03-25 15:00:00" -B "2023-03-25 15:10:00" -c 10000

image-20250122164946525

这个就是,本来按照时间范围,只会生成一个包。加了-C后,就继续按包的数量拆分了。

组合时间范围、时间间隔两个选项

editcap  file20230325.pcap file20230325-start3-end310-seconds.pcap -A "2023-03-25 15:00:00" -B "2023-03-25 15:10:00" -i 100

image-20250122170035066

按序号

image-20250122170742237

命令中可以指定序号,但是默认是删掉这些序号的包。

-r

Reverse the packet selection. Causes the packets whose packet numbers are specified on the command line to be written to the output capture file, instead of discarding them.

加了-r后,意味着反选。即保留这些序号的包。

官方示例:
To limit a capture file to packets from number 200 to 750 (inclusive) use:

editcap -r capture.pcapng small.pcapng 200-750

image-20250122170404907

我这边也试了下:

editcap  -r file20230325.pcap file20230325-frame-number.pcap 1-100

image-20250122170654536

总结

也没啥好总结的。