当前位置:   article > 正文

Pyshark分析pcap文件_pyshark过滤pcap

pyshark过滤pcap

Filtering packets:

Filtering packets can be done with any capture object, like so:

filtered_cap = pyshark.FileCapture(path_to_file, display_filter='http')
filtered_cap2 = pyshark.LiveCapture('eth0', bpf_filter='tcp port 80')
  • 1
  • 2

There are two types of filters, BPF filters and display filters. Generally, bpf filters are more limited but are faster while display filters can be used on pretty much any attribute of the packet but are much slower.

Note: there is currently an ISSUE with BPF filters on FileCapture and it is not recommended it be used.

See BPF syntax help HERE and display filters help HERE.

Note: we recommended using “Wireshark - Preparing and Applying Filters Feature” to select the filters.

Demo for analyzing arp packet

$ ipython
Python 2.7.8 (default, Jul  2 2014, 22:10:09)
Type "copyright", "credits" or "license" for more information.

IPython 4.2.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/156847
推荐阅读
  • 相关标签
      

    闽ICP备14008679号