简体   繁体   English

C#.NET和Win2012防火墙

[英]c# .net and win2012 firewall

I'm not that advanced with C# and need some assistance compiling a code. 我在C#方面不那么先进,需要一些帮助来编译代码。 Honestly it's first time I'm doing that. 老实说,这是我第一次这样做。 I have a code that is aimed to automatically block rdp bruteforce. 我有一个旨在自动阻止rdp bruteforce的代码。 Here is acode I'm trying to compile: https://pastebin.com/CJEapWyi 这是我要编译的代码: https ://pastebin.com/CJEapWyi

I've got problems interacting with firewall api. 与防火墙api交互时出现问题。 In the internet people say I have to add reference to FirewallAPI.dll and I'm compiling code using following CLI: 在互联网上,人们说我必须添加对FirewallAPI.dll的引用,并且正在使用以下CLI编译代码:

    c:\Windows\Microsoft.NET\Framework\v4.0.30319>csc.exe /r:"c:\windows\system32\FirewallApi.dll" c:\Users\Administrator\Documents\rdpbrute.cs

and it says: 它说:

error CS0006: Metadata file 'FirewallApi.dll' could not be found 错误CS0006:找不到元数据文件'FirewallApi.dll'

Is there any way to compile a program that interacts with firewall using this compiler or I have to install visual studio? 有什么办法可以使用此编译器编译与防火墙交互的程序,或者我必须安装Visual Studio?

Thanks for your time. 谢谢你的时间。

Instead of referencing c:\\windows\\system32\\FirewallApi.dll you should first create COM interop library Interop.FirewallApi.dll and then add reference to it. 而不是引用c:\\ windows \\ system32 \\ FirewallApi.dll,您应该首先创建COM互操作库Interop.FirewallApi.dll ,然后添加对它的引用。

Interop library can be created with use of tlbimp.exe tool that is part of Visual Studio installation. 可以使用tlbimp.exe工具创建Interop库, 工具是Visual Studio安装的一部分。 A more simple approach is to use Add reference feature inside of VS (just select c:\\windows\\system32\\FirewallApi.dll and interop library will be created automatically). 一种更简单的方法是在VS中使用“ 添加引用”功能(只需选择c:\\ windows \\ system32 \\ FirewallApi.dll,就会自动创建interop库)。

So you have to install VS as you suggested. 因此,您必须按照建议安装VS。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM