开发者

See what website the user is visiting in a browser independent way

开发者 https://www.devze.com 2023-01-25 09:48 出处:网络
I am trying to build an application that can inform a user about website specific information whenever they are visiting a website that is p开发者_开发问答resent in my database. This must be done in a

I am trying to build an application that can inform a user about website specific information whenever they are visiting a website that is p开发者_开发问答resent in my database. This must be done in a browser independent way so the user will always see the information when visiting a website (no matter what browser or other tool he or she is using to visit the website).

My first (partially successful) approach was by looking at the data packets using the System.Net.Sockets.Socket class etc. Unfortunately I discoverd that this approach only works when the user has administrator rights. And of course, that is not what I want. My goal is that the user can install one relatively simple program that can be used right away.

After this I went looking for alternatives and found a lot about WinPcap and some of it's .NET wrappers (did I tell you I am programming c# .NET already?). But with WinPcap I found out that this must be installed on the user's pc and there is nog way to just reference some dll files and code away. I already looked at including WinPcap as a prerequisite in my installer but that is also to cumbersome.

Well, long story short. I want to know in my application what website my user is visiting at the moment it is happening. I think it must be done by looking at the data packets of the network but can't find a good solution for this. My application is build in C# .NET (4.0).


You could use Fiddler to monitor Internet traffic. It is

a Web Debugging Proxy which logs all HTTP(S) traffic between your computer and the Internet. Fiddler allows you to inspect traffic, set breakpoints, and "fiddle" with incoming or outgoing data. Fiddler includes a powerful event-based scripting subsystem, and can be extended using any .NET language.

It's scriptable and can be readily used from .NET.


One simple idea: Instead of monitoring the traffic directly, what about installing a browser extension that sends you the current url of the page. Then you can check if that url is in your database and optionally show the user a message using the browser extension.

This is how extensions like Invisible Hand work... It scans the current page and sends relevant data back to the server for processing. If it finds anything, it uses the browser extension framework to communicate those results back to the user. (Using an alert, or a bar across the top of the window, etc.)


for a good start, wireshark will do what you want. you can specify a filter to isolate and view http streams.

best part is wireshark is open source, and built opon another program api, winpcap which is open source.

I'm guessing this is what you want.

  1. capture network data off the wire
  2. view the tcp traffic of a computer, isolate and save(in part or in hole) http data.
  3. store information about the http connections

number 1 there is easy, you can google for a winpcap tutorial, or just use some of their sample programs to capture the data. I recomend you study up on the pcap file format, everything with winpcap uses this basic format and its structers.

now you have to learn how to take a tcp stream and turn it into a solid data stream without curoption, or disorginized parts. (sorry for the spelling) again, a very good example can be found in the wireshark source code.

then with your data stream, you can simple read the http format, and html data, or what ever your dealing with.

Hope that helps


If the user is cooperating, you could have them set their browser(s) to use a proxy service you provide. This would intercept all web traffic, do whatever you want with it (look up in your database, notify the user, etc), and then pass it on to the original location. Run the proxy on the local system, or on a remote system if that fits your case better.

If the user is not cooperating, or you don't want to make them change their browser settings, you could use one of the packet sniffing solutions, such as fiddler.


A simple stright forward way is to change the comupter DNS to point to your application. this will cause all DNS traffic to pass though your app which can be sniffed and then redirected to the real DNS server. it will also save you the hussel of filtering out emule/torrent traffic as it normally work with pure IP address (which also might be a problem as it can be circumvented by using IP address to browse).

-How to change windows DNS Servers

-DNS resolver

Another simple way is to configure (programmaticly) the browsers proxy to pass through your server this will make your life easier but will be more obvious to users.

  • How to create a simple proxy in C#?
0

精彩评论

暂无评论...
验证码 换一张
取 消