Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pyshark can not capture the packet on windows 7 (python)

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.

like image 479
Doo-Seop Choi Avatar asked Mar 14 '16 10:03

Doo-Seop Choi


1 Answers

open cmd and type:

tshark -D

this will give you a list like:

C:\WINDOWS\system32>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')
like image 199
ayedaemon Avatar answered Sep 22 '22 01:09

ayedaemon