首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >pyshark.LiveCapture不捕获数据包

pyshark.LiveCapture不捕获数据包
EN

Stack Overflow用户
提问于 2020-05-14 07:15:20
回答 1查看 2.2K关注 0票数 3

我正在我的Linux系统上运行pySharver0.4.2.9版。我试图从我的无线接口‘to 01’中捕获数据包,但是pyshark.LiveCapture( interface =‘to 01’)捕获了0个数据包。就像tshark捕获数据包一样,很好。

代码语言:javascript
代码运行次数:0
运行
复制
>>> import pyshark
>>> cap=pyshark.LiveCapture(interface='wl01')
>>> cap.sniff(timeout=50)
>>> cap
<LiveCapture (0 packets)>

我还尝试了capture.set_debug(),以获得以下内容:

代码语言:javascript
代码运行次数:0
运行
复制
>>> capture = pyshark.LiveCapture(interface='wl01')
>>> capture.set_debug()
>>> capture.sniff(timeout=50)
2020-05-14 12:57:37,348 - LiveCapture - DEBUG - Creating Dumpcap subprocess with parameters: /usr/bin/dumpcap -q -i wl01 -w -
2020-05-14 12:57:37,350 - LiveCapture - DEBUG - Dumpcap subprocess created
2020-05-14 12:57:37,351 - LiveCapture - DEBUG - Creating TShark subprocess with parameters: /usr/bin/tshark -l -n -T pdml -r -
2020-05-14 12:57:37,351 - LiveCapture - DEBUG - Executable: /usr/bin/tshark
2020-05-14 12:57:37,353 - LiveCapture - DEBUG - TShark subprocess created
2020-05-14 12:57:37,353 - LiveCapture - DEBUG - Starting to go through packets
Capturing on 'wl01'
dumpcap: The capture session could not be initiated on interface 'wl01' (No such device exists).
Please check that you have the proper interface or pipe specified.
>>> capture
<LiveCapture (0 packets)>

任何帮助都是appreciated.Thanks!

编辑1:在使用sudo运行脚本时,我得到以下内容:

代码语言:javascript
代码运行次数:0
运行
复制
user@aritri:~/Documents/tshark$ sudo python3 test.py
[sudo] password for user: 
Task exception was never retrieved
future: <Task finished coro=<Capture.packets_from_tshark() done, defined at /home/user/.local/lib/python3.6/site-packages/pyshark/capture/capture.py:279> exception=TSharkCrashException('TShark seems to have crashed (retcode: 1). Try rerunning in debug mode [ capture_obj.set_debug() ] or try updating tshark.',)>
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.6/site-packages/pyshark/capture/capture.py", line 288, in packets_from_tshark
    await self._go_through_packets_from_fd(tshark_process.stdout, packet_callback, packet_count=packet_count)
  File "/home/user/.local/lib/python3.6/site-packages/pyshark/capture/capture.py", line 306, in _go_through_packets_from_fd
    psml_structure=psml_struct)
  File "/home/user/.local/lib/python3.6/site-packages/pyshark/capture/capture.py", line 366, in _get_packet_from_stream
    new_data = await stream.read(self.DEFAULT_BATCH_SIZE)
  File "/usr/lib/python3.6/asyncio/streams.py", line 634, in read
    yield from self._wait_for_data('read')
  File "/usr/lib/python3.6/asyncio/streams.py", line 464, in _wait_for_data
    yield from self._waiter
concurrent.futures._base.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.6/site-packages/pyshark/capture/capture.py", line 293, in packets_from_tshark
    await self.close_async()
  File "/home/user/.local/lib/python3.6/site-packages/pyshark/capture/capture.py", line 441, in close_async
    await self._cleanup_subprocess(process)
  File "/home/user/.local/lib/python3.6/site-packages/pyshark/capture/capture.py", line 434, in _cleanup_subprocess
    % process.returncode)
pyshark.capture.capture.TSharkCrashException: TShark seems to have crashed (retcode: 1). Try rerunning in debug mode [ capture_obj.set_debug() ] or try updating tshark.
Exception ignored in: <bound method Capture.__del__ of <LiveCapture (0 packets)>>
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.6/site-packages/pyshark/capture/capture.py", line 446, in __del__
  File "/home/user/.local/lib/python3.6/site-packages/pyshark/capture/capture.py", line 437, in close
  File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
  File "/home/user/.local/lib/python3.6/site-packages/pyshark/capture/capture.py", line 441, in close_async
  File "/home/user/.local/lib/python3.6/site-packages/pyshark/capture/capture.py", line 434, in _cleanup_subprocess
pyshark.capture.capture.TSharkCrashException: TShark seems to have crashed (retcode: 1). Try rerunning in debug mode [ capture_obj.set_debug() ] or try updating tshark.

编辑2:这两个命令'tshark‘和'sudo’提供相同的输出。

代码语言:javascript
代码运行次数:0
运行
复制
user@aritri:~$ tshark -D
1. wlo1
2. any
3. lo (Loopback)
4. eno1
5. bluetooth0
6. nflog
7. nfqueue
8. usbmon1
9. usbmon2
10. ciscodump (Cisco remote capture)
11. dpauxmon (DisplayPort AUX channel monitor capture)
12. randpkt (Random packet generator)
13. sdjournal (systemd Journal Export)
14. sshdump (SSH remote capture)
15. udpdump (UDP Listener remote capture)

user@aritri:~$ sudo tshark -D
[sudo] password for user: 
Running as user "root" and group "root". This could be dangerous.
1. wlo1
2. any
3. lo (Loopback)
4. eno1
5. bluetooth0
6. nflog
7. nfqueue
8. usbmon1
9. usbmon2
10. ciscodump (Cisco remote capture)
11. dpauxmon (DisplayPort AUX channel monitor capture)
12. randpkt (Random packet generator)
13. sdjournal (systemd Journal Export)
14. sshdump (SSH remote capture)
15. udpdump (UDP Listener remote capture)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-05-14 09:35:45

接口名为wlo1,但在代码中使用wl01o != 0

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61791435

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档