tcpdump示例
今天有需求要用tcpdump,给一个我使用的例子:
sudo /usr/sbin/tcpdump dst 10.20.137.24 and tcp port 8080 -A -s0 -w nouse
-A 表示只用ASCII码显示, 方便查看网页
-x 表示用16进制
-X 表示16进制和ASCII码同时显示
-s0 表示不限制包的大小
-w 表示写入文件
参考了下面的文章,不胜感激。
Let assume ,I wanna capture tcp packets that flow over eth1 port 6881. The dump file with be save as test.pcap.
tcpdump -w test.pcap -i eth1 tcp port 6881
Simple right? What if at the same time I am interested on getting packets on udp port 33210 and 33220?
tcpdump -w test.pcap -i eth1 tcp port 6881 or udp \( 33210 or 33220 \)
‘\’ is an escape symbol for ‘(’ and ‘)’. Logic OR implies PLUS (+). In plain text is I want to capture tcp packets flows over port 6881 plus udp ports 33210 and 33220.
Careful with ‘and’ in tcpdump filter expression, it means intersection. Thats why I put ‘or’ instead of and within udp port 33210 and 33220. The usage of ‘and’ in tcpdump will be illustrate later.
Ok, how about reading pcap that I saved previously?
tcpdump -nnr test.pcap
The -nn is to tell tcpdump not to resolve DNS on IP and Ports, where r is read.
Adding -tttt to makes the timestamp appears more readable format.
tcpdump -ttttnnr test.pcap
How about capture based on IP ?
You need to tell tcpdump which IP you are interested in? Destination IP? or Source IP ? Let say I wanna sniff on destination IP 10.168.28.22 tcp port 22, how should i write?
tcpdump -w test.pcap dst 10.168.28.22 and tcp port 22
So the ‘and’ makes the intersection of destination IP and port.
By default the sniff size of packets is 96 bytes, you somehow can overload that size by specified with -s.
tcpdump -w test.pcap -s 1550 dst 10.168.28.22 and tcp port 22
Some version of tcpdump allows you to define port range. You can as bellow for capturing packets based on a range of tcp port.
tcpdump tcp portrange 20-24
Bare in mind, the line above I didn’t specified -w which it won’t write to a file but i will just print the captured packets on the screen.
tcpdump示例的更多相关文章
- 抓包工具tcpdump用法说明
tcpdump采用命令行方式对接口的数据包进行筛选抓取,其丰富特性表现在灵活的表达式上. 不带任何选项的tcpdump,默认会抓取第一个网络接口,且只有将tcpdump进程终止才会停止抓包. 例如: ...
- tcpdump抓包工具用法说明
tcpdump采用命令行方式对接口的数据包进行筛选抓取,其丰富特性表现在灵活的表达式上. 不带任何选项的tcpdump,默认会抓取第一个网络接口,且只有将tcpdump进程终止才会停止抓包. 例如: ...
- 抓包工具 tcpdump 用法说明
tcpdump采用命令行方式对接口的数据包进行筛选抓取,其丰富特性表现在灵活的表达式上. 不带任何选项的tcpdump,默认会抓取第一个网络接口,且只有将tcpdump进程终止才会停止抓包. 例如: ...
- [转帖]tcpdump详细教程
tcpdump详细教程 https://www.jianshu.com/p/d9162722f189 tcpdump tcpdump - dump traffic on a network tcpdu ...
- 【转载】抓包工具tcpdump用法说明
转载地址:http://www.cnblogs.com/f-ck-need-u/p/7064286.html tcpdump采用命令行方式对接口的数据包进行筛选抓取,其丰富特性表现在灵活的表达式上. ...
- 抓包工具tcpdump用法说明--1
本文目录: 1.1 tcpdump选项 1.2 tcpdump表达式 1.3 tcpdump示例 tcpdump采用命令行方式对接口的数据包进行筛选抓取,其丰富特性表现在灵活的表达式上. 不带任何选项 ...
- tcpdump用法说明
tcpdump采用命令行方式对接口的数据包进行筛选抓取,其丰富特性表现在灵活的表达式上. 不带任何选项的tcpdump,默认会抓取第一个网络接口,且只有将tcpdump进程终止才会停止抓包. 例如: ...
- 超详细的网络抓包神器 tcpdump 使用指南
原文链接:Tcpdump 示例教程 本文主要内容翻译自<Tcpdump Examples>. tcpdump 是一款强大的网络抓包工具,它使用 libpcap 库来抓取网络数据包,这个库在 ...
- monitor a local unix domain socket like tcpdump
Can I monitor a local unix domain socket like tcpdump? - Super User https://superuser.com/questions/ ...
随机推荐
- 【python】-- web开发之CSS
CSS CSS作用概述:(通俗的讲就是将HTML这个赤裸裸的“人”,穿上华丽的衣服) CSS 指层叠样式表 (Cascading Style Sheets) 样式定义如何显示 HTML 元素 样式通常 ...
- 【译】StackOverflow——Java 中的 finally 代码块是否总会被执行?
问题 有一个 try/catch 代码块,其中包含一个打印语句.finally代码块总会被调用么? 示例: try { something(); return success; } catch (Ex ...
- PAT 1051. 复数乘法 (15)
复数可以写成(A + Bi)的常规形式,其中A是实部,B是虚部,i是虚数单位,满足i2 = -1:也可以写成极坐标下的指数形式(R*e(Pi)),其中R是复数模,P是辐角,i是虚数单位,其等价于三角形 ...
- ABAP文件选择框函数
因为WS_FILENAME_GET已经被废弃所以使用接口CL_GUI_FRONTEND_SERVICES来实现本地文件的选择. 用接口类CL_GUI_FRONTEND_SERVICES实现的方法 CA ...
- python 统计单词出现次数
#use python3.6 import re from collections import Counter FILESOURCE = './abc.txt' def getMostCommonW ...
- maven导入项目时,缺少部分source folder
今天导入公司的maven项目时,少了一些source folder,运行启动正常,但是页面打不开,找不到对应的目录文件,使用maven更新项目,重启编辑器也无效. 问题描述如图所示,缺少了图中的2个目 ...
- HDR(High Dynamic Range) - 高动态范围
1. Dynamic Range 动态范围是指一个场景的最亮和最暗部分之间的相对比值 2. Tone-mapping 现实真正存在的亮度差,即最亮的物体亮度和最暗的物体亮度之比为 , 而人类的眼睛 ...
- finally return 执行关系 异常处理 c#
Return.finally执行关系简述 除了函数出现system.exit(0)终止虚拟机,finally中的代码一定执行,return语句会等待finally的执行:如果是值传递,finally中 ...
- 【DP】最长不下降子序列问题(二分)
Description 给你一个长度为n的整数序列,按从左往右的顺序选择尽量多的数字并且满足这些数字不下降. Thinking 朴素dp算法:F[i]表示到第i位为止的最长不下降子序列长度 F[i]= ...
- python详细目录
python第一篇 第二篇.初识列表字典元祖循环 第三篇.内置方法 第四篇.编码解码 列表.元祖 第五篇.数据类型 第六篇 函数 第七篇.函数二 第八篇.递归.装饰器 第九篇 正则表达式 第十篇.模块 ...