Python Forum
sniffing real time with pyshark or scapy - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Networking (https://python-forum.io/forum-12.html)
+--- Thread: sniffing real time with pyshark or scapy (/thread-6119.html)



sniffing real time with pyshark or scapy - jeanapala - Nov-06-2017

Hello , i'am looking for a way to sniff the traffic in real time and save it on a cap file or csv so i can load it in logstash .
(i tried pyshark but i got a none csv file format while opening the file)

import os
import pyshark

#sniff de l'interface en temps réel
fichier = open("sniff.csv", "w") #création du fichier qui contiendra les capture
#Faire Une boucle infini
capture = pyshark.LiveCapture(interface ='eth0',decryption_key='',encryption_type='wpa-psk')
capture.sniff (timeout=10)
for pkt in capture:
pkt = str(pkt) #conversion en chaine de caractère
fichier.write(pkt) #Ecrtit le resultat mais pas sur le bon format







Thank you


RE: sniffing real time with pyshark or scapy - Larz60+ - Nov-07-2017

I don't get the file error.
You should probably use the csv package if you need output to be csv
but this has nothing to do with your error.


RE: sniffing real time with pyshark or scapy - jeanapala - Nov-16-2017

can i send you some screenshots by email ?