0

I have write code for sniffing packet using scapy in python. And i got some problems that make me confused, showed by this picture below.

enter image description here -> Important

so this is the code

import subprocess
import time
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
logging.getLogger("scapy.loading").setLevel(logging.ERROR)
logging.getLogger("scapy.interactive").setLevel(logging.ERROR)

try:
    from scapy.all import *
except ImportError:
    sys.exit()

interface = 'wlp10s0'
subprocess.call(["ifconfig",interface,"promisc"],stdout=None,stderr=None,shell=False)
print 'Interface has been set to Promiscous mode'

totalpackets=0
sniffingtime=10
protocols=0
infinite=1

def timenow():
    currenttime=time.strftime("%m%d%y-%H%M%S")
    return currenttime

def export():
    p = sniff(iface='wlp10s0',timeout=sniffingtime,count=0)
    wrpcap('./home/Desktop/' + timenow() + '.pcap',p);

while infinite==1 :
    export()

I hope someone can helping me solve this code.

Thank you.

1 Answer 1

0

./home/... is an I valid path. Use /home/... instead.

It clearly says “OSerror: No such file or directory”. You may want to lookup those errors ;-)

2
  • I tried, but the errors is same as before. Thank you for helping. If you have any idea please let me know. Thankyou
    – user10154223
    Commented Jan 15, 2019 at 2:19
  • Try to use a different file path (maybe one without the date). The format’s probably wrong
    – Cukic0d
    Commented Jan 15, 2019 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.