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电子书等设备.它是一个完整的电子图书馆,包括图书馆管理 ...
随机推荐
- WinSCP 工具
windows 与 Linux 传文件,非常方便.安全.
- apache以天为单位生成日志
编辑/etc/httpd/conf.d/vhost.conf,修改ErrorLog和CustomLog: ErrorLog "|rotatelogs /var/log/httpd/phpdd ...
- 第39章 ETH—Lwip以太网通信—零死角玩转STM32-F429系列
第39章 ETH—Lwip以太网通信 全套200集视频教程和1000页PDF教程请到秉火论坛下载:www.firebbs.cn 野火视频教程优酷观看网址:http://i.youku.com/ ...
- Linux添加新硬盘,设置分区和开机自动挂载之图文教程!
虚拟机添加硬盘的步骤就不多废话了,主要列出添加硬盘后要进行设置的几个详细步骤: 1.查看磁盘信息:fdisk -ls 添加前如下图所示: 添加后如下图: 也可以用:ls /dev/sd*查看,如下图: ...
- java斗地主扑克 扑克牌 洗牌 发牌 Collection 集合练习
package com.swift.poker; import java.util.ArrayList; import java.util.Collections; /*训练考核知识点:Collect ...
- DB总结1
DBA 重构 data new york committee cobol codasyl journal DDL DML 关系演算 域关系演算语言(QBE) 元祖关系演算语言 ...
- v-show
v-show的原理是当值为false的时候,元素display:none 隐藏了元素且脱离文档流,但是在dom 中仍然存在. 与v-if使用场景不同,文档中提到,当需要高频切换的时候使用v-show ...
- Linux下文件的压缩与解压缩
一.zip格式 zip可能是目前使用的最多的文档压缩格式.它最大的优点就是在不同的操作系统平台上使用.缺点就是支持 的压缩率不是很高,而tar.gz和tar.bz2在压缩率方面做得非常好. 我们可以使 ...
- UVA_10139
The factorial function, n! is defined thus for n a non-negative integer:0! = 1 n! = n×(n−1)! (n > ...
- Mysql5.7创建存储过程中调用自定义函数报错Not allowed to return a result set from a function
因为很多存储过程都会共用一段sql语句,所以我把共用的sql封装成一个自定义函数 AddCapital(); 然后通过存储过程调用,创建存储过程会报错1415,Not allowed to retur ...