Python - scapy sniff() filter with port range
<p>I want to sniff all packets in a range of ports with the scapy module.</p>

<p>This is how it works for one port..</p>

<pre><code>from scapy.all import *
packets = sniff(filter='udp and port 14000')
</code></pre>

<p>But rather than only port 14000, i want to sniff the range from 14000 up to 64000.</p>

<p>The following code does not work..</p>

<pre><code>from scapy.all import *
packets = sniff(filter='udp and port 14000 to 64000')
</code></pre>

<p>What should the filter string look like if I want to do this?</p>

<p><em>Scapy</em> uses the <a href="http://biot.com/capstats/bpf.html" rel="nofollow"><em>BPF</em> syntax</a> for specifying the filter:</p>

<pre><code>packets = sniff(filter='udp and portrange 14000-64000')
</code></pre>

<p>Note that the range is inclusive and that no spaces are allowed around the <code>'-'</code> sign.</p>

python range port scapy packet-sniffers