Inspired by violent python and some of the scripts in there, I would like to make a http request sniffer to sniff http requests on a network.

In the book violent python there is a tutorial for a section to make a google keg logger (gets what people search on a network)

Any suggested libraries, links to example code etc would be helpful

There is a packet sniffer for linux here:

http://www.binarytides.com/python-packet-sniffer-code-linux/

It uses the socket module to grab incoming and outgoing packets. It's pretty low-level stuff. The packet data is raw bytes, so you would have to decode/translate them.

I converted it to Python 3 and put it on my pastebin:

http://welbornprod.com/paste/?id=fgyx

That's about as far as I can go with it right now though. It would be trivial to add some sort of filters to it based on packet type or address. I may do that later if I get bored. Mine uses docopt. It's an excellent argument parser that would make it really easy to add filters like that as command-line arguments.

I would put the code in this comment but it's 216 lines. I will if the mods want me to.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.