[Tutor] Network Sniffing on Windows with Python 3.6

Alan Gauld alan.gauld at yahoo.co.uk
Fri Apr 7 05:00:24 EDT 2017


On 07/04/17 06:07, Some Developer wrote:

> How would I go about writing a Python 3.6 script for Windows that would 
> sniff the network traffic and take the individual packets and then 
> reassemble them into something that is useful data?

That is definitely possible using Python although it is fairly advanced
networking code. Certainly further than I've ever gone using Python.

> I was thinking of installing Wireshark to have a look at the network 
> communications but I wasn't really sure what I would do with the data. 
> Are there any library functions in Python 3.6 that would help with this 
> task?

For sure, but I'd definitely install wireshark, if nothing else
its likely to be near essential in debugging your code.

> Also does the Python script require admin permissions for this to work 
> or can it run as a normal user? It doesn't matter if it does require 
> admin permissions but it would be better for my users if it didn't 
> require admin permissions.

That's more likely to be a feature of the OS and who is running the
code producing the data. Unless everything is running as your
user account I'd suspect admin privileges will be necessary
 - in fact I'd hope so!
> there are any books on the subject that would be even better as I like 
> reading books on programming subjects.

My two main sources for Python networking are:

Python Network Programming by Goerzen, published by APress
This is a great intro to the general theory of network programming
as well as the Python specifics. If you are already familiar with
networking through say, the classic Stephens books on C networking, then
this will be familiar ground. Its good if you want to
understand what you are doing rather than just copy somebody
else's code.

Programming Python 4th edition.
A monster book (1600 pages?) with about 500 pages dedicated to
networking. It's a book within a book! A bjt less background theory,
more code. If you like books this is a great value buy since it
also covers GUI/Tkinter(400 pages) and  Systems programming
(200 pages) as well as miscellaneous other topics.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list