• Linux 抓包


    https://www.cnblogs.com/ggjucheng/archive/2012/01/14/2322659.html

    tcpdump 与wireshark

    Wireshark(以前是ethereal)是Windows下非常简单易用的抓包工具。但在Linux下很难找到一个好用的图形化抓包工具。
    还好有Tcpdump。我们可以用Tcpdump + Wireshark 的完美组合实现:在 Linux 里抓包,然后在Windows 里分析包。

    tcpdump tcp -i eth1 -t -s 0 -c 100 and dst port ! 22 and src net 192.168.1.0/24 -w ./target.cap

    (1)tcp: ip icmp arp rarp 和 tcp、udp、icmp这些选项等都要放到第一个参数的位置,用来过滤数据报的类型
    (2)-i eth1 : 只抓经过接口eth1的包
    (3)-t : 不显示时间戳
    (4)-s 0 : 抓取数据包时默认抓取长度为68字节。加上-S 0 后可以抓到完整的数据包
    (5)-c 100 : 只抓取100个数据包
    (6)dst port ! 22 : 不抓取目标端口是22的数据包
    (7)src net 192.168.1.0/24 : 数据包的源网络地址为192.168.1.0/24
    (8)-w ./target.cap : 保存成cap文件,方便用ethereal(即wireshark)分析

     

     

    监视指定主机的数据包

    打印所有进入或离开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

    截获主机hostname发送的所有数据

    tcpdump -i eth0 src host hostname

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

    tcpdump -i eth0 dst host hostname

     

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

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

    tcpdump tcp port 23 and host 210.27.48.1

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

    tcpdump udp port 123 
  • 相关阅读:
    Linux下安装Apache2.4.43踩坑记录
    网络代理条件下配置git
    docker存储驱动的选择
    Python列表排序
    解决apache无法启动No space left on device
    Flask匹配url使用正则表达式
    Web安全-客户端脚本安全
    springboot中的一些好用注解
    基于cdn方式的vue+element-ui的单页面架构
    干货网站
  • 原文地址:https://www.cnblogs.com/liujx2019/p/10310110.html
Copyright © 2020-2023  润新知