简体   繁体   English

Python端口侦听器

[英]Python Port Listener

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). 我想编写一个Python程序,该程序在一定范围的端口上侦听传入的sin请求(也可能是ack和fin)。 I then want this program to log the time, ip, and port of these sent packets. 然后,我希望该程序记录这些已发送数据包的时间,ip和端口。

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 我不想有人在这里牵着我的手,但我确实需要有人将我指向正确的方向

You are probably looking for raw sockets, see http://docs.python.org/library/socket.html 您可能正在寻找原始套接字,请参阅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/ 如果您只想在端口范围内捕获接收到的数据包并将其记录下来,则可以避免麻烦并使用Wireshark http://www.wireshark.org/

if it is for educational purposes; 如果是出于教育目的; you could use scapy as a network sniffer. 您可以将scapy用作网络嗅探器。 Otherwise just configuring your firewall to log appropriate events might be enough. 否则,仅将防火墙配置为记录适当的事件就足够了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM