Question

I'm beginner in python and scapy and I run program but it has error, just syntax error but I really don't know how to fix it. This is my code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from scapy.all import *
import sys

def parse(pkt):
   if pkt.haslayer(TCP) and pkt.getlayer(TCP).dport == 80 and pkt.haslayer(Raw):
      print pkt.getlayer(Raw).load

#start sniffing
pkts = sniff(filter="tcp and port 80",iface=“eth0”, prn=parse)

And this is error:

  File "getsniff.py", line 11
    pkts = sniff(filter="tcp and port 80",iface=“eth0”, prn=parse)
                                                ^
SyntaxError: invalid syntax
Was it helpful?

Solution

The double quotes are not the usual double quotes there. Use " (character code 34) or ' (39) instead of (8220):

pkts = sniff(filter="tcp and port 80", iface="eth0", prn=parse)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top