C# 监控传出的互联网流量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/903612/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 01:51:00  来源:igfitidea点击:

Monitoring outgoing internet traffic

c#.netnetworkingnetwork-programming

提问by

Is there a way to monitoring internet traffic programatically? I would like to log the pages users are visiting on the Internet. Can this be achieved with .NET code, is there a 3rd party .NET component that could be used to retrieved data.

有没有办法以编程方式监控互联网流量?我想记录用户在 Internet 上访问的页面。这可以用 .NET 代码实现吗,是否有 3rd 方 .NET 组件可用于检索数据。

Information about Internet traffic must be stored to a database so I cannot use a plugin or something for IE. We are also looking to include this code into our existing product so we cannot use a 3rd party product that cannot be redistributed.

有关 Internet 流量的信息必须存储到数据库中,因此我无法为 IE 使用插件或其他东西。我们还希望将此代码包含在我们现有的产品中,这样我们就不能使用无法重新分发的 3rd 方产品。

It would be cool if this thing could monitor traffic for all browsers but monitoring IE traffic might also be sufficient.

如果这个东西可以监控所有浏览器的流量会很酷,但监控 IE 流量也可能就足够了。

回答by Vinko Vrsalovic

Setting up a sniffer is doable via the WinPCaplibrary, which has several projects wrapping it to .NET:

可以通过WinPCap库设置嗅探器,该库有几个项目将其包装到 .NET:

and probably some others as well, just a matter of Googling.

可能还有其他一些,只是谷歌搜索的问题。

回答by Jeff

You would need to build some software that acts as a proxy. You should start by looking at programs like "Fiddler" to understand the concepts and what you need to implement.

您需要构建一些充当代理的软件。您应该首先查看诸如“Fiddler”之类的程序,以了解概念以及您需要实现的内容。

If you want my profesional opionon you should go to Server Fault and ask for opionons for low cost internet proxy solution. Writing this thing yourself while challenging and fun will not make good business sense.

如果你想要我的专业意见,你应该去服务器故障并要求低成本互联网代理解决方案的意见。在具有挑战性和乐趣的同时自己编写这件事不会具有良好的商业意义。

回答by JonnyBoats

If you want to monitor all traffic from everyone on your network consider a product like Microsoft's Internet Security and Acceleration (ISA) Server

如果您想监控网络上每个人的所有流量,请考虑使用 Microsoft 的Internet Security and Acceleration (ISA) Server 这样的产品

While this is probably overkill for what you want, the point is that you need a way to have all traffic go through a single point (a proxy server) where the traffic can be logged. Since all traffic goes through this one point, users can't avoid detection by using an alternate browser etc.

虽然这对于您想要的东西来说可能有点矫枉过正,但关键是您需要一种方法让所有流量通过可以记录流量的单个点(代理服务器)。由于所有流量都经过这一点,因此用户无法通过使用备用浏览器等来避免检测。

回答by brickner

You can also try Pcap.Netto easily use WinPcap in .NET. It is a wrapper for WinPcap written in C++/CLI and C# and includes a packet interpretation and creation framework.

您也可以尝试Pcap.Net,以便在 .NET 中轻松使用 WinPcap。它是用 C++/CLI 和 C# 编写的 WinPcap 包装器,包括数据包解释和创建框架。

回答by Oliver

Like JDalready mentioned you should take a look into Fiddler. With this proxy you are able to monitor all the web traffic (if your browser is configured to use fiddler as proxy).

就像JD已经提到的,你应该看看Fiddler。使用此代理,您可以监控所有网络流量(如果您的浏览器配置为使用 fiddler 作为代理)。

If you don't want fiddler as a standalone application and need its functionality within your own app, you should take a look into FiddlerCore. It is a .Net assembly which encapsulates the core functionality of Fiddler.

如果您不希望 fiddler 作为独立应用程序并且需要在您自己的应用程序中使用它的功能,您应该查看FiddlerCore。它是一个 .Net 程序集,封装了 Fiddler 的核心功能。

If you need a more raw way to sniff into the data (maybe you don't want to [or can't] configure the proxy of the client) the answer from Vinkowill help you further.

如果您需要更原始的方式来嗅探数据(也许您不想 [或不能] 配置客户端的代理),Vinko的回答将进一步帮助您。