1

I would like to Sniff/Listen on port 80 requests/responses.

Can it be done with TIdHTTPServer? If so, then how?

Edit: I want my application to listen on browser activity (it can be IE, Chrome, FF etc...) and get all the media links (images, movies). something like MediaPluck

The "problem" with MediaPluck is that you need to alters the proxy server in your web browser configuration, and I think it's a bad idea.

ZigiZ
  • 2,480
  • 4
  • 25
  • 41
  • what is "not a real question" about it? should I delete it or what? – ZigiZ Jan 14 '12 at 14:18
  • To "sniff" at the HTTP level you need a proxy. You can have a transparent one if all traffic from/to port 80 is routed through it. But to achieve it you need to perform it outside your machine through one at the internet gateway, or intercept it at the TCP level on your machine. A library like WinPvap will allow it, but then you'll have to process the whole HTTP protocol to get the informations you need. –  Jan 14 '12 at 14:54

3 Answers3

3

There is no way to use TIdHTTPServer or TIdHTTPProxyServer to sniff HTTP traffic without altering browser/client settings to connect to it. That is what Fiddler does - alters WinInet's proxy settings temporarily (IE uses WinInet, so it picks up the alterations transparently). What you are asking for requires lower-level sniffing of the network subsystem, such as what WinPCap/Ethereal does.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • I used to work with IngusSniffer years ago - found at Francois Piette's [home page](http://www.overbyte.be/eng/download.html?url=/arch/isniffer.zip). but it's not working with modern Windows OS. – ZigiZ Jan 14 '12 at 14:35
1

You can write a proxy server using TIdHTTPServer. But this "sniffing" will only work if you configure this proxy server in web browser.

UPDATE

In case you want to write another Fiddler ;-) see this answer: Any resource/codes on how fiddler works?

UPDATE 2

Based on your question update, you have two options.

Either change WinInet proxy settings as Remy pointed. For example see this question, you need to only translate code from C++ to Delphi: C++/WinInet Change Proxy Settings Windows 7.

Or write windows driver to support capturing packets. But this seems worse option for a media application.

Community
  • 1
  • 1
Pol
  • 5,064
  • 4
  • 32
  • 51
  • I want to be able to Listen to port 80 without setting the Proxy of the web browsers (which is what Fiddler does if I understand correct). – ZigiZ Jan 13 '12 at 22:12
  • 1
    Why you can't set web browser proxy settings? – Pol Jan 13 '12 at 22:29
  • Indy does not use WinINet - Remy only said that Fiddler does – mjn Jan 14 '12 at 10:56
  • @mjn - That's even better, think about it. – Pol Jan 14 '12 at 11:03
  • @Pol, do you really think that altering the proxy server setting is a better idea than using a driver? – ZigiZ Jan 14 '12 at 14:28
  • Yes, because you can alter proxy setting for user request only when it is needed in application. As opposite, network driver you only can install and uninstall with your application. Doing it just to download some media files is something to rethink. – Pol Jan 14 '12 at 14:34
  • 1
    If you install WinPCap, it has its own capture driver so you do not have to write your own. Use WinPCap's own API directly in your user-mode application like any other library, and it will talk to the driver for you. It is very easy to write a network sniffer this way. Then you can tell it to sniff all traffic on port 80 (or any other pattern criteria you need) and pass you the sniffed data. – Remy Lebeau Jan 14 '12 at 20:09
0

I can be done with Fiddler or FiddlerCore

Sam Axe
  • 33,313
  • 9
  • 55
  • 89
  • Are either of them written in Delphi and using `THTTPServer`? If not, this doesn't answer the question asked. – Ken White Jan 13 '12 at 22:22