TCPDUMP

tcpdump的使用总结

匿名 (未验证) 提交于 2019-12-02 23:42:01
1、 监视所有发送到主机hostname的数据: tcpdump -i eth0 dst host hostname 2、 监视指定主机和端口的数据包(接收或发出的telnet包): tcpdump tcp port 22 and host hostname 3、 截获主机hostname发送而来的数据包 tcpdump -i ens160 src host 10.10.18.139 > recv_log.log cat recv_log.log | "17:01:16"|wc -l 4、 监听指定网卡udp指定port: tcpdump -i ens160 udp port 10310 5、 抓取所有经过eth0,目的或源地址为10.10.18.139的网络数据: 6、 抓取主机10.37.63.255和主机10.37.63.61或10.37.63.95的通信 tcpdump host 10.37.63.255 and (10.37.63.61 or 10.37.63.95) 7、 抓取主机192.168.13.210除了和主机10.37.63.61之外所有主机通信的数据包 8、 抓取主机10.37.63.255除了和主机10.37.63.61之外所有主机通信的ip包 9、 抓取主机10.37.63.3发送的所有数据 tcpdump -i eth0 host 172.20.0

tcpdump 介绍

江枫思渺然 提交于 2019-12-02 22:17:06
tcpdump 是一款强大的网络抓包工具,dump the traffice on anetwork,对网络上的数据包进行截获的包分析工具。熟练掌握 tcpdump 可以方便我们跟踪解决网络丢包,重传,数据库链路调用等问题。 tcpdump 的语法 Usage: tcpdump [-aAdDefhIJKlLnNOpqRStuUvxX] [ -B size ] [ -c count ] [ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ] [ -i interface ] [ -j tstamptype ] [ -M secret ] [ -Q|-P in|out|inout ] [ -r file ] [ -s snaplen ] [ -T type ] [ -w file ] [ -W filecount ] [ -y datalinktype ] [ -z command ] [ -Z user ] [ expression ] tcpdump 主要支持3种类型的表达式: Type(类型)选项包括 host,net 和 port,缺省为 host host(缺省类型): 指明一台主机,如:host 10.215.20.13 net: 指定网络地址,net 10.215.20.0 port: 指明端口号

Handling tcpdump output in python

北城以北 提交于 2019-12-02 19:33:11
Im trying to handle tcpdump output in python. What I need is to run tcpdump (which captures the packets and gives me information) and read the output and process it. The problem is that tcpdump keeps running forever and I need to read the packet info as soon as it outputs and continue doing it. I tried looking into subprocess of python and tried calling tcpdump using popen and piping the stdout but it doesnt seem to work. Any directions on how to proceed with this. import subprocess def redirect(): tcpdump = subprocess.Popen("sudo tcpdump...", stdin=subprocess.PIPE, stdout=subprocess.PIPE,

TCPDUMP抓包工具的常用方法

ぃ、小莉子 提交于 2019-12-02 17:53:33
说明 tcpdump在Linux系统中,由于它需要将网络界面设置为混杂模式, 普通用户不能正常执行,但具备root权限的用户可以直接执行它来获取网络上的信息。 tcpdump可以将网络中传送的数据包的“头”完全截获下来提供分析。它支持针对网络层、协议、主机、网络或端口的过滤,并提供and、or、not等逻辑语句来去掉无用的信息。 不带参数的tcpdump会收集网络中所有的信息包头,数据量巨大,必须过滤。 常用选项: -i 指定监听的网络接口 -nn IP和端口均以数字形式显示 -c 在收到指定的数量的分组后,tcpdump停止,如果没有这个参数,tcpdump会持续不断的监听直到用户输入 [ctrl]-c 为止 -e 输出数据链路层的头部信息(显示MAC地址相关信息)。 -t 在输出的每一行不打印时间戳 -q 只输出较少的协议信息(仅输出协议名称,如TCP;而不输出封包标记信息,如F、P等标记) -w FILE直接将分组写入文件中,而不是到stdout -r FILE从后面接的文件将数据包数据读出来。那个「文件」是已经存在的文件,并且这个「文件」是由 -w 所制作出来的 -s 设置tcpdump的数据包抓取长度为len,如果不设置默认将会是65535字节。对于要抓取的数据包较大时,长度设置不够可能会产生包截断,若出现包截断,输出行中会出现"[|proto]"的标志

tcpdump 和 iptables

你离开我真会死。 提交于 2019-12-02 17:50:28
tcpdump基础用法 tcpdump -i ens33 -tnn dst port 80 -c 1000 #对ens33网卡 的80 端口进行抓包,只抓访问报文,且抓满1000个就停下,-tnn t是tcp的意思可换成u只抓udp或者两个tu两个都抓,nn的意思是显示端口,不加nn 80会被解析成http tcpdump -i ens33 host 192.168.0.13 and -tnn dst port 80 -c 1000 #对ens33 的80 端口进行抓包同时过滤吊其他报文只抓192.168.0.13 #如图, 加了dst 只抓访问报文,不加访问报文和回包一起抓,如果只想看回包的话加上src。 同时抓两个端口 tcpdump -i ens33 host 192.168.0.13 and -tnn dst port 80 or 22 -c 1000 #对192.168.0.13 的 80和22端口同时抓 tcpdump -i ens33 host 192.168.0.13 and -nn 'icmp' #对192.168.0.13 对icmp报文,抓包,自己ping自己抓不到 防火墙拒绝了80端口,再抓包 #图中可以看到,能收到访问报文,但是服务器拒绝了80端口,就没有回包了 tcpdump -i ens33 dst 192.168.0.13 and src 192

How can I have tcpdump write to file and standard output the appropriate data?

99封情书 提交于 2019-12-02 14:14:18
I want to have tcpdump write raw packet data into a file and display packet analysis in standard output as the packets are captured (by analysis I mean the lines it displays normally when -w is missing). Can anybody please tell me how to do that? Here's a neat way to do what you want: tcpdump -w - | tee somefile | tcpdump -r - What it does: -w - tells tcpdump to write binary data to stdout tee writes that binary data to a file AND to its own stdout -r - tells the second tcpdump to get its data from its stdin If you want a way to do it without running tcpdump twice, consider: sudo tcpdump port

Can I use tcpdump to get HTTP requests, response header and response body?

◇◆丶佛笑我妖孽 提交于 2019-12-02 13:49:19
I am using tcpdump to get HTTP data by executing the below command: sudo tcpdump -A -s 1492 dst port 80 The result of above command: Headers, I think request and response headers. Unreadable data. The url GET /modules/mod_news_pro_gk1/cache/stories.ilbalad.ajayeb.strange-tractor.jpg . I need a more clear result, for example, readable request > response header > response body etc. How can I filter my results? paulz There are tcpdump filters for HTTP GET & HTTP POST (or for both plus message body): Run man tcpdump | less -Ip examples to see some examples Here’s a tcpdump filter for HTTP GET:

tcpdump

﹥>﹥吖頭↗ 提交于 2019-12-02 12:28:56
监视指定网络接口的数据包 tcpdump - i eth1 如果不指定网卡,默认tcpdump只会监视第一个网络接口,一般是eth0 下面的例子都没有指定网络接口。  打印所有进入或离开主机sundown的数据包 . tcpdump host sundown 也可以指定ip , 例如截获所有 210.27 .48 .1 的主机收到的和发出的所有的数据包 tcpdump host 210.27 .48 .1 打印helios 与 hot 或者与 ace 之间通信的数据包 tcpdump host helios and \ ( hot or ace \ ) 截获主机 210.27 .48 .1 和主机 210.27 .48 .2 或 210.27 .48 .3 的通信 tcpdump host 210.27 .48 .1 and \ ( 210.27 .48 .2 or 210.27 .48 .3 \ ) 打印ace与任何其他主机之间通信的IP 数据包 , 但不包括与helios之间的数据包 . tcpdump ip host ace and not helios 如果想要获取主机 210.27 .48 .1 除了和主机 210.27 .48 .2 之外所有主机通信的ip包,使用命令: tcpdump ip host 210.27 .48 .1 and ! 210.27 .48 .2

How to convert KDD 99 dataset to tcpdump format?

喜夏-厌秋 提交于 2019-12-02 11:19:11
问题 Can anyone guide me in converting the KDD 99 dataset,consisting of ip packets in the following format to TCP dump format? 0,udp,private,SF,105,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0.00,0.00,0.00,0.00,1.00,0.00,0.00,255,254,1.00,0.01,0.00,0.00,0.00,0.00,0.00,0.00,normal. 0,udp,private,SF,105,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0.00,0.00,0.00,0.00,1.00,0.00,0.00,255,254,1.00,0.01,0.00,0.00,0.00,0.00,0.00,0.00,normal. 0,udp,private,SF,105,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0.00,0.00

云计算人员常用技术有哪些 tcpdump工具怎么回事

佐手、 提交于 2019-12-02 06:00:01
云计算人员常用技术有哪些?tcpdump工具怎么回事?对于一个云计算运维人员来说,tcpdump是比较基础但常用的技术,它可以将网络中传送的数据包完全截获下来提供分析。很多人在最初学习tcpdump时感觉无从下手,接下来小编就给大家讲解一下。 tcpdump支持针对网络层、协议、主机、网络或端口的过滤,并提供and、or、not等逻辑语句来帮助你去掉无用的信息。 tcpdump采用命令行方式对接口的数据包进行筛选抓取,其丰富特性表现在灵活的表达式上。不带任何选项的tcpdump,默认会抓取第一个网络接口,且只有将tcpdump进程终止才会停止抓包。 tcpdump选项 命令格式为: tcpdump [ -DenNqvX ] [ -c count ] [ -F file ] [ -i interface ] [ -r file ] [ -s snaplen ] [ -w file ] [ expression ] 抓包选项: -c:指定要抓取的包数量。注意,是最终要获取这么多个包。例如,指定"-c 10"将获取10个包,但可能已经处理了100个包,只不过只有10个包是满足条件的包。 -i interface:指定tcpdump需要监听的接口。若未指定该选项,将从系统接口列表中搜寻编号最小的已配置好的接口(不包括loopback接口,要抓取loopback接口使用tcpdump -i