Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inform the user of unsupported protocol usage #692

Open
weshouman opened this issue Apr 5, 2024 · 0 comments · Fixed by amlamarra/pyshark#4 · May be fixed by #693
Open

Inform the user of unsupported protocol usage #692

weshouman opened this issue Apr 5, 2024 · 0 comments · Fixed by amlamarra/pyshark#4 · May be fixed by #693
Labels

Comments

@weshouman
Copy link

weshouman commented Apr 5, 2024

Describe the bug
When a capture's display_filter is set to a protocol that is not supported, tshark crashes without a clear error.

An unsupported protocol could be:

  • A protocol that is defined as in the user's plugins dir but the user is sniffing the packets over an interface using a sudo user, providing the user with a hint of the error would be clearer to handle such configuration.
  • A mis-typed protocol, for example capital letters (as seen in a lua dissector) instead of small letters
Traceback (most recent call last):
  ...
  File "/path_to_project/app.py", line 73, in capture_packets
    for packet in capture.sniff_continuously():
  File "/path_to_project/venv/lib/python3.10/site-packages/pyshark/capture/capture.py", line 237, in _packets_from_tshark_sync
    self.eventloop.run_until_complete(
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/path_to_project/venv/lib/python3.10/site-packages/pyshark/capture/capture.py", line 380, in _cleanup_subprocess
    raise TSharkCrashException(f"TShark (pid {process.pid}) seems to have crashed (retcode: {process.returncode}).\n"
pyshark.capture.capture.TSharkCrashException: TShark (pid 3357406) seems to have crashed (retcode: 4).
Last error line: ^~~~~~~
Try rerunning in debug mode [ capture_obj.set_debug() ] or try updating tshark.

To Reproduce
Steps to reproduce the behavior:

# PROTOCOL_NAME is not found in `tshark -G protocols | awk -F'\t' '{print $3}'`
capture = pyshark.LiveCapture(interface=interface, display_filter='PROTOCOL_NAME')
for packet in capture.sniff_continuously():
    print(packet)

Expected behavior
If protocol is not found, an error message giving a hint for that.

Versions (please complete the following information):

  • OS: all
  • pyshark version: all
  • tshark version: 4.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant