Python Forum

Full Version: sniffing real time with pyshark or scapy
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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.
can i send you some screenshots by email ?