Skip to main content

A TCPKill utility written in python and scapy

Project description

RSTconn

A TCPKill is a utility that implements a TCP reset attack for IPv4 and IPv6 written in python and scapy.

RESET is a flag in TCP packets to indicate that the conection is not longer working. If any of the two participants in a TCP connection send a packet contains such a RESET flag, the connection will be closed immediately.

Thus it can be use to attack TCP connections once the attacker can forge TCP packets from any of the two parties if he or she know their IPs, ports and the sequence number of current TCP connection.

The attack can be used to make certain users to fail to use certain network services based on TCP if we know the information above.

In practice, we should eavesdrop the victims’ communications to get their IPs, ports and the sequence number. You can do it by:

Trick them to connect a malicious WiFi, or use other ways to hijack their communications.

Sniff WiFi packets if they are near you and using WiFi. We can filter the TCP packets and find the newest packets that we want to attack.

We can sends a TCP packet with RESET flag and the IPs and ports of source and destination are sniffed from victims. What’s more, the sequence number will increase in TCP communication, its value should be equal or lager than the ack value from the lastest packet the sender received and in the window of receiver. So we should update it. To ensure successful, we can send lots of packets with different sequence number which is larger than the sniffed ack field.

Setup

pip install rstconn

Usage

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
  --ip IP, -ip IP       Server IPv4
  --port PORT, -p PORT  Server port
  --packet-count PACKET_COUNT, -pc PACKET_COUNT
                        listen for a maximum of N 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 listens for the matching connections and than sends a number of SYN/ACK and RST packets to the client to get the connection be killed.

The number of packets is configurable by --packet-count, --iface and -ip and --port are related to the local server port to be listen on.

rstconn -i lo -ip 127.0.0.1 -p 8000 --packet-count 50

Demo

apt install netcat
  • Setup TCP connection. In one terminal window run nc -nvl 8000 to set up a server
  • In another terminal window run nc 127.0.0.1 8000 to connect to the server
  • In a third window run rstconn to run our sniffing program

You should see the sniffing program log some output, send a RST packet, and the nc connection should be broken.

If you want to test rstconn in IPv6, use instead:

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

Credits

References

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rstconn-0.2.0.tar.gz (5.5 kB view details)

Uploaded Source

File details

Details for the file rstconn-0.2.0.tar.gz.

File metadata

  • Download URL: rstconn-0.2.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.10

File hashes

Hashes for rstconn-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e1885aea904f1ba05d35c145c3ff9b250445e18ee1018bb023ac878cfc563625
MD5 a7b7a84007a463ad43ad40bb22a6c7f4
BLAKE2b-256 9f78661f25b2a2c4262f839dfe04ee802e844784c03509ab97e9a6f5ec52ed75

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page