Linux cooked-mode capture 格式转换
tcpdump抓包时,如果-i选项指定为一个网卡地址,那么抓取的数据包数据链路层是以太网头部;如果指定any,则以太网头部将被替换为linux cooked capture头部
# tcpdump -i any -w linux_sll.pcap
tcpdump: listening on any, link-type LINUX_SLL (Linux cooked), capture size bytes
# tcpdump -i eth1 -w enet.pcap
tcpdump: listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes
tcpdump抓包时可以通过 -y 选项来指定data link type,不过测试发现 -i 选项指定 any 时,不支持抓获的包的data link type 为以太网 :
# tcpdump -i any -w test.pcap -y EN10MB
tcpdump: EN10MB is not one of the DLTs supported by this device
# tcpdump -i eth1 -w test.pcap -y EN10MB
tcpdump: data link type EN10MB
#
这时,若需要将linux cooked capture格式的包转换为Ethernet格式,有那么几种方法:
1. 写代码读出每一个包后再改写到新文件(使用libpcap或者基于pcap头部结构体偏移);
2. tcpdump 3.0+ 版本下,可以用tcprewrite直接改写,这应该是最快捷的方法;
DLT Plugins
As of 3.0, tcprewrite uses plugins to support different DLT/Layer 2 types. This not only makes the
code easier to maintain, but also helps make things clearer for users regarding what is and isn't
supported. Each plugin may support reading and/or writing packets. By default, the plugin used to
read packets is also used for output, but you can override the output plugin using the --dlt option.
Changing the DLT plugin allows you to convert the packets from one DLT/Layer 2 type to another type.
This allows you for example to capture traffic on say an Ethernet interface and replay over Cisco
HDLC or capture on a BSD Loopback interface and replay over Ethernet. Plugins supported in output mode: Ethernet (enet)
Cisco HDLC (hdlc)
User defined Layer 2 (user)
Plugins supported in input mode: Ethernet
Cisco HDLC
Linux SLL
BSD Loopback
BSD Null
Raw IP
802.11
Juniper Ethernet (version >= 4.0)
Hence, if you have a pcap in one of the supported input DLT types, you can convert it to one of the
supported output DLT type by using the --dlt=<output> option. Depending on the input DLT you may
need to provide additional DLT plugin flags.
tcprewrite转换命令如下:
# tcpdump -r linux_sll.pcap
reading from file linux_sll.pcap, link-type LINUX_SLL (Linux cooked)
# tcprewrite --dlt=enet --infile=linux_sll.pcap --outfile=enet.pcap
# tcpdump -r enet.pcap
reading from file enet.pcap, link-type EN10MB (Ethernet)
#
唯一有点问题的,是转换后的数据的Destination-Mac为空, 对这个字段有需求的要注意下:

可以参考的网址:
https://wiki.wireshark.org/SLL
http://www.tcpdump.org/linktypes.html
http://tcpreplay.synfin.net/wiki/tcprewrite
其它:
# tips 删除vlan
# tcprewrite --enet-vlan=del --infile=enet.pcap --outfile=output.pcap
Linux cooked-mode capture 格式转换的更多相关文章
- linux环境下deb格式 转换成rpm格式
linux环境下deb格式 转换成rpm格式 使用alien工具转换deb格式到rpm格式 alien_8.87.tar.gz 下载alien_8.87.tar.gz [root@mysqlnode2 ...
- Linux基础命令---文本格式转换expand,unexpand
expand 将文件中的tab转换成空格,结果送到标准输出.如果没有指定文件,那么从标准输入读取. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.openSUSE.F ...
- Linux基础命令---文本格式转换fmt
fmt 将指定文件的内容,按照指定的格式重新排版,结果送到标准输出. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.openSUSE.Fedora. 1.语法 ...
- linux命令实现音频格式转换和拼接
安装FFmpeg flaceric@ray:~$ sudo apt install FFmpeg flac 安装lame faaceric@ray:~$ sudo apt install lame f ...
- Linux - 文本格式转换
文本文档格式查看 Linux下的文档格式查看方法 cat -A <filename> | grep "^M$", 如果存在^M$字符就是Dos格式. Windows下的 ...
- Linux下时间格式转换及获取方法
Linux下使用clock_gettime给程序计时 #include <stdio.h> #include <unistd.h> #include <stdlib.h& ...
- 使用notepad++进行格式转换
由于历史原因,导致Windows.Unix/Linux.Mac三者之间,对于文本中所用回车换行符,表示的方法,都不一样.这就导致了很多人都会遇到回车换行符的困惑,同时需要在不同格式间进行转换. 1)查 ...
- Linux下常见音频格式之间的转换方法
Linux下常见音频格式之间的转换方法[转] 下面简单介绍下Linux环境常见音频格式之间的转换方法: MP3 相关工具: lameOGG 相关工具: vorbis-toolsAPE 相关工具: ma ...
- calibre,完成对各种格式的电子书籍的管理和格式转换及同步
Calibre是免费的电子书制作.阅读软件,源代码开放,拥有跨平台的设计,支持多个基于不同系统的便携式移动设备,包括苹果iPhone.Amazon电子书等设备.它是一个完整的电子图书馆,包括图书馆管理 ...
随机推荐
- CentOS 5 - 安装PHP MongoDB扩展
For driver developers and people interested in the latest bugfixes, you can compile the driver from ...
- 错误:javax.servlet.http.HttpServlet" was not found on the Java Build Path
我们在用Eclipse进行Java web开发时,可能会出现这样的错误: The superclass javax.servlet.http.HttpServlet was not found on ...
- 【P3398]】仓鼠找sugar
暴力lca 题目 有一种情况肯定不行 较深得lca深度比浅的两个点还深,直接不行 如果可能存在解 则解一定是介中情况 较深的lca一定在另一个lca路径上. 判读呢? 就是用深的lca和浅的lca的两 ...
- cudpp库的编译和使用
项目主页 http://cudpp.github.io/ 根据这个网址的提示进行 https://github.com/cudpp/cudpp/wiki/BuildingCUDPPwithCMake ...
- Oracle必备知识.
一.基本数据类型 1.字符数据类型 char varchar2 long 三者区别: I.char固定长度字符串,存储字母数字值,列长度可以是 1 到 2000 个字节. II.varc ...
- 远程桌面连接失败,提示CredSSP加密Oracel修正问题解决
今天远程桌面的时候失败了,出现以下提示 于是上网找解决办法,经过测试,该方法是可行的. 首先,在控制台中输入regedit,打开注册表
- JavaScript对象回收机制
js维护了一张对象引用表: 当一个对象被创建以后,栈内就有一个a,a这个对象就指向了对这个地址,当a=new Person()执行后,引用次数加1.当a=null置空,引用次数减1.由系统来维护对象引 ...
- Java中的二进制运算出错问题
问题: 最近在做Java web项目中需要计算金额总和,在这里出现了一个问题是我以前没有关注到的: System.out.println(2.0-1.1); 执行时候的console中打印输出的是 0 ...
- tcl之过程/函数-proc
- xml中encoding
前同天和同事在讨论xml里的encoding属性和文件格式的关系,终于彻底的弄清楚了.以前理解的是,xml里的encoding里定义必须与文件格式相匹配.即有这样的xml Introduction&l ...