sniffing btw my web browser and a server

Jan Dries jdries at
Tue Dec 26 20:33:22 EST 2000

>I'm doing some sort of web client programming, and have to observe the
>messages that my browser and web-servers transmit, being tired of guessing
>what the messages'd be and looking up the references and the specifications.
>Anyone has done it in Python or knows how it could be done?

If all you want is to see the trafic between a browser and server, you
basically need a proxy server. If it's for testing purposes, and if it's
just to see the trafic (i.e. without interpreting/altering it), this
isn't too hard to do. I did it in C once, and it took me no more than 2
or 3 pages of code. It should be shorter in Python. 
If you want to monitor trafic to one particular server, it's even
easier, since you don't have to extract the name/ip address of server to
connect to from the info sent by the browser.
Your program must just listen on a port the browser connects to (e.g.
8080), and connect to a port the server is listening on (e.g. 80) and it
just sends al the info it receives on port 8080 to the connection on
port 80, and sends everything it receives back from port 80 to the
connection on port 8080. And in the mean time it logs everything it
sends and receives. Keep doing this till either the sender or the
receiver closes the socket.
And that's more or less it. 


More information about the Python-list mailing list