简体   繁体   English

使用 .net 监控传入/传出 http 流量

[英]monitor incoming/outgoing http traffic with .net

I want to write a small application that can: 1. monitor URLs requested via a web browser and/or 2. monitor incoming http responses on the local machine我想编写一个小应用程序,它可以:1. 监控通过 Web 浏览器请求的 URL 和/或 2. 监控本地机器上传入的 http 响应

I have been doing some Googling, but I am not finding any clear answers.我一直在做一些谷歌搜索,但我没有找到任何明确的答案。 I am thinking maybe System.Net.Sockets.TCPListener and messing around with it, but I am under the impression that it is either not what I"m looking for or can't handle both things.我在想 System.Net.Sockets.TCPListener 可能会弄乱它,但我的印象是它要么不是我想要的,要么无法处理这两件事。

I don't need a detailed step by step explanation.我不需要详细的一步一步的解释。 Just a small overview would be helpful (if this is even possible) such as (what classes to use, what events to subscribe to, any additional details needed to instantiate necessary objects) I can google the details.只是一个小的概述会有所帮助(如果这甚至可能的话),例如(使用什么类,订阅什么事件,实例化必要对象所需的任何其他详细信息)我可以在谷歌上搜索详细信息。

为什么不扩展Fiddler满足您的需求?

You may want to use a utility like Wireshark (graphical, but not scriptable from C#, AFAIK).您可能想要使用像 Wireshark 这样的实用程序(图形,但不能从 C#、AFAIK 编写脚本)。 Wireshare uses a library called WinPcap, which does the actual monitoring of the TCP streams on the computer. Wireshare 使用一个名为 WinPcap 的库,它对计算机上的 TCP 流进行实际监控。 Decoding of the HTTP headers will need to be done in your application (this is what wireshark/tcpdump/windump should be able to do).需要在您的应用程序中完成 HTTP 标头的解码(这是 wireshark/tcpdump/windump 应该能够做到的)。 You will need to use PInvoke to call the WinPcap DLL.您将需要使用 PInvoke 来调用 WinPcap DLL。 You can find library wrappers by performing a web search for "WinPcap PInvoke".您可以通过对“WinPcap PInvoke”执行 Web 搜索来找到库包装器。

This question sound very similar to the following:这个问题听起来与以下内容非常相似:

Is there any way in .NET to programmatically listen to HTTP traffic? .NET 中有没有办法以编程方式侦听 HTTP 流量?

EDIT: Also, Capturing HTTP requests may help编辑:另外, 捕获 HTTP 请求可能会有所帮助

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

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