I want to write a tiny custom firewall for windows,开发者_如何学Go in python. I would be very glad if someone can point me in the right direction to achieve this. I would like to have block/unblock IP and Port.
Use python's subprocess module to run the following command prompt / powershell commands:
Configure the Windows firewall service to start automatically.
sc config mpssvc start=auto
Start the Windows firewall service.
net stop mpssvc && net start mpssvc
Enable the Windows firewall profiles.
netsh advfirewall set allprofiles state on
Create a firewall rule to deny the input of packets from a specific IP address.
netsh advfirewall firewall add rule name="BLOCK IP ADDRESS - 10.10.10.10" dir=in action=block remoteip=10.10.10.10
Create a firewall rule to deny the output of packets to a specific IP address.
netsh advfirewall firewall add rule name="BLOCK IP ADDRESS - 10.10.10.10" dir=out action=block remoteip=10.10.10.10
精彩评论