Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 3.4.3 - Error Pyshark capture.sniff()

Here is my code:

import pyshark
capture = pyshark.LiveCapture(interface='en0')
capture.sniff()

Now here is the error:

Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
capture.sniff()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pyshark/capture/capture.py", line 109, in load_packets
self.apply_on_packets(keep_packet, timeout=timeout)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pyshark/capture/capture.py", line 201, in apply_on_packets
return self.eventloop.run_until_complete(coro)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/trollius/base_events.py", line 350, in run_until_complete
return future.result()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/trollius/futures.py", line 286, in result
raise self._exception
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/trollius/tasks.py", line 250, in _step
result = coro.throw(exc)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pyshark/capture/capture.py", line 212, in packets_from_tshark
tshark_process = yield  From(self._get_tshark_process(packet_count=packet_count))
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/trollius/tasks.py", line 252, in _step
result = coro.send(value)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pyshark/capture/capture.py", line 298, in _get_tshark_process
parameters = [get_tshark_path(self.tshark_path), '-l', '-n', '-T', xml_type] + self.get_parameters(packet_count=packet_count)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pyshark/tshark/tshark.py", line 93, in get_tshark_path
'Search these paths: {}'.format(possible_paths)
pyshark.tshark.tshark.TSharkNotFoundException: TShark not found. Try adding its location to the configuration file. Search these paths: ['C:\\Program Files\\Wireshark\\tshark.exe', '/usr/bin/tshark', '/bin/tshark', '/usr/sbin/tshark', '/sbin/tshark']

I am running mac os 10.10.x with python 3.4.3 Installed pyshark with sudo pip3 install pyshark

like image 253
Bob Ebert Avatar asked Sep 17 '15 02:09

Bob Ebert


People also ask

What is the default set for sniffing with TShark?

Set for sniffing with tshark. Default to 50 seconds in this setup. interface: A string. Name of the interface to sniff on. bpf_filter: A string. The capture filter in bpf syntax 'tcp port 80'. Needs to be changed to match filter for the traffic sent.

Can I run a live packet capture sniffer in PyCharm?

At the bottom of the page, there is an example code for a live packet capture sniffer (pictured below). I tried to run it in pyCharm and ran into permission problems (I needed root access) so I had to run it in the terminal using the “sudo” prefix to my command. It worked!

What is TShark wrapper for Python?

Python wrapper for tshark, allowing python packet parsing using wireshark dissectors. Python2 deprecation – This package no longer supports Python2. If you wish to still use it in Python2, you can:

What does this TShark crash exception mean?

That particular exception just means that tshark crashed and doesn't say anything. Please run capture.set_debug () before running the sniff () function and post the results here.


1 Answers

Try Installing tshark that worked for me and I am on Ubuntu linux.

sudo apt-get install TShark

Blessings.

like image 125
Sean Sog Miller Avatar answered Jan 02 '23 06:01

Sean Sog Miller