开发者

Python Firewall for Windows?

开发者 https://www.devze.com 2023-01-23 09:27 出处:网络
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

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
0

精彩评论

暂无评论...
验证码 换一张
取 消