3

Possible Duplicate:
How do I programatically collect packets from passively sniffing?

I am interested in figuring out how to go about writing a program like wireshark. The program should be able to listen on any port without disrupting network traffic.

The exact programming language is less interesting than the OS principle itself, so let's say that either C++ or Python would work just fine.

How would you do this on Windows? And on Linux?

Thanks!

Community
  • 1
  • 1
Guy Adini
  • 5,188
  • 5
  • 32
  • 34

2 Answers2

2

On Linux you use libpcap, on Windows you use the windows port of it, winpcap.

Since you tagged the question with : There are python bindings (pylibpcap) for libpcap.

ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
1

On Windows, you'll probably want to look into WinPcap (well-documented packet capture library). You may also be interested in developing a filter driver for your network adapter in order to capture network traffic.

Reference: http://www.winpcap.org/

On Linux, (Python in particular), you can look into the socket library. It'll allow you to open up an INET socket and sniff on a port you specify.

Reference: http://docs.python.org/library/socket.html

Enjoy and good luck!

Daniel Li
  • 14,976
  • 6
  • 43
  • 60