gpt4 book ai didi

c++ - 判断IP是否被封

转载 作者:可可西里 更新时间:2023-11-01 11:22:59 29 4
gpt4 key购买 nike

有谁知道是否可以可靠地确定(以编程方式 C/C++...)Windows PC 上是否安装了防火墙或 IP 过滤软件?我需要检测主机操作系统是否在我的客户端软件中阻止了某个服务器 IP。

在这种情况下,我不需要担心外部硬件防火墙,因为我可以完全控制它。我只关心软件防火墙。我希望我可以迭代 Windows 网络堆栈或 NDIS 接口(interface)并确定这一点

最佳答案

在阅读了您对其他答案的一些评论后,我认为这实际上可能更接近您正在寻找的内容。它可能无法捕获所有类型的防火墙,但任何主要的防火墙供应商都应该在安全中心注册,因此可以使用此方法进行检测。您还可以将其与此处的其他一些答案结合起来,为自己提供第二层验证。

Detecting running firewalls in windows

这是一篇专家交流帖,因此您可能无法阅读该帖子。为了以防万一,我已经复制并粘贴了相关信息。它在 VBScript 中,但就您可以使用的 WMI namespace 而言,它应该为您指明正确的方向。

KemalRouge: I've just solved this problem with some help from acolleague. He pointed me in the direction of a knowledge base article,which pointed out that this information was stored in the WMI database

Basically, it's possible to query the WMI in a few lines of code tofind out what firewalls/anti-virus software is being monitored by theSecurity Center, and the status of this software (i.e. enabled or not).

Anyway, if you're interested, here's some VB code I used to test this out(you'll need a reference to "Microsoft WMI Scripting V1.2 Library"):

Private Sub DumpFirewallInfo()

Dim oLocator As WbemScripting.SWbemLocator
Dim oService As WbemScripting.SWbemServicesEx
Dim oFirewalls As WbemScripting.SWbemObjectSet
Dim oFirewall As WbemScripting.SWbemObjectEx
Dim oFwMgr As Variant


Set oFwMgr = CreateObject("HNetCfg.FwMgr")

Debug.Print "Checking the Windows Firewall..."
Debug.Print "Windows Firewal Enabled: " & oFwMgr.LocalPolicy.CurrentProfile.FirewallEnabled
Debug.Print ""

Set oFwMgr = Nothing


Debug.Print "Checking for other installed firewalls..."

Set oLocator = New WbemScripting.SWbemLocator
Set oService = oLocator.ConnectServer(".", "root\SecurityCenter")
oService.Security_.ImpersonationLevel = 3

Set oFirewalls = oService.ExecQuery("SELECT * FROM FirewallProduct") ' This could also be "AntivirusProduct"

For Each oFirewall In oFirewalls
Debug.Print "Company: " & vbTab & oFirewall.CompanyName
Debug.Print "Firewall Name: " & vbTab & oFirewall.DisplayName
Debug.Print "Enabled: " & vbTab & Format$(oFirewall.Enabled)
Debug.Print "Version: " & vbTab & oFirewall.versionNumber
Debug.Print ""
Next oFirewall

Set oFirewall = Nothing
Set oFirewalls = Nothing
Set oService = Nothing
Set oLocator = Nothing

End Sub

关于c++ - 判断IP是否被封,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/198625/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com