zoukankan      html  css  js  c++  java
  • tcpdump 抓包使用小结

     

    tcpdump 抓包规则常用命令

    下面的例子全是以抓取 eth0 接口为例,如果不加”-i eth0” 是表示抓取所有的接口包括 lo

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    # 抓取包含 172.16.1.122 的数据包  
    tcpdump -i eth0 -vnn host 172.16.1.122
    # 抓取包含 172.16.1.0/24 网段的数据包
    tcpdump -i eth0 -vnn net 172.16.1.0/24
    # 抓取包含端口 22 的数据包
    tcpdump -i eth0 -vnn port 22
    # 抓取 udp 协议的数据包
    tcpdump -i eth0 -vnn udp
    # 抓取 icmp 协议的数据包
    tcpdump -i eth0 -vnn icmp
    # 抓取 arp 协议的数据包
    tcpdump -i eth0 -vnn arp
    # 抓取 ip 协议的数据包
    tcpdump -i eth0 -vnn ip
    # 抓取源 ip 是 172.16.1.122 数据包。
    tcpdump -i eth0 -vnn src host 172.16.1.122
    # 抓取目的 ip 是 172.16.1.122 数据包
    tcpdump -i eth0 -vnn dst host 172.16.1.122
    # 抓取源端口是 22 的数据包
    tcpdump -i eth0 -vnn src port 22
    # 抓取源 ip 是 172.16.1.253 且目的 ip 是 22 的数据包
    tcpdump -i eth0 -vnn src host 172.16.1.253 and dst port 22
    # 抓取源 ip 是 172.16.1.122 或者包含端口是 22 的数据包
    tcpdump -i eth0 -vnn src host 172.16.1.122 or port 22
    # 抓取源 ip 是 172.16.1.122 且端口不是 22 的数据包
    tcpdump -i eth0 -vnn src host 172.16.1.122 and not port 22
    # 抓取源 ip 是 172.16.1.2 且目的端口是 22,或源 ip 是 172.16.1.65 且目的端口是 80 的数据包。
    tcpdump -i eth0 -vnn ( src host 172.16.1.2 and dst port 22 ) or ( src host 172.16.1.65 and dst port 80 )
    # 抓取源 ip 是 172.16.1.59 且目的端口是 22,或源 ip 是 172.16.1.68 且目的端口是 80 的数据包。
    tcpdump -i eth0 -vnn 'src host 172.16.1.59 and dst port 22' or 'src host 172.16.1.68 and dst port 80'
    # 把抓取的数据包记录存到 / tmp/fill 文件中,当抓取 100 个数据包后就退出程序。
    tcpdump –i eth0 -vnn -w /tmp/fil1 -c 100
    # 从 / tmp/fill 记录中读取 tcp 协议的数据包
    tcpdump –i eth0 -vnn -r /tmp/fil1 tcp
    # 从 / tmp/fill 记录中读取包含 172.16.1.58 的数据包
    tcpdump –i eth0 -vnn -r /tmp/fil1 host 172.16.1.58
    # 抓取目的地址范围是 10 网段
    tcpdump -i any -nn 'ip[16] == 10'
    # 抓取目的地址范围是 192.168.1.10 ~ 192.168.1.100
    tcpdump -i any -nn 'ip[16] == 192 and ip[17] == 168 and ip[18] == 1 and ip[19] > 9 and ip[19] < 101'
    # 保存 10000 个数据包过滤条件为 443 端口,并解析来源 IP
    tcpdump -i any -nn -c 10000 port 443 > tcpdump.log
    cat tcpdump.log | awk '{print $3}' |awk -F '.' '{print $1"."$2"."$3"."$4}'| sort | uniq -c | sort -rn
  • 相关阅读:
    怎样快速学会ZBrush 中的移动笔刷的运用
    ZBrush中如何才能快速完成脸部雕刻(下)
    ZBrush中如何才能快速完成脸部雕刻(上)
    ZBrush中的Clip剪切笔刷怎么快速运用
    ZBrush中必须记住的常用快捷键
    怎么在ZBrush中渲染漫画风格的插画
    怎么运用ZBrush中的Z球制作身体部分
    ZBrush中的笔刷该怎样制作
    如何在ZBrush中添加毛发
    App交互demo
  • 原文地址:https://www.cnblogs.com/qiumingcheng/p/12164512.html
Copyright © 2011-2022 走看看