我想用python为windows编写一个小型的自定义防火墙。如果有人能为我指明实现这一目标的正确方向,我将非常高兴。我想要阻止/取消阻止IP和端口。
发布于 2021-06-23 14:41:44
使用python的子进程模块运行以下命令提示符/ powershell命令:
将Windows防火墙服务配置为自动启动。
sc config mpssvc start=auto启动Windows防火墙服务。
net stop mpssvc && net start mpssvc启用Windows防火墙配置文件。
netsh advfirewall set allprofiles state on创建防火墙规则以拒绝来自特定IP地址的数据包输入。
netsh advfirewall firewall add rule name="BLOCK IP ADDRESS - 10.10.10.10" dir=in action=block remoteip=10.10.10.10创建防火墙规则以拒绝将数据包输出到特定IP地址。
netsh advfirewall firewall add rule name="BLOCK IP ADDRESS - 10.10.10.10" dir=out action=block remoteip=10.10.10.10https://stackoverflow.com/questions/4064561
复制相似问题