A lot of times, a remote host, gets bound to a port and starts running a process on it. This is not only undesirable but also can be dangerous. I made a set of two scripts, in order to solve the mess. One to check the currently active ports, another one to kill the process running on them.
The Script uses psutil
module to solve the purpose, unarguably the lsof
package provided in Linux is way better.
But as it is not cross platform, I have hardcoded using psutil
.
There are 2 scripts.
- Setup a Virtual Environment.
- Install dependencies using
pip3 install -r requirements.txt
- Go through the comments and the interactive options.
- For
ports_kill.py
Sample -python3 ports_kill.py <port number>
Sample Outputs -
- ports_scan.py
- ports_kill.py
Made by Vybhav Chaturvedi