Shuts down a TCP connection on Linux or macOS. Local and remote endpoint arguments can be copied from the output of ‘netstat -lanW’.
The functionality offered by tcp_killer is intended to mimic TCPView‘s “Close Connection” functionality and tcpdrop‘s functionality on Linux and macOS.
geffner@ubuntu:~$ # Create a server to listen on TCP port 12345
geffner@ubuntu:~$ nc -d -l -p 12345 &
[1] 135578
geffner@ubuntu:~$ # Connect to the local server on TCP port 12345
geffner@ubuntu:~$ nc -v -d localhost 12345 &
[2] 135579
Connection to localhost 12345 port [tcp/*] succeeded!
geffner@ubuntu:~$ # Find the connection endpoints
geffner@ubuntu:~$ netstat -lanW | grep 12345.*ESTABLISHED
tcp 0 0 127.0.0.1:33994 127.0.0.1:12345 ESTABLISHED
tcp 0 0 127.0.0.1:12345 127.0.0.1:33994 ESTABLISHED
geffner@ubuntu:~$ # Kill the connection by copying and pasting the output of netstat
geffner@ubuntu:~$ python tcp_killer.py 127.0.0.1:33994 127.0.0.1:12345
TCP connection was successfully shutdown.
[1]- Done nc -d -l -p 12345
[2]+ Done nc -v -d localhost 12345
Dependencies
lsof
This program uses lsof to find the process and socket file descriptor associated with a given TCP connection.
lsof can be installed via your package management system (for example, sudo apt-get install lsof).
frida
This program uses the frida framework to perform code injection.
Frida can be installed as follows: sudo pip install frida
tcp_killer
Shuts down a TCP connection on Linux or macOS. Local and remote endpoint arguments can be copied from the output of ‘netstat -lanW’.
The functionality offered by tcp_killer is intended to mimic TCPView‘s “Close Connection” functionality and tcpdrop‘s functionality on Linux and macOS.
Basic Usage
python tcp_killer.py [-verbose] <local endpoint> <remote endpoint>Arguments:
Examples:
Full Example
Dependencies
lsof
This program uses lsof to find the process and socket file descriptor associated with a given TCP connection.
lsof can be installed via your package management system (for example,
sudo apt-get install lsof).frida
This program uses the frida framework to perform code injection.
Frida can be installed as follows:
sudo pip install fridaDisclaimer
This is not an official Google product.