dsniff 之tcpkill 的使用详细介绍

简介

tcpkill 工具,顾名思义,用来杀死指定的tcp连接。是dsniff的一个小模块。

dsniff是一个非常有名的被动监听的网络嗅探工具,用于渗透测试,信息抓取等,都是网络黑客大佬们使用。我也不懂,单纯就是介绍下tcpkill模块。重点放在cpdump(8) filter expression。

dsniff 下载地址:https://monkey.org/~dugsong/dsniff/

tcpkill 过滤表达式语法地址:https://www.tcpdump.org/manpages/pcap-filter.7.html

安装

我的系统是centos6,使用了网易的163的yum源,阿里的epel源,可以直接通过yum install dsniff 进行安装。

163源安装地址:http://mirrors.163.com/.help/centos.html

阿里epel安装地址:https://developer.aliyun.com/mirror/epel?spm=a2c6h.13651102.0.0.3e221b11hrMBGH

安装完以后,执行命令:

#清空缓存

yum clean all

#重建缓存

yum makecache

#查看支持的dsniff版本,我的是dsniff.x86_64-2.4-0.23.b1.el6 

yum list dsniff

#安装dsniff

yum install dsniff


 

使用

这个命令不要在生产环境轻易使用!!!切记哦

#man tcpkill

名字
       tcpkill - 杀死局域网上的tcp连接

用法
       tcpkill [-i interface] [-1...9] expression

描述
       tcpkill  kills specified in-progress TCP connections (useful for libnids-based applications which require a full
       TCP 3-whs for TCB creation).

选项
       -i interface    指定监听的网卡

       -1...9     指定kill 杀死连接的级别。默认是3,强制杀死用9,类比linux的kill

       expression     指定一个tcpdump(8) filter expression 来选择要杀死的连接


 

tcpdump(8) filter expression

过滤表达式是由一个或多个过滤条件组成,每个过滤条件又是由阈值和条件组成。条件有3个维度,称为type,dir,proto。并且按照proto dir type 的顺序组成一个过滤条件。这里比较绕,看到后面的例子就好了。先说下三个维度:

 

type维度设置阈值的属性,可选值有host,net,port,portrange。默认为host

host :指定主机名或ip,比如host 10.0.11.22

port:指定端口 比如 port 80

net: 指定网段。比如 net 128.3

portrange:指定一个端口范围。比如portrange 1-1024

 

dir维度设置阈值的传播方向,可选值有src , dst , src or dst , src and dst 。默认是src or dst。此外,对于无线局域网,还有ra,ta,addr1,addr2,addr3,addr4这些值可以选,大家可以自己深入探索

src  表示连接的来源地 ,比如 src net 128.3

dst 表示连接的目的地 ,比如dst port 80

src or dst 表示连接的来源或目的地 ,比如 src and dst host 10.0.11.22

src and dst 表示连接的来源和目的地 ,比如  src and dst portrange 6000-6010

 

porto维度设置阈值的指定协议,可选值有ip,ip6,arp,rarp,decnet,wlan,fddi,ether,tr,tcp,udp。默认是所有协议.(wlan,fddi,ether,tr是其实同一种协议。。。)

 

知道了上面的过滤条件是有三个维度组成,接下来就是多个过滤条件的组合,组合方式有and,or,not 。

比如host hadoop01 and not port 80,就是筛选了hadoop01机器上所有非80端口的连接。

 

此外还有特殊的两个过滤条件,不需要三个维度的组合。就是gateway 和broadcast。

gateway 指定该连接的网关,必须是主机名。比如筛选网关为test01机器的连接 gateway test01 

broadcast 指定数据传输方式为广播。和传输协议一起使用。比如ip broadcast,就是筛选数据包为IPv4广播的连接

 

当然还有很多更为细节的过滤方式,比如根据数据包的长度,或者数据包中某一个属性筛选连接。大家可以参考https://www.tcpdump.org/manpages/pcap-filter.7.html了解更多。


EXAMPLES

最后引用来官网给的例子:

To select all packets arriving at or departing from sundown:

host sundown

To select traffic between helios and either hot or ace:

host helios and \( hot or ace \)

To select all IP packets between ace and any host except helios:

ip host ace and not helios

To select all traffic between local hosts and hosts at Berkeley:

net ucb-ether

To select all ftp traffic through internet gateway snup:

gateway snup and (port ftp or ftp-data)

To select traffic neither sourced from nor destined for local hosts (if you gateway to one other net, this stuff should never make it onto your local net).

ip and not net localnet

To select the start and end packets (the SYN and FIN packets) of each TCP conversation that involves a non-local host.

tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net localnet

To select all IPv4 HTTP packets to and from port 80, i.e. print only packets that contain data, not, for example, SYN and FIN packets and ACK-only packets. (IPv6 is left as an exercise for the reader.)

tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)

To select IP packets longer than 576 bytes sent through gateway snup:

gateway snup and ip[2:2] > 576

To select IP broadcast or multicast packets that were not sent via Ethernet broadcast or multicast:

ether[0] & 1 = 0 and ip[16] >= 224

To select all ICMP packets that are not echo requests/replies (i.e., not ping packets):

icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply
icmp6[icmp6type] != icmp6-echo and icmp6[icmp6type] != icmp6-echoreply

 

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值