环境:win10 python2.7 winpcap
#-*- coding:utf-8 -*- from scapy.all import * #s数据包的回调函数 def packet_callback(packet): print packet.show() #开启嗅探器 # sniff(filter="tcp port 80",prn=packet_callback,count=1) sniff(prn=packet_callback,count=1)
运行结果:
C:Windowssystem32>D:Programspython2python E:f盘python全栈开发(从入门到放弃)9.25mail_sniffer.py ###[ Ethernet ]### dst = a4:02:b9:80:2e:88 src = 7c:03:c9:fa:ed:34 type = 0x800 ###[ IP ]### version = 4 ihl = 5 tos = 0x0 len = 407 id = 0 flags = DF frag = 0 ttl = 4 proto = udp chksum = 0xc3b2 src = 192.168.1.1 dst = 239.255.255.250 options ###[ UDP ]### sport = 41113 dport = ssdp len = 387 chksum = 0x54bc ###[ Raw ]### load = 'NOTIFY * HTTP/1.1 HOST: 239.255.255.250:1900 CACHE-CONTROL: max-age=1800 LOCATION: http://192.168.1.1:12345/description.xml NT: urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1 NTS: ssdp:alive SERVER: Trend Chip UPnP/1.0 DMS X-User-Agent: TrendChip-1.0 DMS USN: uuid:48dfd604-bd8c-11e8-9af4-7d03c9faed34::urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1 ' None C:Windowssystem32>
常用的服务的默认端口号
HTTP(超文本传输协议):80/8080/3128/8081/9080 TCP
HTTPS(安全超文本传输协议):443 TCP
FTP(文件传输协议):21 TCP
SSH(安全外壳协议):22 TCP
Telnet(远程终端协议):23 TCP
SMTP(简单邮件传输协议):25 TCP
POP3(邮局协议版本3):110 TCP
DNS(域名解析协议):53 UDP