【发布时间】:2012-02-04 03:39:44
【问题描述】:
或者换一种方式理解VB.NET中如何绕过Windows的防火墙?
【问题讨论】:
-
您已经进行了哪些研究?谷歌发现了什么?
-
绕过任何防火墙听起来都不是很安全。为什么需要?你只是想让你的程序提示用户允许吗?您只是想务实地添加规则吗?
或者换一种方式理解VB.NET中如何绕过Windows的防火墙?
【问题讨论】:
我找到了通过托管代码访问 Windows 防火墙 API 的指南。这将允许您在程序中自动打开和关闭端口,这是您要找的吗?
它专门给出了这个例子来将一个程序添加到受信任的程序列表中。
INetFwAuthorizedApplications applications;
INetFwAuthorizedApplication application;
application.Name = “Internet Explorer”;/*set the name of the application */
application.ProcessImageFileName = "C:\\Program Files\\Internet Explorer\\iexplore.exe" /* set this property to the location of the executable file of the application*/
application.Enabled = true; //enable it
/*now add this application to AuthorizedApplications collection */
Type NetFwMgrType = Type.GetTypeFromProgID("HNetCfg.FwMgr", false);
INetFwMgr mgr = (INetFwMgr)Activator.CreateInstance(NetFwMgrType);
applications = (INetFwAuthorizedApplications)mgr.LocalPolicy.CurrentProfile.AuthorizedApplications;
applications.Add(application);
根据评论编辑 基于 cmets,您真正想要查看的是代码签名。 http://en.wikipedia.org/wiki/Code_signing
这通常意味着购买证书(有点像 SSL)并将其应用于您编译的应用程序。这与为程序集赋予强名称的 .NET 签名不同,它是不同的。
【讨论】: