[英]Python - scapy sniff() filter with port range
I want to sniff all packets in a range of ports with the scapy module. 我想使用scapy模块嗅探一系列端口中的所有数据包。
This is how it works for one port.. 这是一个端口的工作原理..
from scapy.all import *
packets = sniff(filter='udp and port 14000')
But rather than only port 14000, i want to sniff the range from 14000 up to 64000. 但不仅仅是端口14000,我想嗅探范围从14000到64000。
The following code does not work.. 以下代码不起作用..
from scapy.all import *
packets = sniff(filter='udp and port 14000 to 64000')
What should the filter string look like if I want to do this? 如果我想这样做,过滤器字符串应该是什么样的?
Scapy uses the BPF syntax for specifying the filter: Scapy使用BPF语法指定过滤器:
packets = sniff(filter='udp and portrange 14000-64000')
Note that the range is inclusive and that no spaces are allowed around the '-'
sign. 请注意,范围是包含的,并且
'-'
符号周围不允许有空格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.