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

推荐订阅源

Project Zero
Project Zero
月光博客
月光博客
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
O
OpenAI News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Know Your Adversary
Know Your Adversary
Last Week in AI
Last Week in AI
S
Securelist
Engineering at Meta
Engineering at Meta
博客园 - 司徒正美
P
Privacy & Cybersecurity Law Blog
T
Tailwind CSS Blog
F
Fortinet All Blogs
博客园 - 三生石上(FineUI控件)
Scott Helme
Scott Helme
MyScale Blog
MyScale Blog
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
C
Cisco Blogs
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
小众软件
小众软件
U
Unit 42
Microsoft Azure Blog
Microsoft Azure Blog
Hacker News: Ask HN
Hacker News: Ask HN
Hugging Face - Blog
Hugging Face - Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
SecWiki News
SecWiki News
宝玉的分享
宝玉的分享
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
Lohrmann on Cybersecurity
IT之家
IT之家
Security Archives - TechRepublic
Security Archives - TechRepublic
I
InfoQ
S
Security @ Cisco Blogs
Webroot Blog
Webroot Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
F
Full Disclosure
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The GitHub Blog
The GitHub Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Jina AI
Jina AI
Cyberwarzone
Cyberwarzone
人人都是产品经理
人人都是产品经理
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
B
Blog RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - 步孤天

程序员去新加坡打工的杂事记录 基于Bert的中文评价情感分析 (转载)DeepSeek+LoRA+FastAPI-微调大模型并暴露接口给后端调用 用YOLOv5截取出短剧的人物 Chromium源码分析五:写一个利用ipc+protobuf通信的demo Chromium源码分析四:RunLoop、Bind、scoped_refptr Chromium源码分析三:Chromium中用到的设计模式 Chromium源码分析二:LifeofaPixel.pdf Chromium源码分析一:基础知识 交叉编译valgrind在嵌入式设备上调试程序 gerrit 反向代理从 apache 换成 nginx 之后项目页报错“The page you requested was not found, or you do not have permission to view this page” golang实现一个简单的文件浏览下载功能代码示例 六十花甲子纳音表中的五行是怎么算出来的 df查看30GB的磁盘满了而du -sh查看磁盘占用只有6GB centos7+mariadb安装在线评判系统 如何去掉Linux vim文本中的^M 如何从超大(10G)sql语句文本中分离出需要的部分 golang如何打印变量类型,golang list如何把元素转换为可用类型 数据库文件导入报错"MySQL server has gone away"
如何在Linux上用tshark命令把抓包中follow的二进制流保存成文件
步孤天 · 2022-11-25 · via 博客园 - 步孤天

背景

用wireshark windows版本把视频流保存出来,结果只有抓包的一半,另一半丢失了。
为了验证是视频流的问题还是wireshark的问题。不得已,研究起了tshark,最终确定wireshark 400MB抓包文件的前200MB。

tshark是可以在linux命令行中运行的wireshark工具,分析tcpdump抓的包非常方便,但如果抓的包是视频流,需要把视频流保存出来应该怎么办?
原生的命令是没有的。(也不知道有没有,反正是搜了一下午都没找到)
"-w"命令是把一种抓包文件输出成另一种抓包文件;
"-z"相当于wireshark的追踪流,但是没有另存为选项;

解决方案

用脚本
参考:https://osqa-ask.wireshark.org/questions/53747/scripting-follow-tcp-stream-save-as-raw/
也就是下面的脚本:

infile=in.pcap
outfile=out
ext=txt
for stream in $(tshark -nlr $infile -Y tcp.flags.syn==1 -T fields -e tcp.stream | sort -n | uniq | sed 's/\r//')
do
    echo "Processing stream $stream: ${outfile}_${stream}.${ext}"
    tshark -nlr $infile -qz "follow,tcp,raw,$stream" | tail -n +7 | sed 's/^\s\+//g' | xxd -r -p > ${outfile}_${stream}.${ext}
done

但我知道流信息,所以就简化成了

infile=222.cap
outfile=out
ext=ts
stream=0
echo "Processing stream $stream: ${outfile}_${stream}.${ext}"
tshark -nlr $infile -qz "follow,tcp,raw,$stream" | tail -n +7 | sed 's/^\s\+//g' | xxd -r -p > ${outfile}_${stream}.${ext}

不过tshark应该也不完善,10分钟的视频流,wireshark保存了5分钟的,tshark保存了9分钟的,最终确定wireshark追踪400MB的流文件只能保存前200MB的。