6

I want to capture the packet using pyshark. but I could not capture the packet on windows 7.

this is my python code


import pyshark
def NetCap():
    print 'capturing...'
    livecapture = pyshark.LiveCapture(interface="eth0", output_file='./test.pcapng')
    livecapture.sniff(packet_count=10)
    print 'end of capture.'
    print livecapture

if __name__ == "__main__":
    NetCap()

this is result


capturing...
end of capture.
<LiveCapture (0 packets)>

Livecapture is 0 packets. I don't know what is the matter. please help me.

user158
  • 12,852
  • 7
  • 62
  • 94
Choi Doo-Seop
  • 95
  • 1
  • 2
  • 10

2 Answers2

4

open cmd then go to C:\Program Files\Wireshark and type:

tshark -D

this will give you a list like:

C:\Program Files\Wireshark>tshark -D
1. \Device\NPF_{BF2D596D-AEB8-4AF3-88A2-FF31441BB262} (VMware Network Adapter VMnet8)
2. \Device\NPF_{7AB58B39-455D-4A40-AA3A-678491E70B27} (Local Area Connection* 4)
3. \Device\NPF_{7FEC3EE6-0676-4E81-8B13-FBD5716BF2BF} (Wi-Fi)
4. \Device\NPF_{10D9C98D-BF03-4CE5-A58C-5A726BC6066A} (Ethernet)
5. \Device\NPF_{45AD9B2A-DB01-4EDE-A922-C2DD6D868568} (VMware Network Adapter VMnet1)
6. \\.\USBPcap1 (USBPcap1)

now you can use any of the interface as required by this:

import pyshark
livecapture = pyshark.LiveCapture(interface='\\Device\\NPF_{7FEC3EE6-0676-4E81-8B13-FBD5716BF2BF}', output_file='./test.pcapng')
tom
  • 21,844
  • 6
  • 43
  • 36
2

windows doesnot have any interface named eth0. they use the full name as Ethernet adapter Ethernet. please use str() command and try solving it.