如何使用SharpPCAP库在c#中创建http过滤器? [英] How create http-filter in c# using SharpPCAP lirary?

查看:440
本文介绍了如何使用SharpPCAP库在c#中创建http过滤器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!
我想使用SharpPCAP创建http过滤器.在我的应用程序中,我使用部分URL地址为字符串的字符串,例如"goog","xxx","por" .如何使用带有这些掩码的 sharpPCAP C#阻止访问站点,并显示类似请勿访问站点:http://xx ..."的页面?

Hi everyone!
I''d like to create http-filter using SharpPCAP. In my application I use strings with part URL address like "goog", "xxx", "por". How I can block access to sites using sharpPCAP and C# with these mask and show page like "Do not make a visit to site: http://xx... "?

推荐答案

类似,这篇文章可以为您提供帮助: ^ ]
Looks like, this articles can help you out: SharpPcap - A Packet Capture Framework for .NET[^]


使用数据包捕获库是错误的方法. PCAP可以为您提供穿越网络的数据包的副本,但无法阻止它们.您不是在拦截数据,而是在听对话.这意味着用户请求仍将发送到互联网,并且仍将返回页面.

顺便说一句:当浏览器请求页面时,正在过滤的服务器/域不会显示在请求中.该信息用于解析为IP地址,以将其余的请求发送到.

正确的方法是位于您的客户端和Internet连接之间的代理服务器.每个浏览器都必须通过代理来获取请求的页面.然后,代理可以确定该请求是否有效,然后适当地检索页面或返回设计的错误页面.
Using a packet capture library is the wrong approach. PCAP can give you a copy of the packets going acrossed the wire but it cannot stop them. You''re not intercepting the data, you''re listening in on the conversation. This means that the users request will still go out to the internet and a page will still be returned.

BTW: When a browser requests a page, the server/domain you''re filtering on does NOT show up in the request. That information is used to resolve to an IP address to send the rest of the request to.

The correct approach is a proxy server that sits between your clients and the internet connection. Every browser would have to go through the proxy to get the requested pages. The proxy can then make the determination of whether that request is valid or not, then retrieve the page as appropriate or return an error page of your design.


您如何看待,使用Frameworks HttpListener TCPListener 可以帮助我吗?
在MSDN中,我看到了有关使用此类的代理的文章.但这不是任何代码.
如何使用标准.Net类进行代理?
how do You think, using Frameworks HttpListener and TCPListener can help me?
In MSDN I saw article about proxy using this classes. But it is not any code.
How can I make proxy with standard .Net classes?


这篇关于如何使用SharpPCAP库在c#中创建http过滤器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆