sniffing btw my web browser and a server
kuntsi at cc.helsinki.fi.spam.no
Wed Dec 27 23:11:17 EST 2000
June Kim <junaftnoon at nospamplzyahoo.com> wrote:
> 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?
Writing a simple HTTP-proxy in Python that dumps all the data (or just the
HTTP-headers for both requests and replies, if that is enough) is quite easy:
-create a INET-socket, and start accepting connections.
-When you get a connection, read the request, and print the data to a file
-Open a socket to the server (you get this from the first line of the request,
as the request made by browser to your HTTP-proxy tells you this)
-write the request to the server
-read the response from the server, dump/print the data, and send it to the
-go back to accepting connections.
To make it fancy, you can make it multiplexed or threaded, but it's not
Do note, that you have to
1) change the first line of the request when you make the req to the server
i.e. from HTTP-proxy-request to HTTP-server-request
2) open the connection to a real HTTP-proxy instead of the server, and let it
take care of figuring out the web-server's address and port.
/"\ | iki.
\ / ASCII Ribbon Campaign | fi/
X Against HTML Mail | mickut
More information about the Python-list