全网整合营销服务商

电脑端+手机端+微信端=数据同步管理

免费咨询热线:400-708-3566

tcpdump:截获与分析网络数据包的实用工具及命令实例 媒体软文营销推广和内容

简单来说,它是把数据包 dump 到某个地方,能依据使用者的定义截取网络上的数据包进行包分析的工具。可以完整截获网络中传送数据包的“头”以供分析。它支持针对网络层、协议、主机、网络或端口进行过滤,还能提供 and、or、not 等逻辑语句来去除无用信息。

实用命令实例

默认启动

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">tcpdump</pre></p>

通常情况下,会直接启动并监视第一个网络接口上所有经过的数据包。

监视指定网络接口的数据包

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">tcpdump -i eth1</pre></p>

如果没有指定网卡,那么默认只会对第一个网络接口进行监视,通常这个接口是 eth0,并且下面的例子都没有指定网络接口。

监视指定主机的数据包

打印所有进入或离开的数据包.

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">tcpdump host sundown</pre></p>

可以指定 ip ,比如截获所有来自 210.27.48.1 的主机所接收的以及发出的所有数据包

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">tcpdump host <span style="font-family:&#39;Courier New&#39;!important; color:#80080; line-height:1.5!important; font-size:12px!important">210.27</span>.<span style="font-family:&#39;Courier New&#39;!important; color:#80080; line-height:1.5!important; font-size:12px!important">48.1</span> </pre></p>

打印 与 hot 或者与 ace 之间通信的数据包

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">tcpdump 对 helios 进行监听并且(对 hot 进行监听或者对 ace 进行监听)</pre></p>

截获主机 210.27.48.1 的通信,或者截获主机 210.27.48.2 的通信,或者截获主机 210.27.48.3 的通信

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">tcpdump 捕获主机为 210.27.48.1 且(主机为 210.27.48.2 或 210.27.48.3)</pre></p>

打印 ace 与其他主机通信的 IP 数据包,不包括与某些特定主机之间的数据包。

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">使用 tcpdump 捕获 IP 主机为 ace 且不是 helios 的数据包。</pre></p>

如果想要获取主机 210.27.48.1 与除主机 210.27.48.2 之外其他主机通信的 ip 包,就使用该命令:

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">使用 tcpdump 命令来捕获 IP 数据包,这些数据包的源地址或目的地址是 210.27.48.1 ,并且不是 210.27.48.2 。</pre></p>

截获主机发送的所有数据

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">使用 tcpdump 命令并指定网络接口为 eth0,同时指定源主机为 hostname</pre></p>

监视所有送到主机的数据包

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">使用 tcpdump 命令并指定接口为 eth0,目标主机为 hostname</pre></p>

监视指定主机和端口的数据包

要获取主机 210.27.48.1 接收或发出的包,可使用如下命令。

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">tcpdump tcp port <span style="font-family:&#39;Courier New&#39;!important; color:#80080; line-height:1.5!important; font-size:12px!important">23</span> host <span style="font-family:&#39;Courier New&#39;!important; color:#80080; line-height:1.5!important; font-size:12px!important">210.27</span>.<span style="font-family:&#39;Courier New&#39;!important; color:#80080; line-height:1.5!important; font-size:12px!important">48.1</span></pre></p>

对本机的udp 123端口进行监视123为ntp的服务端口

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">tcpdump udp port 123 </pre></p>

监视指定网络的数据包

打印本地主机与网络上主机之间的通信数据包。其中,网络地址为 ucb-ether,此表达式最初的含义是打印网络地址为 ucb-ether 的所有数据包。

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">tcpdump net ucb-ether</pre></p>

打印通过网关 snup 的 ftp 数据包。需要注意的是,表达式被单引号括起来了,这样做可以防止 shell 对其中的括号进行错误解析。

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">tcpdump <span style="font-family:&#39;Courier New&#39;!important; line-height:1.5!important; font-size:12px!important">&#39;</span><span style="font-family:&#39;Courier New&#39;!important; line-height:1.5!important; font-size:12px!important">gateway snup 以及(port ftp 或者 ftp-data)</span><span style="font-family:&#39;Courier New&#39;!important; line-height:1.5!important; font-size:12px!important">&#39;</span></pre></p>

打印所有源地址或目标地址是本地主机的IP数据包

如果本地网络是通过网关与另一个网络相连接的,那么另一个网络不能被视为本地网络。(注:此句翻译较为曲折,需要进行补充说明)在实际使用中,要将其真正替换成本地网络的名称。

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">使用 tcpdump 来捕获包含 IP 协议且不属于本地网络的数据包。通过这种方式,可以对特定网络环境中的 IP 流量进行监控和分析,以便更好地了解网络活动和排查网络问题。它能够过滤出那些来自或去往外部网络的 IP 数据包,而不包括本地网络内部的通信流量。</pre></p>

监视指定协议的数据包

打印 TCP 会话中的开始数据包,并且数据包的源或目的不是本地网络上的主机。打印 TCP 会话中的结束数据包,并且数据包的源或目的不是本地网络上的主机。

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">tcpdump <span style="font-family:&#39;Courier New&#39;!important; line-height:1.5!important; font-size:12px!important">&#39;</span><span style="font-family:&#39;Courier New&#39;!important; line-height:1.5!important; font-size:12px!important">tcp 的 tcpflags 与 (tcp-syn 或 tcp-fin) 进行按位与运算的结果不为 0 ,并且没有 src ,同时 dst 属于 localnet 。</span><span style="font-family:&#39;Courier New&#39;!important; line-height:1.5!important; font-size:12px!important">&#39;</span></pre></p>

打印的数据包需满足以下条件:源或目的端口为 80,网络层协议为 IPv4,且含有数据,同时不能是 SYN、FIN 以及 ACK-only 等不含数据的数据包。(ipv6 的版本的表达式可做练习)

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">tcpdump <span style="font-family:&#39;Courier New&#39;!important; line-height:1.5!important; font-size:12px!important">&#39;</span><span style="font-family:&#39;Courier New&#39;!important; line-height:1.5!important; font-size:12px!important">tcp 端口 80 以及 (((ip 的第 2 位到第 2 位 减去 ((ip 的第 0 位与 0xf 进行按位与运算后的结果 )<<2)) - ((tcp[12]&0xf0)>>2)) != 0)</span><span style="font-family:&#39;Courier New&#39;!important; line-height:1.5!important; font-size:12px!important">&#39;</span></pre></p>

可理解为,ip 的第 2 位到第 2 位表示整个 ip 数据包的长度,ip 的第 0 位与 0xf 进行与运算后再大于 4 表示 tcp 头的长度,此域的单位是 32bit,换算成比特数为 ((tcp 的第 12 位与 0xf0 进行与运算后再右移 4 位)乘以 2)。整个 ip 数据包的长度减去 ip 头的长度,再减去 (ip 的第 0 位与 0xf 进行与运算后乘以 2)不等于 0 表示:整个 ip 数据包的长度减去 ip 头的长度,再减去

tcp 头的长度不为 0 ,这意味着 ip 数据包中有数据。对于 ipv6 版本,只需考虑 ipv6 头中的“ ”与“tcp 头的长度”的差值,并且其中的表达方式“ip[]”需换成“ip6[]”。

打印长度超过 576 字节的数据包,且该数据包的网关地址是 snup 的 IP 地址

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">tcpdump <span style="font-family:&#39;Courier New&#39;!important; line-height:1.5!important; font-size:12px!important">&#39;</span><span style="font-family:&#39;Courier New&#39;!important; line-height:1.5!important; font-size:12px!important">网关 snup 以及 ip 的第 2 位到第 2 位大于 576 。</span><span style="font-family:&#39;Courier New&#39;!important; line-height:1.5!important; font-size:12px!important">&#39;</span></pre></p>

打印所有属于 IP 层的广播或多播数据包,并且这些数据包不是物理以太网层的广播或多播数据报。

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">tcpdump <span style="font-family:&#39;Courier New&#39;!important; line-height:1.5!important; font-size:12px!important">&#39;</span><span style="font-family:&#39;Courier New&#39;!important; line-height:1.5!important; font-size:12px!important">ether[0] 与 1 进行按位与运算的结果为 0 ,并且 ip[16] 大于或等于 224 。</span><span style="font-family:&#39;Courier New&#39;!important; line-height:1.5!important; font-size:12px!important">&#39;</span></pre></p>

打印以下类型的 ICMP 数据包:不是“echo ”类型,也不是“echo reply”类型。例如,当需要打印所有非 ping 程序产生的数据包时,可以使用此表达式。

“echo”类型和“echo reply”类型的 ICMP 数据包一般是由 ping 程序生成的。

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">tcpdump <span style="font-family:&#39;Courier New&#39;!important; line-height:1.5!important; font-size:12px!important">&#39;</span><span style="font-family:&#39;Courier New&#39;!important; line-height:1.5!important; font-size:12px!important">icmp 的 icmptype 不等于 icmp-echo ,并且 icmp 的 icmptype 也不等于 icmp-echoreply 。</span><span style="font-family:&#39;Courier New&#39;!important; line-height:1.5!important; font-size:12px!important">&#39;</span></pre></p>

  与

曾经有一款非常简单易用的抓包工具。然而,在 Linux 系统中,很难找到一个令人满意的图形化抓包工具。

还好有。我们能够通过以下完美组合来实现:在 Linux 系统中进行抓包操作,接着在相应的环境里对包进行分析。

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">最后将抓取到的数据包保存到./target.cap 文件中。</pre></p>

tcp、ip、icmp、arp、rarp 这些选项以及 tcp、udp、icmp 等都需放置在第一个参数的位置,以用于过滤数据报的类型。

(2)-i eth1 : 只抓经过接口eth1的包

(3)-t : 不显示时间戳

抓取数据包时,原本默认抓取的长度是 68 字节。当加上-S 0 之后,就能够抓到完整的数据包。

(5)-c 100 : 只抓取100个数据包

不抓取目标端口为 22 的数据包。

数据包的源网络地址是 192.168.1.0 且子网掩码为 255.255.255.0

将其保存为 cap 文件,这样便于进行分析。

使用抓取HTTP包

<p style='margin-bottom:15px;color:#555555;font-size:15px;line-height:200%;text-indent:2em;'> <pre style="margin-top:0px; font-family:&#39;Courier New&#39;!important; word-wrap:break-word; white-space:pre-wrap; margin-bottom:0px; font-size:12px!important">使用 tcpdump 进行抓包操作,设置参数为 -XvvennSs 0 并指定网络接口为 eth0 ,抓取的条件是 tcp 报文头部的第 20 字节到第 21 字节的值为 0x4745 或者为 0x4854 。</pre></p>

“GET”的前两个字母是“GE”,“HTTP”的前两个字母是“HT”。

截获的数据未被彻底解码,数据包内的大部分内容是以十六进制形式直接打印输出的。这显然不利于分析网络故障。通常的解决办法是,先使用带 -w 参数的方式截获数据并保存到文件中,接着再使用其他程序(如)进行解码分析。当然,也需要定义过滤规则,以防止捕获的数据包将整个硬盘填满。


# tcpdump:截获与分析网络数据包的实用工具及命令实例  # tcpdump  # 截获与分析网络数据包的实用工具及命令实例  # 数据包  # 第一个  # 到第  # 网络地址  # 不为  # 不等于  # 进行分析  # 的是  # 或多  # 源地址  # 也不  # 还能  # 是由  # 中有  # 只需  # 将其  # 它是  # 而不  # 这样做  # 如果没有  # 社交媒体营销推广的特点  # 宁陵网站建设报价公示  # seo建站推广  # 专业的网站建设兼职  # 企业seo排名有 名  # 海外营销推广哪里好点  # 符合抖音seo规则  # 济宁营销推广获客系统  # 最新外贸seo  # 成都营销推广哪家服务好  # 科技主题营销推广策略  # 校园网站建设计划  # seo引擎优化怎么念  # 黑河网站优化怎么做  # 如何使用seo打造  # 网络营销设计推广招聘  # 个人网站建设免费咨询  # 网站建设拓扑结构包括  # 英文网站百度能推广吗  # 陇南seo公司联系21火星 


相关文章: 【联盟基础】利用网盘下载资源进行推广是什么意思?  新手必看的全网引流渠道及引流思路介绍!  兰州网站优化,提升企业在线竞争力的关键策略,兰州企业在线竞争力加速器,高效网站优化策略全解析  服装生产,从传统到智能,介绍服装产业变革之路  全文缩写-提高效率,释放更多可能,设计类网站建设  豆瓣引流拉新变现月入过万项目实操经验分享!  没本钱怎么在手机一天赚500?“趣闲赚”分享推广做任务赚钱玩法介绍  想通过网络营销获客该怎么做?  SEO有意:如何通过优化策略提升网站排名与流量,信誉好的泉州seo报价  个人站长网站变现,务必注意这8条做广告联盟赚钱的小技巧!  常见的4个网站营销方式,学会了不愁网站没流量!  网赚赚钱项目的本质到底是什么?  优化量:企业成功的背后力量,常州网站建设网址大全  揭秘利用百度小程序挂广告赚钱的操作玩法,竟然还可以这样玩?  cpc广告怎么做才能达到最好的效果?6大cpc广告操作技巧分享!  福建百度推广返费怎么操作?详细指南助您轻松应对,惠州个人网站推广费用  分享两个不一样联盟赚钱玩法,亲测效果非常棒!  微信公众号变现该怎么做?微信公众号变现的四个步骤!  日付广告联盟哪个好,如何判断哪个更靠谱?  优化文字,让表达更精准:提升写作效率的关键,科普网站资源建设  关键词占领:如何通过精准优化打造品牌网络霸主,云南网站推广平台哪个好  SEO更好,让你的网站从此脱颖而出,seo html 嵌套层数  URL泄露:如何防止信息泄露带来的严重后果,淮安网站建设开发与制作  社区论坛引流的5个小技巧,助你高效引流!  推广*类app违法吗?这些问题需要注意!  为什么越来越多的人选择在知乎发布文章?这里面的机会你可能还没发现!,资阳网站官网建设费用  深入解析建网站软件,助力企业打造个性化在线平台,揭秘建站软件,企业个性化在线平台构建之道,揭秘建站软件奥秘,企业个性化在线平台构建指南  伪文章:互联网时代的营销神器,打造品牌的全新突破口,seo 推广排名  想在广告联盟上接单赚钱,这些qq引流技巧你必须掌握!  SEO广告:如何借助SEO提升品牌曝光与销售业绩?,深圳美发店推广招聘网站  最适合个人站长赚钱的6大广告联盟推荐!(新手必看)  网站单页面优化的8个核心要素,做好了排名快速提升!  小红书推广引流没效果?注意这几个小红书引流推广的关键思路!  想要利用qq群赚钱月入过万,该怎么做?  新上线的网站运营该如何做?建议从这8个方面着手!  app运营精细化如何做?这三个核心指标务必明确!  类app推广平台去哪找?哪家的推广效果好?  你想象不到的新型休闲游戏广告联盟的盈利能力!  SEO数量-如何提升你的网站排名与流量?,建设旅游网站方法  全球优化:智能时代下的全球资源配置革命,象山网站推广费用  谷歌头像规则设置方法是什么,谷歌怎么改头像  互联网营销方式主要有哪些?这4种主流方式必须掌握!  公众号自动化:让你的内容营销事半功倍,seo冷启动  竞价广告是什么意思?什么是竞价广告?  app推广拉新这通过这4个市场推广策略来实现用户的拉新和流量暴涨!  3种非常火爆的APP推广方法以及实用小技巧分享!  微信营销新玩法之#话题标签引流吸粉玩法分享!  SEO功能:助力网站流量提升与品牌曝光,扶绥网站建设费用  SEO详解:如何优化你的网站提升排名,获得更多流量,历城区网站优化  SEO外包:提升网站排名与品牌曝光的最佳选择,关键词搜索排名技巧 

您的项目需求

*请认真填写需求信息,我们会在24小时内与您取得联系。