0

I would like to code a Python program that listens on a range of ports for incoming sin requests (possibly ack and fin as well). I then want this program to log the time, ip, and port of these sent packets.

Only thing is I really don't know where to start. I don't want anyone to hold my hand here, but I do need someone to point me in the right direction

user1577775
  • 59
  • 3
  • 7
  • evidently, most of this has already been done: http://stackoverflow.com/questions/8148608/network-traffic-monitor-with-pcapy-in-python – reckoner Aug 12 '12 at 23:24

2 Answers2

3

You are probably looking for raw sockets, see http://docs.python.org/library/socket.html

If you just want to capture received packets on a port range and log it, you should probably save yourself the trouble and use Wireshark http://www.wireshark.org/

Martin Samson
  • 3,970
  • 21
  • 25
  • My goal is to make a daemon I can run that will log connection attempts on common webserver and ssh ports. I know there are programs that do this already, but I want the experience coding it myself. Thanks for the link on Raw Sockets, ill check it out – user1577775 Aug 12 '12 at 02:48
1

if it is for educational purposes; you could use scapy as a network sniffer. Otherwise just configuring your firewall to log appropriate events might be enough.

jfs
  • 399,953
  • 195
  • 994
  • 1,670