Scapy中的TCP层包含源端口:
>>> a[TCP].sport 80
有没有一种简单的方法将端口号转换为服务名称?我见过Scapy TCP_SERVICES
并且UDP_SERVICES
要翻译端口号,但是
print TCP_SERVICES[80] # fails print TCP_SERVICES['80'] # fails print TCP_SERVICES.__getitem__(80) # fails print TCP_SERVICES['www'] # works, but it's not what i need 80
有人知道如何将端口映射到服务?
先感谢您
Python的套接字模块将这样做:
>>> import socket >>> socket.getservbyport(80) 'http' >>> socket.getservbyport(21) 'ftp' >>> socket.getservbyport(53, 'udp') 'domain'