1

any ideas on how to block a network port from being used, or one that is currently in use? For example, say I want to block port 23 from being used. by used, I mean allowing connections to or from it.

thanks in advance.

ekhumoro
  • 115,249
  • 20
  • 229
  • 336

1 Answers1

1

The solution need to be done via the command line however you can use python's os library to run scripts. this link is too a similar problem (just with a different port) so you can adapt that command then run it by the following script

import os
# specify the command prompt command you need to be run
command = 'netsh advfirewall firewall add rule name="BlockAIM" protocol=TCP  dir=out remoteport=23 action=block'
# assign variable to the command
output = os.popen2(command)
# To get output call output.read()

the following script blocks outgoing requests so you will need to repeat the process with dir=in

AlexanderRD
  • 2,069
  • 2
  • 11
  • 19